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

Commit

Permalink
Add animation options for zoomIn/zoomOut funtions (#2830)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
yotamberk authored Mar 5, 2017
1 parent 6586c53 commit f8be0a5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 14 deletions.
14 changes: 10 additions & 4 deletions docs/timeline/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1439,15 +1439,21 @@ <h2 id="Methods">Methods</h2>
</tr>

<tr>
<td>zoomIn(percentage)</td>
<td>zoomIn(percentage [, options])</td>
<td>none</td>
<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.
<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:
<ul>
<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>
</ul>
</td>
</tr>
<tr>
<td>zoomOut(percentage)</td>
<td>zoomOut(percentage [, options])</td>
<td>none</td>
<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.
<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:
<ul>
<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>
</ul>
</td>
</tr>

Expand Down
28 changes: 18 additions & 10 deletions lib/timeline/Core.js
Original file line number Diff line number Diff line change
Expand Up @@ -708,8 +708,15 @@ Core.prototype.getWindow = function() {
/**
* Zoom in the window such that given time is centered on screen.
* @param {Number} percentage - must be between [0..1]
* @param {Object} [options] Available options:
* `animation: boolean | {duration: number, easingFunction: string}`
* If true (default), 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 'easeInOutQuad'.
*/
Core.prototype.zoomIn = function(percentage) {
Core.prototype.zoomIn = function(percentage, options) {
if (!percentage || percentage < 0 || percentage > 1) return
var range = this.getWindow();
var start = range.start.valueOf();
Expand All @@ -720,17 +727,21 @@ Core.prototype.zoomIn = function(percentage) {
var newStart = start + distance;
var newEnd = end - distance;

this.setWindow({
start : newStart,
end : newEnd
});
this.setWindow(newStart, newEnd, options);
};

/**
* Zoom out the window such that given time is centered on screen.
* @param {Number} percentage - must be between [0..1]
* @param {Object} [options] Available options:
* `animation: boolean | {duration: number, easingFunction: string}`
* If true (default), 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 'easeInOutQuad'.
*/
Core.prototype.zoomOut = function(percentage) {
Core.prototype.zoomOut = function(percentage, options) {
if (!percentage || percentage < 0 || percentage > 1) return
var range = this.getWindow();
var start = range.start.valueOf();
Expand All @@ -739,10 +750,7 @@ Core.prototype.zoomOut = function(percentage) {
var newStart = start - interval * percentage / 2;
var newEnd = end + interval * percentage / 2;

this.setWindow({
start : newStart,
end : newEnd
});
this.setWindow(newStart, newEnd, options);
};

/**
Expand Down

0 comments on commit f8be0a5

Please sign in to comment.