Skip to content

Commit 1f9eaea

Browse files
authored
Changed the fail-safe code in setTimelineWidth
1 parent de5e93a commit 1f9eaea

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

JavaScript/horizontal_timeline.2.0.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,12 +1390,14 @@ Docs at http://horizontal-timeline.ycodetech.co.uk
13901390
// Get the css left value of the last event date, remove the px unit and add 100 to it.
13911391
lastEventLeft = Number(timelineComponents['timelineEvents'].last().css('left').replace('px', '')) + 100;
13921392

1393-
// Set the timeline width
1394-
totalWidth = lastEventLeft;
1395-
1396-
// Set a fail-safe, if totalWidth is less than the wrapperWidth then use the wrapperWidth as width.
1393+
// Set a fail-safe, if lastEventLeft is less than the wrapperWidth then use the wrapperWidth as totalWidth.
13971394
// Stops the timeline width from being too small.
1398-
if (totalWidth < wrapperWidth) totalWidth = wrapperWidth;
1395+
if (lastEventLeft < wrapperWidth) {
1396+
totalWidth = wrapperWidth;
1397+
}
1398+
else {
1399+
totalWidth = lastEventLeft;
1400+
}
13991401

14001402
timelineComponents['eventsWrapper'].css('width', totalWidth+'px');
14011403
this._updateTimelinePosition(timelineComponents['eventsWrapper'].find('a.selected'), timelineComponents, totalWidth);

0 commit comments

Comments
 (0)