Skip to content

Commit 2506837

Browse files
yotamberkmarcortw
authored andcommitted
feat(timeline): visjs#2647 Dynamic rolling mode option (visjs#2705)
* Fix redraw order * Fix error when option is not defined * Allow template labels * Add .travis.yml file * Add experiment travis code * Fix react example * Add toggleRollingMode option * Update docs with toggleRollingMode option
1 parent 8362807 commit 2506837

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

docs/timeline/index.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,6 +1431,13 @@ <h2 id="Methods">Methods</h2>
14311431
</td>
14321432
</tr>
14331433

1434+
<tr>
1435+
<td>toggleRollingMode()</td>
1436+
<td>none</td>
1437+
<td>Toggle rollingMode.
1438+
</td>
1439+
</tr>
1440+
14341441
<tr>
14351442
<td>zoomIn(percentage)</td>
14361443
<td>none</td>

examples/timeline/interaction/navigationMenu.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
<input type="button" id="zoomOut" value="Zoom out"/>
3939
<input type="button" id="moveLeft" value="Move left"/>
4040
<input type="button" id="moveRight" value="Move right"/>
41+
<input type="button" id="toggleRollingMode" value="toggleRollingMode"/>
4142
</div>
4243
</div>
4344

@@ -74,6 +75,8 @@
7475
document.getElementById('zoomOut').onclick = function () { timeline.zoomOut( 0.2); };
7576
document.getElementById('moveLeft').onclick = function () { move( 0.2); };
7677
document.getElementById('moveRight').onclick = function () { move(-0.2); };
78+
document.getElementById('toggleRollingMode').onclick = function () { timeline.toggleRollingMode() };
79+
7780

7881
</script>
7982
</body>

lib/timeline/Timeline.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,4 +572,20 @@ Timeline.prototype.getEventProperties = function (event) {
572572
}
573573
};
574574

575+
/**
576+
* Toggle Timeline rolling mode
577+
*/
578+
579+
Timeline.prototype.toggleRollingMode = function () {
580+
if (this.range.rolling) {
581+
this.range.stopRolling();
582+
} else {
583+
if (this.options.rollingMode == undefined) {
584+
this.setOptions(options)
585+
}
586+
this.range.startRolling();
587+
}
588+
589+
}
590+
575591
module.exports = Timeline;

0 commit comments

Comments
 (0)