diff --git a/dist/vis.js b/dist/vis.js index 301d517b..6fae9c4e 100644 --- a/dist/vis.js +++ b/dist/vis.js @@ -1419,6 +1419,68 @@ return /******/ (function(modules) { // webpackBootstrap return -change/2 * (t*(t-2) - 1) + start; }; + + + /* + * Easing Functions - inspired from http://gizma.com/easing/ + * only considering the t value for the range [0, 1] => [0, 1] + * https://gist.github.com/gre/1650294 + */ + exports.easingFunctions = { + // no easing, no acceleration + linear: function (t) { + return t + }, + // accelerating from zero velocity + easeInQuad: function (t) { + return t * t + }, + // decelerating to zero velocity + easeOutQuad: function (t) { + return t * (2 - t) + }, + // acceleration until halfway, then deceleration + easeInOutQuad: function (t) { + return t < .5 ? 2 * t * t : -1 + (4 - 2 * t) * t + }, + // accelerating from zero velocity + easeInCubic: function (t) { + return t * t * t + }, + // decelerating to zero velocity + easeOutCubic: function (t) { + return (--t) * t * t + 1 + }, + // acceleration until halfway, then deceleration + easeInOutCubic: function (t) { + return t < .5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1 + }, + // accelerating from zero velocity + easeInQuart: function (t) { + return t * t * t * t + }, + // decelerating to zero velocity + easeOutQuart: function (t) { + return 1 - (--t) * t * t * t + }, + // acceleration until halfway, then deceleration + easeInOutQuart: function (t) { + return t < .5 ? 8 * t * t * t * t : 1 - 8 * (--t) * t * t * t + }, + // accelerating from zero velocity + easeInQuint: function (t) { + return t * t * t * t * t + }, + // decelerating to zero velocity + easeOutQuint: function (t) { + return 1 + (--t) * t * t * t * t + }, + // acceleration until halfway, then deceleration + easeInOutQuint: function (t) { + return t < .5 ? 16 * t * t * t * t * t : 1 + 16 * (--t) * t * t * t * t + } + }; + /***/ }, /* 2 */ /***/ function(module, exports, __webpack_require__) { @@ -21114,66 +21176,6 @@ return /******/ (function(modules) { // webpackBootstrap this._loadHierarchySystem(); - /* - * Easing Functions - inspired from http://gizma.com/easing/ - * only considering the t value for the range [0, 1] => [0, 1] - * https://gist.github.com/gre/1650294 - */ - this.easingFunctions = { - // no easing, no acceleration - linear: function (t) { - return t - }, - // accelerating from zero velocity - easeInQuad: function (t) { - return t * t - }, - // decelerating to zero velocity - easeOutQuad: function (t) { - return t * (2 - t) - }, - // acceleration until halfway, then deceleration - easeInOutQuad: function (t) { - return t < .5 ? 2 * t * t : -1 + (4 - 2 * t) * t - }, - // accelerating from zero velocity - easeInCubic: function (t) { - return t * t * t - }, - // decelerating to zero velocity - easeOutCubic: function (t) { - return (--t) * t * t + 1 - }, - // acceleration until halfway, then deceleration - easeInOutCubic: function (t) { - return t < .5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1 - }, - // accelerating from zero velocity - easeInQuart: function (t) { - return t * t * t * t - }, - // decelerating to zero velocity - easeOutQuart: function (t) { - return 1 - (--t) * t * t * t - }, - // acceleration until halfway, then deceleration - easeInOutQuart: function (t) { - return t < .5 ? 8 * t * t * t * t : 1 - 8 * (--t) * t * t * t - }, - // accelerating from zero velocity - easeInQuint: function (t) { - return t * t * t * t * t - }, - // decelerating to zero velocity - easeOutQuint: function (t) { - return 1 + (--t) * t * t * t * t - }, - // acceleration until halfway, then deceleration - easeInOutQuint: function (t) { - return t < .5 ? 16 * t * t * t * t * t : 1 + 16 * (--t) * t * t * t * t - } - }; - // apply options this._setTranslation(this.frame.clientWidth / 2, this.frame.clientHeight / 2); this._setScale(1); @@ -23289,7 +23291,7 @@ return /******/ (function(modules) { // webpackBootstrap this.easingTime = easingTime || this.easingTime + this.animationSpeed; this.easingTime += this.animationSpeed; - var progress = this.easingFunctions[this.animationEasingFunction](this.easingTime); + var progress = util.easingFunctions[this.animationEasingFunction](this.easingTime); this._setScale(this.sourceScale + (this.targetScale - this.sourceScale) * progress); this._setTranslation( diff --git a/lib/network/Network.js b/lib/network/Network.js index e75a2ffe..df34351b 100644 --- a/lib/network/Network.js +++ b/lib/network/Network.js @@ -257,66 +257,6 @@ function Network (container, data, options) { this._loadHierarchySystem(); - /* - * Easing Functions - inspired from http://gizma.com/easing/ - * only considering the t value for the range [0, 1] => [0, 1] - * https://gist.github.com/gre/1650294 - */ - this.easingFunctions = { - // no easing, no acceleration - linear: function (t) { - return t - }, - // accelerating from zero velocity - easeInQuad: function (t) { - return t * t - }, - // decelerating to zero velocity - easeOutQuad: function (t) { - return t * (2 - t) - }, - // acceleration until halfway, then deceleration - easeInOutQuad: function (t) { - return t < .5 ? 2 * t * t : -1 + (4 - 2 * t) * t - }, - // accelerating from zero velocity - easeInCubic: function (t) { - return t * t * t - }, - // decelerating to zero velocity - easeOutCubic: function (t) { - return (--t) * t * t + 1 - }, - // acceleration until halfway, then deceleration - easeInOutCubic: function (t) { - return t < .5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1 - }, - // accelerating from zero velocity - easeInQuart: function (t) { - return t * t * t * t - }, - // decelerating to zero velocity - easeOutQuart: function (t) { - return 1 - (--t) * t * t * t - }, - // acceleration until halfway, then deceleration - easeInOutQuart: function (t) { - return t < .5 ? 8 * t * t * t * t : 1 - 8 * (--t) * t * t * t - }, - // accelerating from zero velocity - easeInQuint: function (t) { - return t * t * t * t * t - }, - // decelerating to zero velocity - easeOutQuint: function (t) { - return 1 + (--t) * t * t * t * t - }, - // acceleration until halfway, then deceleration - easeInOutQuint: function (t) { - return t < .5 ? 16 * t * t * t * t * t : 1 + 16 * (--t) * t * t * t * t - } - }; - // apply options this._setTranslation(this.frame.clientWidth / 2, this.frame.clientHeight / 2); this._setScale(1); @@ -2432,7 +2372,7 @@ Network.prototype._transitionRedraw = function (easingTime) { this.easingTime = easingTime || this.easingTime + this.animationSpeed; this.easingTime += this.animationSpeed; - var progress = this.easingFunctions[this.animationEasingFunction](this.easingTime); + var progress = util.easingFunctions[this.animationEasingFunction](this.easingTime); this._setScale(this.sourceScale + (this.targetScale - this.sourceScale) * progress); this._setTranslation( diff --git a/lib/util.js b/lib/util.js index 0cdf3fbe..7032f3a6 100644 --- a/lib/util.js +++ b/lib/util.js @@ -1260,4 +1260,66 @@ exports.easeInOutQuad = function (t, start, end, duration) { if (t < 1) return change/2*t*t + start; t--; return -change/2 * (t*(t-2) - 1) + start; +}; + + + +/* + * Easing Functions - inspired from http://gizma.com/easing/ + * only considering the t value for the range [0, 1] => [0, 1] + * https://gist.github.com/gre/1650294 + */ +exports.easingFunctions = { + // no easing, no acceleration + linear: function (t) { + return t + }, + // accelerating from zero velocity + easeInQuad: function (t) { + return t * t + }, + // decelerating to zero velocity + easeOutQuad: function (t) { + return t * (2 - t) + }, + // acceleration until halfway, then deceleration + easeInOutQuad: function (t) { + return t < .5 ? 2 * t * t : -1 + (4 - 2 * t) * t + }, + // accelerating from zero velocity + easeInCubic: function (t) { + return t * t * t + }, + // decelerating to zero velocity + easeOutCubic: function (t) { + return (--t) * t * t + 1 + }, + // acceleration until halfway, then deceleration + easeInOutCubic: function (t) { + return t < .5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1 + }, + // accelerating from zero velocity + easeInQuart: function (t) { + return t * t * t * t + }, + // decelerating to zero velocity + easeOutQuart: function (t) { + return 1 - (--t) * t * t * t + }, + // acceleration until halfway, then deceleration + easeInOutQuart: function (t) { + return t < .5 ? 8 * t * t * t * t : 1 - 8 * (--t) * t * t * t + }, + // accelerating from zero velocity + easeInQuint: function (t) { + return t * t * t * t * t + }, + // decelerating to zero velocity + easeOutQuint: function (t) { + return 1 + (--t) * t * t * t * t + }, + // acceleration until halfway, then deceleration + easeInOutQuint: function (t) { + return t < .5 ? 16 * t * t * t * t * t : 1 + 16 * (--t) * t * t * t * t + } }; \ No newline at end of file