fix: issues with highlight system and todayDate.
This commit is contained in:
parent
8f03ba0572
commit
6d89ee0154
@ -305,7 +305,7 @@ export default class Bar {
|
|||||||
(timeout = setTimeout(() => {
|
(timeout = setTimeout(() => {
|
||||||
this.show_popup(e.offsetX || e.layerX);
|
this.show_popup(e.offsetX || e.layerX);
|
||||||
document.getElementById(
|
document.getElementById(
|
||||||
`${task_id}-highlight`,
|
`highlight-${task_id}`,
|
||||||
).style.display = 'block';
|
).style.display = 'block';
|
||||||
}, 200)),
|
}, 200)),
|
||||||
);
|
);
|
||||||
@ -313,7 +313,7 @@ export default class Bar {
|
|||||||
$.on(this.group, 'mouseleave', () => {
|
$.on(this.group, 'mouseleave', () => {
|
||||||
clearTimeout(timeout);
|
clearTimeout(timeout);
|
||||||
this.gantt.popup?.hide?.();
|
this.gantt.popup?.hide?.();
|
||||||
document.getElementById(`${task_id}-highlight`).style.display =
|
document.getElementById(`highlight-${task_id}`).style.display =
|
||||||
'none';
|
'none';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
22
src/index.js
22
src/index.js
@ -689,13 +689,14 @@ export default class Gantt {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compute the horizontal x-axis distance and associated date for the current date and view.
|
* Compute the horizontal x-axis distance and associated date for the current date and view.
|
||||||
*
|
*
|
||||||
* @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.
|
||||||
*/
|
*/
|
||||||
computeGridHighlightDimensions(view_mode) {
|
computeGridHighlightDimensions(view_mode) {
|
||||||
const todayDate = new Date();
|
const todayDate = new Date();
|
||||||
if (todayDate < this.gantt_start || todayDate > this.gantt_end) return null;
|
if (todayDate < this.gantt_start || todayDate > this.gantt_end)
|
||||||
|
return null;
|
||||||
|
|
||||||
let x = this.options.column_width / 2;
|
let x = this.options.column_width / 2;
|
||||||
|
|
||||||
@ -703,10 +704,10 @@ export default class Gantt {
|
|||||||
return {
|
return {
|
||||||
x:
|
x:
|
||||||
x +
|
x +
|
||||||
(date_utils.diff(today, this.gantt_start, 'hour') /
|
(date_utils.diff(todayDate, this.gantt_start, 'hour') /
|
||||||
this.options.step) *
|
this.options.step) *
|
||||||
this.options.column_width,
|
this.options.column_width,
|
||||||
date: today,
|
date: todayDate,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -746,7 +747,9 @@ export default class Gantt {
|
|||||||
this.view_is(VIEW_MODE.YEAR)
|
this.view_is(VIEW_MODE.YEAR)
|
||||||
) {
|
) {
|
||||||
// Used as we must find the _end_ of session if view is not Day
|
// Used as we must find the _end_ of session if view is not Day
|
||||||
const highlightDimensions = this.computeGridHighlightDimensions(this.options.view_mode);
|
const highlightDimensions = this.computeGridHighlightDimensions(
|
||||||
|
this.options.view_mode,
|
||||||
|
);
|
||||||
if (!highlightDimensions) return;
|
if (!highlightDimensions) return;
|
||||||
const { x: left, date } = highlightDimensions;
|
const { x: left, date } = highlightDimensions;
|
||||||
if (!this.dates.find((d) => d.getTime() == date.getTime())) return;
|
if (!this.dates.find((d) => d.getTime() == date.getTime())) return;
|
||||||
@ -1147,7 +1150,6 @@ export default class Gantt {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bar_wrapper.classList.add('active');
|
bar_wrapper.classList.add('active');
|
||||||
if (this.popup) this.popup.parent.classList.add('hidden');
|
|
||||||
|
|
||||||
if (this.popup) this.popup.parent.classList.add('hidden');
|
if (this.popup) this.popup.parent.classList.add('hidden');
|
||||||
|
|
||||||
@ -1165,7 +1167,7 @@ export default class Gantt {
|
|||||||
ids = [parent_bar_id];
|
ids = [parent_bar_id];
|
||||||
}
|
}
|
||||||
bars = ids.map((id) => this.get_bar(id));
|
bars = ids.map((id) => this.get_bar(id));
|
||||||
|
|
||||||
this.bar_being_dragged = parent_bar_id;
|
this.bar_being_dragged = parent_bar_id;
|
||||||
|
|
||||||
bars.forEach((bar) => {
|
bars.forEach((bar) => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user