Skip to content
This repository was archived by the owner on Jul 29, 2019. It is now read-only.

Commit f8be0a5

Browse files
authored
Add animation options for zoomIn/zoomOut funtions (#2830)
* 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 animation options for zoomIn and zoomOut
1 parent 6586c53 commit f8be0a5

File tree

2 files changed

+28
-14
lines changed

2 files changed

+28
-14
lines changed

docs/timeline/index.html

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,15 +1439,21 @@ <h2 id="Methods">Methods</h2>
14391439
</tr>
14401440

14411441
<tr>
1442-
<td>zoomIn(percentage)</td>
1442+
<td>zoomIn(percentage [, options])</td>
14431443
<td>none</td>
1444-
<td>Zoom in the current visible window. The parameter <code>percentage</code> can be a <code>Number</code> and must be between 0 and 1. If the parameter value of <code>percentage</code> is null, the window will be left unchanged.
1444+
<td>Zoom in the current visible window. The parameter <code>percentage</code> can be a <code>Number</code> and must be between 0 and 1. If the parameter value of <code>percentage</code> is null, the window will be left unchanged. Available options:
1445+
<ul>
1446+
<li><code>animation: boolean or {duration: number, easingFunction: string}</code><br>If true (default) or an Object, the range is animated smoothly to the new window. An object can be provided to specify duration and easing function. Default duration is 500 ms, and default easing function is <code>'easeInOutQuad'</code>. Available easing functions: <code>"linear"</code>, <code>"easeInQuad"</code>, <code>"easeOutQuad"</code>, <code>"easeInOutQuad"</code>, <code>"easeInCubic"</code>, <code>"easeOutCubic"</code>, <code>"easeInOutCubic"</code>, <code>"easeInQuart"</code>, <code>"easeOutQuart"</code>, <code>"easeInOutQuart"</code>, <code>"easeInQuint"</code>, <code>"easeOutQuint"</code>, <code>"easeInOutQuint"</code>.</li>
1447+
</ul>
14451448
</td>
14461449
</tr>
14471450
<tr>
1448-
<td>zoomOut(percentage)</td>
1451+
<td>zoomOut(percentage [, options])</td>
14491452
<td>none</td>
1450-
<td>Zoom out the current visible window. The parameter <code>percentage</code> can be a <code>Number</code> and must be between 0 and 1. If the parameter value of <code>percentage</code> is null, the window will be left unchanged.
1453+
<td>Zoom out the current visible window. The parameter <code>percentage</code> can be a <code>Number</code> and must be between 0 and 1. If the parameter value of <code>percentage</code> is null, the window will be left unchanged. Available options:
1454+
<ul>
1455+
<li><code>animation: boolean or {duration: number, easingFunction: string}</code><br>If true (default) or an Object, the range is animated smoothly to the new window. An object can be provided to specify duration and easing function. Default duration is 500 ms, and default easing function is <code>'easeInOutQuad'</code>. Available easing functions: <code>"linear"</code>, <code>"easeInQuad"</code>, <code>"easeOutQuad"</code>, <code>"easeInOutQuad"</code>, <code>"easeInCubic"</code>, <code>"easeOutCubic"</code>, <code>"easeInOutCubic"</code>, <code>"easeInQuart"</code>, <code>"easeOutQuart"</code>, <code>"easeInOutQuart"</code>, <code>"easeInQuint"</code>, <code>"easeOutQuint"</code>, <code>"easeInOutQuint"</code>.</li>
1456+
</ul>
14511457
</td>
14521458
</tr>
14531459

lib/timeline/Core.js

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -708,8 +708,15 @@ Core.prototype.getWindow = function() {
708708
/**
709709
* Zoom in the window such that given time is centered on screen.
710710
* @param {Number} percentage - must be between [0..1]
711+
* @param {Object} [options] Available options:
712+
* `animation: boolean | {duration: number, easingFunction: string}`
713+
* If true (default), the range is animated
714+
* smoothly to the new window. An object can be
715+
* provided to specify duration and easing function.
716+
* Default duration is 500 ms, and default easing
717+
* function is 'easeInOutQuad'.
711718
*/
712-
Core.prototype.zoomIn = function(percentage) {
719+
Core.prototype.zoomIn = function(percentage, options) {
713720
if (!percentage || percentage < 0 || percentage > 1) return
714721
var range = this.getWindow();
715722
var start = range.start.valueOf();
@@ -720,17 +727,21 @@ Core.prototype.zoomIn = function(percentage) {
720727
var newStart = start + distance;
721728
var newEnd = end - distance;
722729

723-
this.setWindow({
724-
start : newStart,
725-
end : newEnd
726-
});
730+
this.setWindow(newStart, newEnd, options);
727731
};
728732

729733
/**
730734
* Zoom out the window such that given time is centered on screen.
731735
* @param {Number} percentage - must be between [0..1]
736+
* @param {Object} [options] Available options:
737+
* `animation: boolean | {duration: number, easingFunction: string}`
738+
* If true (default), the range is animated
739+
* smoothly to the new window. An object can be
740+
* provided to specify duration and easing function.
741+
* Default duration is 500 ms, and default easing
742+
* function is 'easeInOutQuad'.
732743
*/
733-
Core.prototype.zoomOut = function(percentage) {
744+
Core.prototype.zoomOut = function(percentage, options) {
734745
if (!percentage || percentage < 0 || percentage > 1) return
735746
var range = this.getWindow();
736747
var start = range.start.valueOf();
@@ -739,10 +750,7 @@ Core.prototype.zoomOut = function(percentage) {
739750
var newStart = start - interval * percentage / 2;
740751
var newEnd = end + interval * percentage / 2;
741752

742-
this.setWindow({
743-
start : newStart,
744-
end : newEnd
745-
});
753+
this.setWindow(newStart, newEnd, options);
746754
};
747755

748756
/**

0 commit comments

Comments
 (0)