fix: bug with current marking
This commit is contained in:
parent
fcd04922bd
commit
097d69ce90
@ -50,7 +50,7 @@ const DEFAULT_VIEW_MODES = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Day',
|
name: 'Day',
|
||||||
padding: '1m',
|
padding: '14d',
|
||||||
format_string: 'YYYY-MM-DD',
|
format_string: 'YYYY-MM-DD',
|
||||||
step: '1d',
|
step: '1d',
|
||||||
lower_text: (d, ld, lang) =>
|
lower_text: (d, ld, lang) =>
|
||||||
@ -158,7 +158,9 @@ const DEFAULT_OPTIONS = {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
ctx.add_action('-', (task, chart) => {
|
ctx.add_action('-', (task, chart) => {
|
||||||
task.progress -= (1 / task.actual_duration) * 100;
|
task.progress -=
|
||||||
|
Math.floor((1 / task.actual_duration) * 10000) / 100;
|
||||||
|
console.log(task.progress);
|
||||||
chart.refresh(
|
chart.refresh(
|
||||||
chart.tasks.map((t) => (t.id !== task.id ? t : task)),
|
chart.tasks.map((t) => (t.id !== task.id ? t : task)),
|
||||||
);
|
);
|
||||||
|
|||||||
16
src/index.js
16
src/index.js
@ -642,8 +642,10 @@ export default class Gantt {
|
|||||||
* @returns Object containing the x-axis distance and date of the current date, or null if the current date is out of the gantt range.
|
* @returns Object containing the x-axis distance and date of the current date, or null if the current date is out of the gantt range.
|
||||||
*/
|
*/
|
||||||
highlightNow() {
|
highlightNow() {
|
||||||
const [_, el] = this.get_closest_date();
|
const res = this.get_closest_date();
|
||||||
|
if (!res) return;
|
||||||
|
|
||||||
|
const [_, el] = res;
|
||||||
el.classList.add('current-date-highlight');
|
el.classList.add('current-date-highlight');
|
||||||
|
|
||||||
const diff_in_units = date_utils.diff(
|
const diff_in_units = date_utils.diff(
|
||||||
@ -751,6 +753,9 @@ export default class Gantt {
|
|||||||
$upper_text.innerText = date.upper_text;
|
$upper_text.innerText = date.upper_text;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
this.upperTexts = Array.from(
|
||||||
|
this.$container.querySelectorAll('.upper-text'),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
get_dates_to_draw() {
|
get_dates_to_draw() {
|
||||||
@ -889,9 +894,6 @@ export default class Gantt {
|
|||||||
this.$current.classList.remove('current-upper');
|
this.$current.classList.remove('current-upper');
|
||||||
}
|
}
|
||||||
|
|
||||||
this.upperTexts = Array.from(
|
|
||||||
this.$container.querySelectorAll('.upper-text'),
|
|
||||||
);
|
|
||||||
this.current_date = date_utils.add(
|
this.current_date = date_utils.add(
|
||||||
this.gantt_start,
|
this.gantt_start,
|
||||||
this.$container.scrollLeft / this.config.column_width,
|
this.$container.scrollLeft / this.config.column_width,
|
||||||
@ -904,7 +906,7 @@ export default class Gantt {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Recalculate
|
// Recalculate
|
||||||
this.current_date = this.current_date = date_utils.add(
|
this.current_date = date_utils.add(
|
||||||
this.gantt_start,
|
this.gantt_start,
|
||||||
(this.$container.scrollLeft + $el.clientWidth) /
|
(this.$container.scrollLeft + $el.clientWidth) /
|
||||||
this.config.column_width,
|
this.config.column_width,
|
||||||
@ -917,8 +919,8 @@ export default class Gantt {
|
|||||||
}
|
}
|
||||||
|
|
||||||
scroll_today() {
|
scroll_today() {
|
||||||
let [today, _] = this.get_closest_date();
|
let res = this.get_closest_date();
|
||||||
this.set_scroll_position(today);
|
if (res) this.set_scroll_position(res[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
get_closest_date() {
|
get_closest_date() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user