Skip to content

Commit 8853d50

Browse files
committed
Fixes #52 (scrollToToday).
1 parent 2f6aabf commit 8853d50

File tree

1 file changed

+2
-19
lines changed

1 file changed

+2
-19
lines changed

js/jquery.fn.gantt.js

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
itemsPerPage: 7,
3636
months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
3737
dow: ["S", "M", "T", "W", "T", "F", "S"],
38-
startPos: new Date(),
3938
navigate: "buttons",
4039
scale: "days",
4140
useCookie: false,
@@ -286,24 +285,8 @@
286285

287286
// Scroll the grid to today's date
288287
if (settings.scrollToToday) {
289-
var startPos = Math.round((settings.startPos / 1000 - element.dateStart / 1000) / 86400) - 2;
290-
if ((startPos > 0 && element.hPosition !== 0)) {
291-
if (element.scaleOldWidth) {
292-
mLeft = ($dataPanel.width() - $rightPanel.width());
293-
hPos = mLeft * element.hPosition / element.scaleOldWidth;
294-
hPos = hPos > 0 ? 0 : hPos;
295-
$dataPanel.css({ "margin-left": hPos + "px" });
296-
element.scrollNavigation.panelMargin = hPos;
297-
element.hPosition = hPos;
298-
element.scaleOldWidth = null;
299-
} else {
300-
$dataPanel.css({ "margin-left": element.hPosition + "px" });
301-
element.scrollNavigation.panelMargin = element.hPosition;
302-
}
303-
core.repositionLabel(element);
304-
} else {
305-
core.repositionLabel(element);
306-
}
288+
core.navigateTo(element, 'now');
289+
core.scrollPanel(element, 0);
307290
// or, scroll the grid to the left most date in the panel
308291
} else {
309292
if ((element.hPosition !== 0)) {

0 commit comments

Comments
 (0)