vendor/assets/javascripts/greensock/TweenMax.js in greensock-rails-1.13.1.0 vs vendor/assets/javascripts/greensock/TweenMax.js in greensock-rails-1.13.2.0

- old
+ new

@@ -1,8 +1,8 @@ /*! - * VERSION: 1.13.1 - * DATE: 2014-07-19 + * VERSION: 1.13.2 + * DATE: 2014-08-23 * UPDATES AND DOCS AT: http://www.greensock.com * * Includes all of the following: TweenLite, TweenMax, TimelineLite, TimelineMax, EasePack, CSSPlugin, RoundPropsPlugin, BezierPlugin, AttrPlugin, DirectionalRotationPlugin * * @license Copyright (c) 2008-2014, GreenSock. All rights reserved. @@ -39,11 +39,11 @@ _isSelector = TweenLiteInternals.isSelector, _isArray = TweenLiteInternals.isArray, p = TweenMax.prototype = TweenLite.to({}, 0.1, {}), _blankArray = []; - TweenMax.version = "1.13.1"; + TweenMax.version = "1.13.2"; p.constructor = TweenMax; p.kill()._gc = false; TweenMax.killTweensOf = TweenMax.killDelayedCallsTo = TweenLite.killTweensOf; TweenMax.getTweensOf = TweenLite.getTweensOf; TweenMax.lagSmoothing = TweenLite.lagSmoothing; @@ -155,11 +155,12 @@ if (prevRawPrevTime >= 0) { force = true; } this._rawPrevTime = rawPrevTime = (!suppressEvents || time || prevRawPrevTime === time) ? time : _tinyNum; //when the playhead arrives at EXACTLY time 0 (right on top) of a zero-duration tween, we need to discern if events are suppressed so that when the playhead moves again (next time), it'll trigger the callback. If events are NOT suppressed, obviously the callback would be triggered in this render. Basically, the callback should fire either when the playhead ARRIVES or LEAVES this exact spot, not both. Imagine doing a timeline.seek(0) and there's a callback that sits at 0. Since events are suppressed on that seek() by default, nothing will fire, but when the playhead moves off of that position, the callback should fire. This behavior is what people intuitively expect. We set the _rawPrevTime to be a precise tiny number to indicate this scenario rather than using another property/variable which would increase memory usage. This technique is less readable, but more efficient. } - } else if (!this._initted) { //if we render the very beginning (time == 0) of a fromTo(), we must force the render (normal tweens wouldn't need to render at a time of 0 when the prevTime was also 0). This is also mandatory to make sure overwriting kicks in immediately. + } + if (!this._initted) { //if we render the very beginning (time == 0) of a fromTo(), we must force the render (normal tweens wouldn't need to render at a time of 0 when the prevTime was also 0). This is also mandatory to make sure overwriting kicks in immediately. force = true; } } else { this._totalTime = this._time = time; @@ -229,11 +230,11 @@ this._time = prevTime; this._totalTime = prevTotalTime; this._rawPrevTime = prevRawPrevTime; this._cycle = prevCycle; TweenLiteInternals.lazyTweens.push(this); - this._lazy = time; + this._lazy = [time, suppressEvents]; return; } //_ease is initially set to defaultEase, so now that init() has run, _ease is set properly and we need to recalculate the ratio. Overall this is faster than using conditional logic earlier in the method to avoid having to set ratio twice because we only init() once but renderTime() gets called VERY frequently. if (this._time && !isComplete) { this.ratio = this._ease.getRatio(this._time / duration); @@ -628,13 +629,19 @@ copy[p] = vars[p]; } return copy; }, _pauseCallback = function(tween, callback, params, scope) { - tween._timeline.pause(tween._startTime); - if (callback) { - callback.apply(scope || tween._timeline, params || _blankArray); + var time = tween._timeline._totalTime; + if (callback || !this._forcingPlayhead) { //if the user calls a method that moves the playhead (like progress() or time()), it should honor that and skip any pauses (although if there's a callback positioned at that pause, it must jump there and make the call to ensure the time is EXACTLY what it is supposed to be, and then proceed to where the playhead is being forced). Otherwise, imagine placing a pause in the middle of a timeline and then doing timeline.progress(0.9) - it would get stuck where the pause is. + tween._timeline.pause(tween._startTime); + if (callback) { + callback.apply(scope || tween._timeline, params || _blankArray); + } + if (this._forcingPlayhead) { + tween._timeline.seek(time); + } } }, _slice = function(a) { //don't use [].slice because that doesn't work in IE8 with a NodeList that's returned by querySelectorAll() var b = [], l = a.length, @@ -642,13 +649,13 @@ for (i = 0; i !== l; b.push(a[i++])); return b; }, p = TimelineLite.prototype = new SimpleTimeline(); - TimelineLite.version = "1.13.1"; + TimelineLite.version = "1.13.2"; p.constructor = TimelineLite; - p.kill()._gc = false; + p.kill()._gc = p._forcingPlayhead = false; /* might use later... //translates a local time inside an animation to the corresponding time on the root/global timeline, factoring in all nesting and timeScales. function localToGlobal(time, animation) { while (animation) { @@ -1154,11 +1161,11 @@ var tween = this._first; while (tween) { tween.invalidate(); tween = tween._next; } - return this; + return Animation.prototype.invalidate.call(this);; }; p._enabled = function(enabled, ignoreTimeline) { if (enabled === this._gc) { var tween = this._first; @@ -1168,10 +1175,17 @@ } } return SimpleTimeline.prototype._enabled.call(this, enabled, ignoreTimeline); }; + p.totalTime = function(time, suppressEvents, uncapped) { + this._forcingPlayhead = true; + var val = Animation.prototype.totalTime.apply(this, arguments); + this._forcingPlayhead = false; + return val; + }; + p.duration = function(value) { if (!arguments.length) { if (this._dirty) { this.totalDuration(); //just triggers recalculation } @@ -1276,11 +1290,11 @@ _easeNone = new Ease(null, null, 1, 0), p = TimelineMax.prototype = new TimelineLite(); p.constructor = TimelineMax; p.kill()._gc = false; - TimelineMax.version = "1.13.1"; + TimelineMax.version = "1.13.2"; p.invalidate = function() { this._yoyo = (this.vars.yoyo === true); this._repeat = this.vars.repeat || 0; this._repeatDelay = this.vars.repeatDelay || 0; @@ -1618,16 +1632,16 @@ }; //---- GETTERS / SETTERS ------------------------------------------------------------------------------------------------------- - p.progress = function(value) { - return (!arguments.length) ? this._time / this.duration() : this.totalTime( this.duration() * ((this._yoyo && (this._cycle & 1) !== 0) ? 1 - value : value) + (this._cycle * (this._duration + this._repeatDelay)), false); + p.progress = function(value, suppressEvents) { + return (!arguments.length) ? this._time / this.duration() : this.totalTime( this.duration() * ((this._yoyo && (this._cycle & 1) !== 0) ? 1 - value : value) + (this._cycle * (this._duration + this._repeatDelay)), suppressEvents); }; - p.totalProgress = function(value) { - return (!arguments.length) ? this._totalTime / this.totalDuration() : this.totalTime( this.totalDuration() * value, false); + p.totalProgress = function(value, suppressEvents) { + return (!arguments.length) ? this._totalTime / this.totalDuration() : this.totalTime( this.totalDuration() * value, suppressEvents); }; p.totalDuration = function(value) { if (!arguments.length) { if (this._dirty) { @@ -2309,11 +2323,11 @@ _overwriteProps, //alias to the currently instantiating CSSPlugin's _overwriteProps array. We use this closure in order to avoid having to pass a reference around from method to method and aid in minification. _specialProps = {}, p = CSSPlugin.prototype = new TweenPlugin("css"); p.constructor = CSSPlugin; - CSSPlugin.version = "1.13.1"; + CSSPlugin.version = "1.13.2"; CSSPlugin.API = 2; CSSPlugin.defaultTransformPerspective = 0; CSSPlugin.defaultSkewType = "compensated"; p = "px"; //we'll reuse the "p" variable to keep file size down CSSPlugin.suffixMap = {top:p, right:p, bottom:p, left:p, width:p, height:p, fontSize:p, padding:p, margin:p, perspective:p, lineHeight:""}; @@ -3355,20 +3369,21 @@ min = 0.00002, rnd = 100000, minAngle = 179.99, minPI = minAngle * _DEG2RAD, zOrigin = _supports3D ? parseFloat(_getStyle(t, _transformOriginProp, cs, false, "0 0 0").split(" ")[2]) || tm.zOrigin || 0 : 0, + defaultTransformPerspective = parseFloat(CSSPlugin.defaultTransformPerspective) || 0, s, m, i, n, dec, scaleX, scaleY, rotation, skewX, difX, difY, difR, difS; if (_transformProp) { s = _getStyle(t, _transformPropCSS, cs, true); } else if (t.currentStyle) { //for older versions of IE, we need to interpret the filter portion that is in the format: progid:DXImageTransform.Microsoft.Matrix(M11=6.123233995736766e-17, M12=-1, M21=1, M22=6.123233995736766e-17, sizingMethod='auto expand') Notice that we need to swap b and c compared to a normal matrix. s = t.currentStyle.filter.match(_ieGetMatrixExp); s = (s && s.length === 4) ? [s[0].substr(4), Number(s[2].substr(4)), Number(s[1].substr(4)), s[3].substr(4), (tm.x || 0), (tm.y || 0)].join(",") : ""; } if (!s || s === "none" || s === "matrix(1, 0, 0, 1, 0, 0)") { //if no transforms are applied, just use the defaults to optimize performance (no need to parse). - tm = {x:0, y:0, z:0, scaleX:1, scaleY:1, scaleZ:1, skewX:0, perspective:0, rotation:0, rotationX:0, rotationY:0, zOrigin:0}; + tm = {x:0, y:0, z:0, scaleX:1, scaleY:1, scaleZ:1, skewX:0, perspective:defaultTransformPerspective, rotation:0, rotationX:0, rotationY:0, zOrigin:0}; } else { //split the matrix values out into an array (m for matrix) m = (s || "").match(/(?:\-|\b)[\d\-\.e]+\b/gi) || []; i = m.length; while (--i > -1) { @@ -3495,11 +3510,11 @@ tm.rotation = rotation; tm.skewX = skewX; } if (_supports3D) { tm.rotationX = tm.rotationY = tm.z = 0; - tm.perspective = parseFloat(CSSPlugin.defaultTransformPerspective) || 0; + tm.perspective = defaultTransformPerspective; tm.scaleZ = 1; } } tm.zOrigin = zOrigin; @@ -5226,11 +5241,11 @@ * <script> * var gs = window.GreenSockGlobals = {}; //the newer version we're about to load could now be referenced in a "gs" object, like gs.TweenLite.to(...). Use whatever alias you want as long as it's unique, "gs" or "banner" or whatever. * </script> * <script src="js/greensock/v1.7/TweenMax.js"></script> * <script> - * window.GreenSockGlobals = window._gsQueue = null; //reset it back to null (along with the special _gsQueue variable) so that the next load of TweenMax affects the window and we can reference things directly like TweenLite.to(...) + * window.GreenSockGlobals = window._gsQueue = window._gsDefine = null; //reset it back to null (along with the special _gsQueue variable) so that the next load of TweenMax affects the window and we can reference things directly like TweenLite.to(...) * </script> * <script src="js/greensock/v1.6/TweenMax.js"></script> * <script> * gs.TweenLite.to(...); //would use v1.7 * TweenLite.to(...); //would use v1.6 @@ -5633,10 +5648,16 @@ p.render = function(time, suppressEvents, force) { //stub - we override this method in subclasses. }; p.invalidate = function() { + this._time = this._totalTime = 0; + this._initted = this._gc = false; + this._rawPrevTime = -1; + if (this._gc || !this.timeline) { + this._enabled(true); + } return this; }; p.isActive = function() { var tl = this._timeline, //the 2 root timelines won't have a _timeline; they're always active. @@ -6056,11 +6077,11 @@ p.ratio = 0; p._firstPT = p._targets = p._overwrittenProps = p._startAt = null; p._notifyPluginsOfEnabled = p._lazy = false; - TweenLite.version = "1.13.1"; + TweenLite.version = "1.13.2"; TweenLite.defaultEase = p._ease = new Ease(null, null, 1, 1); TweenLite.defaultOverwrite = "auto"; TweenLite.ticker = _ticker; TweenLite.autoSleep = true; TweenLite.lagSmoothing = function(threshold, adjustedLag) { @@ -6090,11 +6111,11 @@ var i = _lazyTweens.length; _lazyLookup = {}; while (--i > -1) { a = _lazyTweens[i]; if (a && a._lazy !== false) { - a.render(a._lazy, false, true); + a.render(a._lazy[0], a._lazy[1], true); a._lazy = false; } } _lazyTweens.length = 0; }; @@ -6263,10 +6284,13 @@ if (this._startAt) { this._startAt.render(-1, true); this._startAt.kill(); this._startAt = null; } else { + if (this._time !== 0) { //in rare cases (like if a from() tween runs and then is invalidate()-ed), immediateRender could be true but the initial forced-render gets skipped, so there's no need to force the render in this context when the _time is greater than 0 + immediate = false; + } pt = {}; for (p in v) { //copy props into a new object and skip any reserved props, otherwise onComplete or onUpdate or onStart could fire. We should, however, permit autoCSS to go through. if (!_reservedProps[p] || p === "autoCSS") { pt[p] = v[p]; } @@ -6277,10 +6301,13 @@ pt.immediateRender = immediate; //zero-duration tweens render immediately by default, but if we're not specifically instructed to render this tween immediately, we should skip this and merely _init() to record the starting values (rendering them immediately would push them to completion which is wasteful in that case - we'd have to render(-1) immediately after) this._startAt = TweenLite.to(this.target, 0, pt); if (!immediate) { this._startAt._init(); //ensures that the initial values are recorded this._startAt._enabled(false); //no need to have the tween render on the next cycle. Disable it because we'll always manually control the renders of the _startAt tween. + if (this.vars.immediateRender) { + this._startAt = null; + } } else if (this._time === 0) { return; } } } @@ -6424,11 +6451,12 @@ if (prevRawPrevTime >= 0) { force = true; } this._rawPrevTime = rawPrevTime = (!suppressEvents || time || prevRawPrevTime === time) ? time : _tinyNum; //when the playhead arrives at EXACTLY time 0 (right on top) of a zero-duration tween, we need to discern if events are suppressed so that when the playhead moves again (next time), it'll trigger the callback. If events are NOT suppressed, obviously the callback would be triggered in this render. Basically, the callback should fire either when the playhead ARRIVES or LEAVES this exact spot, not both. Imagine doing a timeline.seek(0) and there's a callback that sits at 0. Since events are suppressed on that seek() by default, nothing will fire, but when the playhead moves off of that position, the callback should fire. This behavior is what people intuitively expect. We set the _rawPrevTime to be a precise tiny number to indicate this scenario rather than using another property/variable which would increase memory usage. This technique is less readable, but more efficient. } - } else if (!this._initted) { //if we render the very beginning (time == 0) of a fromTo(), we must force the render (normal tweens wouldn't need to render at a time of 0 when the prevTime was also 0). This is also mandatory to make sure overwriting kicks in immediately. + } + if (!this._initted) { //if we render the very beginning (time == 0) of a fromTo(), we must force the render (normal tweens wouldn't need to render at a time of 0 when the prevTime was also 0). This is also mandatory to make sure overwriting kicks in immediately. force = true; } } else { this._totalTime = this._time = time; @@ -6473,11 +6501,11 @@ return; } else if (!force && this._firstPT && ((this.vars.lazy !== false && this._duration) || (this.vars.lazy && !this._duration))) { this._time = this._totalTime = prevTime; this._rawPrevTime = prevRawPrevTime; _lazyTweens.push(this); - this._lazy = time; + this._lazy = [time, suppressEvents]; return; } //_ease is initially set to defaultEase, so now that init() has run, _ease is set properly and we need to recalculate the ratio. Overall this is faster than using conditional logic earlier in the method to avoid having to set ratio twice because we only init() once but renderTime() gets called VERY frequently. if (this._time && !isComplete) { this.ratio = this._ease.getRatio(this._time / duration); @@ -6611,15 +6639,17 @@ p.invalidate = function() { if (this._notifyPluginsOfEnabled) { TweenLite._onPluginEvent("_onDisable", this); } - this._firstPT = null; - this._overwrittenProps = null; - this._onUpdate = null; - this._startAt = null; - this._initted = this._active = this._notifyPluginsOfEnabled = this._lazy = false; + this._firstPT = this._overwrittenProps = this._startAt = this._onUpdate = null; + this._notifyPluginsOfEnabled = this._active = this._lazy = false; this._propLookup = (this._targets) ? {} : []; + Animation.prototype.invalidate.call(this); + if (this.vars.immediateRender) { + this._time = -_tinyNum; //forces a render without having to set the render() "force" parameter to true because we want to allow lazying by default (using the "force" parameter always forces an immediate full render) + this.render(-this._delay); + } return this; }; p._enabled = function(enabled, ignoreTimeline) { if (!_tickerActive) { \ No newline at end of file