greensock-rails 1.11.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (26) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +2 -0
  3. data/README.md +47 -0
  4. data/lib/greensock/rails.rb +9 -0
  5. data/lib/greensock/rails/version.rb +5 -0
  6. data/vendor/assets/javascripts/greensock/TimelineLite.js +622 -0
  7. data/vendor/assets/javascripts/greensock/TimelineMax.js +1060 -0
  8. data/vendor/assets/javascripts/greensock/TweenLite.js +1654 -0
  9. data/vendor/assets/javascripts/greensock/TweenMax.js +6662 -0
  10. data/vendor/assets/javascripts/greensock/easing/EasePack.js +343 -0
  11. data/vendor/assets/javascripts/greensock/jquery.gsap.js +167 -0
  12. data/vendor/assets/javascripts/greensock/plugins/AttrPlugin.js +51 -0
  13. data/vendor/assets/javascripts/greensock/plugins/BezierPlugin.js +574 -0
  14. data/vendor/assets/javascripts/greensock/plugins/CSSPlugin.js +2260 -0
  15. data/vendor/assets/javascripts/greensock/plugins/CSSRulePlugin.js +100 -0
  16. data/vendor/assets/javascripts/greensock/plugins/ColorPropsPlugin.js +122 -0
  17. data/vendor/assets/javascripts/greensock/plugins/DirectionalRotationPlugin.js +80 -0
  18. data/vendor/assets/javascripts/greensock/plugins/EaselPlugin.js +298 -0
  19. data/vendor/assets/javascripts/greensock/plugins/KineticPlugin.js +298 -0
  20. data/vendor/assets/javascripts/greensock/plugins/RaphaelPlugin.js +367 -0
  21. data/vendor/assets/javascripts/greensock/plugins/RoundPropsPlugin.js +73 -0
  22. data/vendor/assets/javascripts/greensock/plugins/ScrollToPlugin.js +115 -0
  23. data/vendor/assets/javascripts/greensock/plugins/TEMPLATE_Plugin.js +74 -0
  24. data/vendor/assets/javascripts/greensock/plugins/TextPlugin.js +108 -0
  25. data/vendor/assets/javascripts/greensock/utils/Draggable.js +1438 -0
  26. metadata +97 -0
@@ -0,0 +1,73 @@
1
+ /*!
2
+ * VERSION: beta 1.4.0
3
+ * DATE: 2013-02-27
4
+ * UPDATES AND DOCS AT: http://www.greensock.com
5
+ *
6
+ * @license Copyright (c) 2008-2014, GreenSock. All rights reserved.
7
+ * This work is subject to the terms at http://www.greensock.com/terms_of_use.html or for
8
+ * Club GreenSock members, the software agreement that was issued with your membership.
9
+ *
10
+ * @author: Jack Doyle, jack@greensock.com
11
+ **/
12
+ (window._gsQueue || (window._gsQueue = [])).push( function() {
13
+
14
+ "use strict";
15
+
16
+ var RoundPropsPlugin = window._gsDefine.plugin({
17
+ propName: "roundProps",
18
+ priority: -1,
19
+ API: 2,
20
+
21
+ //called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run.
22
+ init: function(target, value, tween) {
23
+ this._tween = tween;
24
+ return true;
25
+ }
26
+
27
+ }),
28
+ p = RoundPropsPlugin.prototype;
29
+
30
+ p._onInitAllProps = function() {
31
+ var tween = this._tween,
32
+ rp = (tween.vars.roundProps instanceof Array) ? tween.vars.roundProps : tween.vars.roundProps.split(","),
33
+ i = rp.length,
34
+ lookup = {},
35
+ rpt = tween._propLookup.roundProps,
36
+ prop, pt, next;
37
+ while (--i > -1) {
38
+ lookup[rp[i]] = 1;
39
+ }
40
+ i = rp.length;
41
+ while (--i > -1) {
42
+ prop = rp[i];
43
+ pt = tween._firstPT;
44
+ while (pt) {
45
+ next = pt._next; //record here, because it may get removed
46
+ if (pt.pg) {
47
+ pt.t._roundProps(lookup, true);
48
+ } else if (pt.n === prop) {
49
+ this._add(pt.t, prop, pt.s, pt.c);
50
+ //remove from linked list
51
+ if (next) {
52
+ next._prev = pt._prev;
53
+ }
54
+ if (pt._prev) {
55
+ pt._prev._next = next;
56
+ } else if (tween._firstPT === pt) {
57
+ tween._firstPT = next;
58
+ }
59
+ pt._next = pt._prev = null;
60
+ tween._propLookup[prop] = rpt;
61
+ }
62
+ pt = next;
63
+ }
64
+ }
65
+ return false;
66
+ };
67
+
68
+ p._add = function(target, p, s, c) {
69
+ this._addTween(target, p, s, s + c, p, true);
70
+ this._overwriteProps.push(p);
71
+ };
72
+
73
+ }); if (window._gsDefine) { window._gsQueue.pop()(); }
@@ -0,0 +1,115 @@
1
+ /*!
2
+ * VERSION: 1.7.3
3
+ * DATE: 2014-01-14
4
+ * UPDATES AND DOCS AT: http://www.greensock.com
5
+ *
6
+ * @license Copyright (c) 2008-2014, GreenSock. All rights reserved.
7
+ * This work is subject to the terms at http://www.greensock.com/terms_of_use.html or for
8
+ * Club GreenSock members, the software agreement that was issued with your membership.
9
+ *
10
+ * @author: Jack Doyle, jack@greensock.com
11
+ **/
12
+ (window._gsQueue || (window._gsQueue = [])).push( function() {
13
+
14
+ "use strict";
15
+
16
+ var _doc = document.documentElement,
17
+ _window = window,
18
+ _max = function(element, axis) {
19
+ var dim = (axis === "x") ? "Width" : "Height",
20
+ scroll = "scroll" + dim,
21
+ client = "client" + dim,
22
+ body = document.body;
23
+ return (element === _window || element === _doc || element === body) ? Math.max(_doc[scroll], body[scroll]) - (_window["inner" + dim] || Math.max(_doc[client], body[client])) : element[scroll] - element["offset" + dim];
24
+ },
25
+
26
+ ScrollToPlugin = window._gsDefine.plugin({
27
+ propName: "scrollTo",
28
+ API: 2,
29
+ version:"1.7.3",
30
+
31
+ //called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run.
32
+ init: function(target, value, tween) {
33
+ this._wdw = (target === _window);
34
+ this._target = target;
35
+ this._tween = tween;
36
+ if (typeof(value) !== "object") {
37
+ value = {y:value}; //if we don't receive an object as the parameter, assume the user intends "y".
38
+ }
39
+ this._autoKill = (value.autoKill !== false);
40
+ this.x = this.xPrev = this.getX();
41
+ this.y = this.yPrev = this.getY();
42
+ if (value.x != null) {
43
+ this._addTween(this, "x", this.x, (value.x === "max") ? _max(target, "x") : value.x, "scrollTo_x", true);
44
+ this._overwriteProps.push("scrollTo_x");
45
+ } else {
46
+ this.skipX = true;
47
+ }
48
+ if (value.y != null) {
49
+ this._addTween(this, "y", this.y, (value.y === "max") ? _max(target, "y") : value.y, "scrollTo_y", true);
50
+ this._overwriteProps.push("scrollTo_y");
51
+ } else {
52
+ this.skipY = true;
53
+ }
54
+ return true;
55
+ },
56
+
57
+ //called each time the values should be updated, and the ratio gets passed as the only parameter (typically it's a value between 0 and 1, but it can exceed those when using an ease like Elastic.easeOut or Back.easeOut, etc.)
58
+ set: function(v) {
59
+ this._super.setRatio.call(this, v);
60
+
61
+ var x = (this._wdw || !this.skipX) ? this.getX() : this.xPrev,
62
+ y = (this._wdw || !this.skipY) ? this.getY() : this.yPrev,
63
+ yDif = y - this.yPrev,
64
+ xDif = x - this.xPrev;
65
+
66
+ if (this._autoKill) {
67
+ //note: iOS has a bug that throws off the scroll by several pixels, so we need to check if it's within 7 pixels of the previous one that we set instead of just looking for an exact match.
68
+ if (!this.skipX && (xDif > 7 || xDif < -7) && x < _max(this._target, "x")) {
69
+ this.skipX = true; //if the user scrolls separately, we should stop tweening!
70
+ }
71
+ if (!this.skipY && (yDif > 7 || yDif < -7) && y < _max(this._target, "y")) {
72
+ this.skipY = true; //if the user scrolls separately, we should stop tweening!
73
+ }
74
+ if (this.skipX && this.skipY) {
75
+ this._tween.kill();
76
+ }
77
+ }
78
+ if (this._wdw) {
79
+ _window.scrollTo((!this.skipX) ? this.x : x, (!this.skipY) ? this.y : y);
80
+ } else {
81
+ if (!this.skipY) {
82
+ this._target.scrollTop = this.y;
83
+ }
84
+ if (!this.skipX) {
85
+ this._target.scrollLeft = this.x;
86
+ }
87
+ }
88
+ this.xPrev = this.x;
89
+ this.yPrev = this.y;
90
+ }
91
+
92
+ }),
93
+ p = ScrollToPlugin.prototype;
94
+
95
+ ScrollToPlugin.max = _max;
96
+
97
+ p.getX = function() {
98
+ return (!this._wdw) ? this._target.scrollLeft : (_window.pageXOffset != null) ? _window.pageXOffset : (_doc.scrollLeft != null) ? _doc.scrollLeft : document.body.scrollLeft;
99
+ };
100
+
101
+ p.getY = function() {
102
+ return (!this._wdw) ? this._target.scrollTop : (_window.pageYOffset != null) ? _window.pageYOffset : (_doc.scrollTop != null) ? _doc.scrollTop : document.body.scrollTop;
103
+ };
104
+
105
+ p._kill = function(lookup) {
106
+ if (lookup.scrollTo_x) {
107
+ this.skipX = true;
108
+ }
109
+ if (lookup.scrollTo_y) {
110
+ this.skipY = true;
111
+ }
112
+ return this._super._kill.call(this, lookup);
113
+ };
114
+
115
+ }); if (window._gsDefine) { window._gsQueue.pop()(); }
@@ -0,0 +1,74 @@
1
+ /*!
2
+ * VERSION: 1.1.0
3
+ * DATE: 2013-02-28
4
+ * UPDATES AND DOCS AT: http://www.greensock.com
5
+ *
6
+ * This file is to be used as a simple template for writing your own plugin. See the
7
+ * notes at http://api.greensock.com/js/com/greensock/plugins/TweenPlugin.html for more details.
8
+ *
9
+ * You can start by doing a search for "yourCustomProperty" and replace it with whatever the name
10
+ * of your property is. This way of defining a plugin was introduced in version 1.9.0 - previous versions
11
+ * of TweenLite won't work with this.
12
+ *
13
+ * @license Copyright (c) 2008-2014, GreenSock. All rights reserved.
14
+ * This work is subject to the terms at http://www.greensock.com/terms_of_use.html or for
15
+ * Club GreenSock members, the software agreement that was issued with your membership.
16
+ *
17
+ * @author: Jack Doyle, jack@greensock.com
18
+ **/
19
+ (window._gsQueue || (window._gsQueue = [])).push( function() {
20
+ //ignore the line above this and at the very end - those are for ensuring things load in the proper order
21
+ "use strict";
22
+
23
+ window._gsDefine.plugin({
24
+ propName: "yourCustomProperty", //the name of the property that will get intercepted and handled by this plugin (obviously change it to whatever you want, typically it is camelCase starting with lowercase).
25
+ priority: 0, //the priority in the rendering pipeline (0 by default). A priority of -1 would mean this plugin will run after all those with 0 or greater. A priority of 1 would get run before 0, etc. This only matters when a plugin relies on other plugins finishing their work before it runs (or visa-versa)
26
+ API: 2, //the API should stay 2 - it just gives us a way to know the method/property structure so that if in the future we change to a different TweenPlugin architecture, we can identify this plugin's structure.
27
+ version: "1.0.0", //your plugin's version number
28
+ overwriteProps: ["yourCustomProperty"], //an array of property names whose tweens should be overwritten by this plugin. For example, if you create a "scale" plugin that handles both "scaleX" and "scaleY", the overwriteProps would be ["scaleX","scaleY"] so that if there's a scaleX or scaleY tween in-progress when a new "scale" tween starts (using this plugin), it would overwrite the scaleX or scaleY tween.
29
+
30
+ /*
31
+ * The init function is called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run. It receives 3 parameters:
32
+ * 1) target [object] - the target of the tween. In cases where the tween's original target is an array (or jQuery object), this target will be the individual object inside that array (a new plugin instance is created for each target in the array). For example, TweenLite.to([obj1, obj2, obj3], 1, {x:100}) the target will be obj1 or obj2 or obj3 rather than the array containing them.
33
+ * 2) value [*] - whatever value is passed as the special property value. For example, TweenLite.to(element, 1, {yourCustomProperty:3}) the value would be 3. Or for TweenLite.to(element, 1, {yourCustomProperty:{subProp1:3, subProp2:"whatever"}});, value would be {subProp1:3, subProp2:"whatever"}.
34
+ * 3) tween [TweenLite] - the TweenLite (or TweenMax) instance that is managing this plugin instance. This can be useful if you need to check certain state-related properties on the tween (maybe in the set method) like its duration or time. Most of the time, however, you don't need to do anything with the tween. It is provided just in case you want to reference it.
35
+ *
36
+ * This function should return true unless you want to have TweenLite/Max skip the plugin altogether and instead treat the property/value like a normal tween (as if the plugin wasn't activated). This is rarely useful, so you should almost always return true.
37
+ */
38
+ init: function(target, value, tween) {
39
+ this._target = target; //we record the target so that we can refer to it in the set method when doing updates.
40
+
41
+ /* Next, we create a property tween for "scaleX" and "scaleY" properties of our target
42
+ * (we're just using them as a examples of how to set up a property tween with a name, start, and end value).
43
+ * the _addTween() method accepts the following parameters:
44
+ * 1) target [object] - target object whose property this tween will control.
45
+ * 2) property [string] - the name of the property, like "scaleX" or "scaleY"
46
+ * 3) start [number] - The starting value of the property. For example, if you're tweening from 0 to 100, start would be 0.
47
+ * 4) end [number] - the ending value of the property. For example, if you're tweening from 0 to 100, end would be 100.
48
+ * 5) overwriteProperty [string] - the name that gets registered as the overwrite property so that if another concurrent tween of the same target gets created and it is tweening a property with this name, this one will be overwritten. Typically this is the same as "property".
49
+ * 6) round [boolean] - if true, the updated value on each update will be rounded to the nearest integer. [false by default]
50
+ * You do NOT need to use _addTween() at all. It is merely a convenience. You can record your own values internally or whatever you want.
51
+ */
52
+ this._addTween(target, "scaleX", target.scaleX, value, "scaleX", false);
53
+ this._addTween(target, "scaleY", target.scaleY, value, "scaleY", false);
54
+
55
+ //now, just for kicks, we'll record the starting "alpha" value and amount of change so that we can manage this manually rather than _addTween() (again, totally fictitious, just for an example)
56
+ this._alphaStart = target.alpha;
57
+ this._alphaChange = value.alpha - target.alpha;
58
+
59
+ //always return true unless we want to scrap the plugin and have the value treated as a normal property tween (very uncommon)
60
+ return true;
61
+ },
62
+
63
+ //[optional] - called each time the values should be updated, and the ratio gets passed as the only parameter (typically it's a value between 0 and 1, but it can exceed those when using an ease like Elastic.easeOut or Back.easeOut, etc.). If you're using this._super._addTween() for all your tweens and you don't need to do anything special on each frame besides updating those values, you can omit this "set" function altogether.
64
+ set: function(ratio) {
65
+ //since we used _addTween() inside init function, it created some property tweens that we'll update by calling the parent prototype's setRatio() (otherwise, the property tweens wouldn't get their values updated). this._super refers to the TweenPlugin prototype from which the plugin inherits (not that you need to worry about that).
66
+ this._super.setRatio.call(this, ratio);
67
+
68
+ //now manually set the alpha
69
+ this._target.alpha = this._alphaStart + this._alphaChange * ratio;
70
+ }
71
+
72
+ });
73
+
74
+ }); if (window._gsDefine) { window._gsQueue.pop()(); }
@@ -0,0 +1,108 @@
1
+ /*!
2
+ * VERSION: 0.5.0
3
+ * DATE: 2013-07-10
4
+ * UPDATES AND DOCS AT: http://www.greensock.com
5
+ *
6
+ * @license Copyright (c) 2008-2014, GreenSock. All rights reserved.
7
+ * This work is subject to the terms at http://www.greensock.com/terms_of_use.html or for
8
+ * Club GreenSock members, the software agreement that was issued with your membership.
9
+ *
10
+ * @author: Jack Doyle, jack@greensock.com
11
+ */
12
+ (window._gsQueue || (window._gsQueue = [])).push( function() {
13
+
14
+ "use strict";
15
+
16
+ var _getText = function(e) {
17
+ var type = e.nodeType,
18
+ result = "";
19
+ if (type === 1 || type === 9 || type === 11) {
20
+ if (typeof(e.textContent) === "string") {
21
+ return e.textContent;
22
+ } else {
23
+ for ( e = e.firstChild; e; e = e.nextSibling ) {
24
+ result += _getText(e);
25
+ }
26
+ }
27
+ } else if (type === 3 || type === 4) {
28
+ return e.nodeValue;
29
+ }
30
+ return result;
31
+ },
32
+ TextPlugin = window._gsDefine.plugin({
33
+ propName: "text",
34
+ API: 2,
35
+ version:"0.5.0",
36
+
37
+ //called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run.
38
+ init: function(target, value, tween) {
39
+ var i, shrt;
40
+ if (!("innerHTML" in target)) {
41
+ return false;
42
+ }
43
+ this._target = target;
44
+ if (typeof(value) !== "object") {
45
+ value = {value:value};
46
+ }
47
+ if (value.value === undefined) {
48
+ this._text = this._original = [""];
49
+ return true;
50
+ }
51
+ this._delimiter = value.delimiter || "";
52
+ this._original = _getText(target).replace(/\s+/g, " ").split(this._delimiter);
53
+ this._text = value.value.replace(/\s+/g, " ").split(this._delimiter);
54
+ this._runBackwards = (tween.vars.runBackwards === true);
55
+ if (this._runBackwards) {
56
+ i = this._original;
57
+ this._original = this._text;
58
+ this._text = i;
59
+ }
60
+ if (typeof(value.newClass) === "string") {
61
+ this._newClass = value.newClass;
62
+ this._hasClass = true;
63
+ }
64
+ if (typeof(value.oldClass) === "string") {
65
+ this._oldClass = value.oldClass;
66
+ this._hasClass = true;
67
+ }
68
+ i = this._original.length - this._text.length,
69
+ shrt = (i < 0) ? this._original : this._text;
70
+ this._fillChar = value.fillChar || (value.padSpace ? "&nbsp;" : "");
71
+ if (i < 0) {
72
+ i = -i;
73
+ }
74
+ while (--i > -1) {
75
+ shrt.push(this._fillChar);
76
+ }
77
+ return true;
78
+ },
79
+
80
+ //called each time the values should be updated, and the ratio gets passed as the only parameter (typically it's a value between 0 and 1, but it can exceed those when using an ease like Elastic.easeOut or Back.easeOut, etc.)
81
+ set: function(ratio) {
82
+ if (ratio > 1) {
83
+ ratio = 1;
84
+ } else if (ratio < 0) {
85
+ ratio = 0;
86
+ }
87
+ if (this._runBackwards) {
88
+ ratio = 1 - ratio;
89
+ }
90
+ var l = this._text.length,
91
+ i = (ratio * l + 0.5) | 0,
92
+ applyNew, applyOld, str;
93
+ if (this._hasClass) {
94
+ applyNew = (this._newClass && i !== 0);
95
+ applyOld = (this._oldClass && i !== l);
96
+ str = (applyNew ? "<span class='" + this._newClass + "'>" : "") + this._text.slice(0, i).join(this._delimiter) + (applyNew ? "</span>" : "") + (applyOld ? "<span class='" + this._oldClass + "'>" : "") + this._delimiter + this._original.slice(i).join(this._delimiter) + (applyOld ? "</span>" : "");
97
+ } else {
98
+ str = this._text.slice(0, i).join(this._delimiter) + this._delimiter + this._original.slice(i).join(this._delimiter);
99
+ }
100
+ this._target.innerHTML = (this._fillChar === "&nbsp;" && str.indexOf(" ") !== -1) ? str.split(" ").join("&nbsp;&nbsp;") : str;
101
+ }
102
+
103
+ }),
104
+ p = TextPlugin.prototype;
105
+
106
+ p._newClass = p._oldClass = p._delimiter = "";
107
+
108
+ }); if (window._gsDefine) { window._gsQueue.pop()(); }
@@ -0,0 +1,1438 @@
1
+ /*!
2
+ * VERSION: 0.9.9
3
+ * DATE: 2014-01-18
4
+ * UPDATES AND DOCS AT: http://www.greensock.com
5
+ *
6
+ * Requires TweenLite and CSSPlugin version 1.11.0 or later (TweenMax contains both TweenLite and CSSPlugin). ThrowPropsPlugin is required for momentum-based continuation of movement after the mouse/touch is released (ThrowPropsPlugin is a membership benefit of Club GreenSock - http://www.greensock.com/club/).
7
+ *
8
+ * @license Copyright (c) 2008-2014, GreenSock. All rights reserved.
9
+ * This work is subject to the terms at http://www.greensock.com/terms_of_use.html or for
10
+ * Club GreenSock members, the software agreement that was issued with your membership.
11
+ *
12
+ * @author: Jack Doyle, jack@greensock.com
13
+ */
14
+ (window._gsQueue || (window._gsQueue = [])).push( function() {
15
+
16
+ "use strict";
17
+
18
+ window._gsDefine("utils.Draggable", ["events.EventDispatcher","TweenLite"], function(EventDispatcher, TweenLite) {
19
+
20
+ var _tempVarsXY = {css:{}}, //speed optimization - we reuse the same vars object for x/y TweenLite.set() calls to minimize garbage collection tasks and improve performance.
21
+ _tempVarsX = {css:{}},
22
+ _tempVarsY = {css:{}},
23
+ _tempVarsRotation = {css:{}},
24
+ _tempEvent = {}, //for populating with pageX/pageY in old versions of IE
25
+ _doc = document,
26
+ _docElement = _doc.documentElement || {},
27
+ _emptyArray = [],
28
+ _emptyFunc = function() { return false; },
29
+ _RAD2DEG = 180 / Math.PI,
30
+ _max = 999999999999999,
31
+ _isOldIE = (_doc.all && !_doc.addEventListener),
32
+ _renderQueue = [],
33
+ _lookup = {}, //when a Draggable is created, the target gets a unique _gsDragID property that allows gets associated with the Draggable instance for quick lookups in Draggable.get(). This avoids circular references that could cause gc problems.
34
+ _lookupCount = 0,
35
+ _clickableTagExp = /^(?:a|input|textarea|button|select)$/i,
36
+ _dragCount = 0, //total number of elements currently being dragged
37
+ _prefix,
38
+ _isMultiTouching,
39
+ ThrowPropsPlugin,
40
+
41
+ _renderQueueTick = function() {
42
+ var i = _renderQueue.length;
43
+ while (--i > -1) {
44
+ _renderQueue[i]();
45
+ }
46
+ },
47
+ _addToRenderQueue = function(func) {
48
+ _renderQueue.push(func);
49
+ if (_renderQueue.length === 1) {
50
+ TweenLite.ticker.addEventListener("tick", _renderQueueTick);
51
+ }
52
+ },
53
+ _removeFromRenderQueue = function(func) {
54
+ var i = _renderQueue.length;
55
+ while (--i > -1) {
56
+ if (_renderQueue[i] === func) {
57
+ _renderQueue.splice(i, 1);
58
+ }
59
+ }
60
+ TweenLite.to(_renderQueueTimeout, 0, {overwrite:"all", delay:15, onComplete:_renderQueueTimeout}); //remove the "tick" listener only after the render queue is empty for 15 seconds (to improve performance). Adding/removing it constantly for every click/touch wouldn't deliver optimal speed, and we also don't want the ticker to keep calling the render method when things are idle for long periods of time (we want to improve battery life on mobile devices).
61
+ },
62
+ _renderQueueTimeout = function() {
63
+ if (!_renderQueue.length) {
64
+ TweenLite.ticker.removeEventListener("tick", _renderQueueTick);
65
+ }
66
+ },
67
+
68
+ _extend = function(obj, defaults) {
69
+ var p;
70
+ for (p in defaults) {
71
+ if (obj[p] === undefined) {
72
+ obj[p] = defaults[p];
73
+ }
74
+ }
75
+ return obj;
76
+ },
77
+
78
+ //just used for IE8 and earlier to normalize events and populate pageX/pageY
79
+ _populateIEEvent = function(e, preventDefault) {
80
+ e = e || window.event;
81
+ _tempEvent.pageX = e.clientX + _doc.body.scrollLeft + _docElement.scrollLeft;
82
+ _tempEvent.pageY = e.clientY + _doc.body.scrollTop + _docElement.scrollTop;
83
+ if (preventDefault) {
84
+ e.returnValue = false;
85
+ }
86
+ return _tempEvent;
87
+ },
88
+
89
+ //grabs the first element it finds (and we include the window as an element), so if it's selector text, it'll feed that value to TweenLite.selector, if it's a jQuery object or some other selector engine's result, it'll grab the first one, and same for an array. If the value doesn't contain a DOM element, it'll just return null.
90
+ _unwrapElement = function(value) {
91
+ if (!value) {
92
+ return value;
93
+ }
94
+ if (typeof(value) === "string") {
95
+ value = TweenLite.selector(value);
96
+ }
97
+ if (value.length && value !== window && value[0] && value[0].style && !value.nodeType) {
98
+ value = value[0];
99
+ }
100
+ return (value === window || (value.nodeType && value.style)) ? value : null;
101
+ },
102
+
103
+ _checkPrefix = function(e, p) {
104
+ var s = e.style,
105
+ capped, i, a;
106
+ if (s[p] === undefined) {
107
+ a = ["O","Moz","ms","Ms","Webkit"];
108
+ i = 5;
109
+ capped = p.charAt(0).toUpperCase() + p.substr(1);
110
+ while (--i > -1 && s[a[i]+capped] === undefined) { }
111
+ if (i < 0) {
112
+ return "";
113
+ }
114
+ _prefix = (i === 3) ? "ms" : a[i];
115
+ p = _prefix + capped;
116
+ }
117
+ return p;
118
+ },
119
+
120
+ _setStyle = function(e, p, value) {
121
+ var s = e.style;
122
+ if (s[p] === undefined) {
123
+ p = _checkPrefix(e, p);
124
+ }
125
+ if (value == null) {
126
+ if (s.removeProperty) {
127
+ s.removeProperty(p.replace(/([A-Z])/g, "-$1").toLowerCase());
128
+ } else { //note: old versions of IE use "removeAttribute()" instead of "removeProperty()"
129
+ s.removeAttribute(p);
130
+ }
131
+ } else if (s[p] !== undefined) {
132
+ s[p] = value;
133
+ }
134
+ },
135
+
136
+ _getComputedStyle = _doc.defaultView ? _doc.defaultView.getComputedStyle : _emptyFunc,
137
+ _horizExp = /(?:Left|Right|Width)/i,
138
+ _suffixExp = /(?:\d|\-|\+|=|#|\.)*/g,
139
+ _convertToPixels = function(t, p, v, sfx, recurse) {
140
+ if (sfx === "px" || !sfx) { return v; }
141
+ if (sfx === "auto" || !v) { return 0; }
142
+ var horiz = _horizExp.test(p),
143
+ node = t,
144
+ style = _tempDiv.style,
145
+ neg = (v < 0),
146
+ pix;
147
+ if (neg) {
148
+ v = -v;
149
+ }
150
+ if (sfx === "%" && p.indexOf("border") !== -1) {
151
+ pix = (v / 100) * (horiz ? t.clientWidth : t.clientHeight);
152
+ } else {
153
+ style.cssText = "border:0 solid red;position:" + _getStyle(t, "position", true) + ";line-height:0;";
154
+ if (sfx === "%" || !node.appendChild) {
155
+ node = t.parentNode || _doc.body;
156
+ style[(horiz ? "width" : "height")] = v + sfx;
157
+ } else {
158
+ style[(horiz ? "borderLeftWidth" : "borderTopWidth")] = v + sfx;
159
+ }
160
+ node.appendChild(_tempDiv);
161
+ pix = parseFloat(_tempDiv[(horiz ? "offsetWidth" : "offsetHeight")]);
162
+ node.removeChild(_tempDiv);
163
+ if (pix === 0 && !recurse) {
164
+ pix = _convertToPixels(t, p, v, sfx, true);
165
+ }
166
+ }
167
+ return neg ? -pix : pix;
168
+ },
169
+ _calculateOffset = function(t, p) { //for figuring out "top" or "left" in px when it's "auto". We need to factor in margin with the offsetLeft/offsetTop
170
+ if (_getStyle(t, "position", true) !== "absolute") { return 0; }
171
+ var dim = ((p === "left") ? "Left" : "Top"),
172
+ v = _getStyle(t, "margin" + dim, true);
173
+ return t["offset" + dim] - (_convertToPixels(t, p, parseFloat(v), v.replace(_suffixExp, "")) || 0);
174
+ },
175
+
176
+ _getStyle = function(element, prop, keepUnits) {
177
+ var rv = (element._gsTransform || {})[prop],
178
+ cs;
179
+ if (rv || rv === 0) {
180
+ return rv;
181
+ } else if (element.style[prop]) {
182
+ rv = element.style[prop];
183
+ } else if ((cs = _getComputedStyle(element))) {
184
+ rv = cs.getPropertyValue(prop.replace(/([A-Z])/g, "-$1").toLowerCase());
185
+ rv = (rv || cs.length) ? rv : cs[prop]; //Opera behaves VERY strangely - length is usually 0 and cs[prop] is the only way to get accurate results EXCEPT when checking for -o-transform which only works with cs.getPropertyValue()!
186
+ } else if (element.currentStyle) {
187
+ rv = element.currentStyle[prop];
188
+ }
189
+ if (rv === "auto" && (prop === "top" || prop === "left")) {
190
+ rv = _calculateOffset(element, prop);
191
+ }
192
+ return keepUnits ? rv : parseFloat(rv) || 0;
193
+ },
194
+
195
+ _dispatchEvent = function(instance, type, callbackName) {
196
+ var vars = instance.vars,
197
+ callback = vars[callbackName],
198
+ listeners = instance._listeners[type];
199
+ if (typeof(callback) === "function") {
200
+ callback.apply(vars[callbackName + "Scope"] || instance, vars[callbackName + "Params"] || [instance.pointerEvent]);
201
+ }
202
+ if (listeners) {
203
+ instance.dispatchEvent(type);
204
+ }
205
+ },
206
+ _getBounds = function(obj, context) { //accepts any of the following: a DOM element, jQuery object, selector text, or an object defining bounds as {top, left, width, height} or {minX, maxX, minY, maxY}. Returns an object with left, top, width, and height properties.
207
+ var e = _unwrapElement(obj),
208
+ top, left, offset;
209
+ if (!e) {
210
+ if (obj.left !== undefined) {
211
+ offset = _getOffsetTransformOrigin(context); //the bounds should be relative to the origin
212
+ return {left: obj.left - offset.x, top: obj.top - offset.y, width: obj.width, height: obj.height};
213
+ }
214
+ left = obj.min || obj.minX || obj.minRotation || 0;
215
+ top = obj.min || obj.minY || 0;
216
+ return {left:left, top:top, width:(obj.max || obj.maxX || obj.maxRotation || 0) - left, height:(obj.max || obj.maxY || 0) - top};
217
+ }
218
+ return _getElementBounds(e, context);
219
+ },
220
+
221
+ _tempDiv = _doc.createElement("div"),
222
+ _supports3D = (_checkPrefix(_tempDiv, "perspective") !== ""),
223
+
224
+
225
+ // start matrix and point conversion methods...
226
+ _originProp = _checkPrefix(_tempDiv, "transformOrigin").replace(/^ms/g, "Ms").replace(/([A-Z])/g, "-$1").toLowerCase(),
227
+ _transformProp = _checkPrefix(_tempDiv, "transform"),
228
+ _transformCSSProp = _transformProp.replace(/^ms/g, "Ms").replace(/([A-Z])/g, "-$1").toLowerCase(),
229
+ _point1 = {}, //we reuse _point1 and _point2 objects inside matrix and point conversion methods to conserve memory and minimize garbage collection tasks.
230
+ _point2 = {},
231
+ _hasReparentBug, //we'll set this inside the _getOffset2DMatrix() method after the body has loaded.
232
+ _getOffsetTransformOrigin = function(e, decoratee) {
233
+ decoratee = decoratee || {};
234
+ if (!e || e === document.body || !e.parentNode) {
235
+ return {x:0, y:0};
236
+ }
237
+ var cs = _getComputedStyle(e),
238
+ v = (_originProp && cs) ? cs.getPropertyValue(_originProp) : "50% 50%",
239
+ a = v.split(" "),
240
+ x = (v.indexOf("left") !== -1) ? "0%" : (v.indexOf("right") !== -1) ? "100%" : a[0],
241
+ y = (v.indexOf("top") !== -1) ? "0%" : (v.indexOf("bottom") !== -1) ? "100%" : a[1];
242
+ if (y === "center" || y == null) {
243
+ y = "50%";
244
+ }
245
+ if (x === "center" || isNaN(parseFloat(x))) { //remember, the user could flip-flop the values and say "bottom center" or "center bottom", etc. "center" is ambiguous because it could be used to describe horizontal or vertical, hence the isNaN(). If there's an "=" sign in the value, it's relative.
246
+ x = "50%";
247
+ }
248
+ decoratee.x = ((x.indexOf("%") !== -1) ? e.offsetWidth * parseFloat(x) / 100 : parseFloat(x));
249
+ decoratee.y = ((y.indexOf("%") !== -1) ? e.offsetHeight * parseFloat(y) / 100 : parseFloat(y));
250
+ return decoratee;
251
+ },
252
+ _getOffset2DMatrix = function(e, offsetOrigin, parentOffsetOrigin) {
253
+ var cs, m;
254
+ if (e === window || !e || !e.parentNode) {
255
+ return [1,0,0,1,0,0];
256
+ }
257
+ cs = _getComputedStyle(e);
258
+ m = cs ? cs.getPropertyValue(_transformCSSProp) : e.currentStyle ? e.currentStyle[_transformProp] : "1,0,0,1,0,0";
259
+ m = (m + "").match(/(?:\-|\b)[\d\-\.e]+\b/g) || [1,0,0,1,0,0];
260
+ if (m.length > 6) {
261
+ m = [m[0], m[1], m[4], m[5], m[12], m[13]];
262
+ }
263
+ if (offsetOrigin) {
264
+ m[4] = Number(m[4]) + offsetOrigin.x + e.offsetLeft - parentOffsetOrigin.x;
265
+ m[5] = Number(m[5]) + offsetOrigin.y + e.offsetTop - parentOffsetOrigin.y;
266
+ //some browsers (like Chrome 31) have a bug that causes the offsetParent not to report correctly when a transform is applied to an element's parent, so the offsetTop and offsetLeft are measured from the parent instead of whatever the offsetParent reports as. For example, put an absolutely-positioned child div inside a position:static parent, then check the child's offsetTop before and after you apply a transform, like rotate(1deg). You'll see that it changes, but the offsetParent doesn't. So we must sense this condition here (and we can only do it after the body has loaded, as browsers don't accurately report offsets otherwise) and set a variable that we can easily reference later.
267
+ if (_hasReparentBug === undefined && _doc.body && _transformProp) {
268
+ _hasReparentBug = (function() {
269
+ var parent = _doc.createElement("div"),
270
+ child = _doc.createElement("div"),
271
+ oldOffsetParent, value;
272
+ child.style.position = "absolute";
273
+ _doc.body.appendChild(parent);
274
+ parent.appendChild(child);
275
+ oldOffsetParent = child.offsetParent;
276
+ parent.style[_transformProp] = "rotate(1deg)";
277
+ value = (child.offsetParent === oldOffsetParent);
278
+ _doc.body.removeChild(parent);
279
+ return value;
280
+ }());
281
+ }
282
+ if (e.parentNode && e.parentNode.offsetParent === e.offsetParent && (!_hasReparentBug || _getOffset2DMatrix(e.parentNode).join("") === "100100")) {
283
+ m[4] -= e.parentNode.offsetLeft;
284
+ m[5] -= e.parentNode.offsetTop;
285
+ }
286
+ }
287
+ return m;
288
+ },
289
+ _getConcatenatedMatrix = function(e, invert) {
290
+ //note: we keep reusing _point1 and _point2 in order to minimize memory usage and garbage collection chores.
291
+ var originOffset = _getOffsetTransformOrigin(e, _point1),
292
+ parentOriginOffset = _getOffsetTransformOrigin(e.parentNode, _point2),
293
+ m = _getOffset2DMatrix(e, originOffset, parentOriginOffset),
294
+ a, b, c, d, tx, ty, m2, determinant;
295
+ while ((e = e.parentNode) && e.parentNode && e !== document.body) {
296
+ originOffset = parentOriginOffset;
297
+ parentOriginOffset = _getOffsetTransformOrigin(e.parentNode, (originOffset === _point1) ? _point2 : _point1);
298
+ m2 = _getOffset2DMatrix(e, originOffset, parentOriginOffset);
299
+ a = m[0];
300
+ b = m[1];
301
+ c = m[2];
302
+ d = m[3];
303
+ tx = m[4];
304
+ ty = m[5];
305
+ m[0] = a * m2[0] + b * m2[2];
306
+ m[1] = a * m2[1] + b * m2[3];
307
+ m[2] = c * m2[0] + d * m2[2];
308
+ m[3] = c * m2[1] + d * m2[3];
309
+ m[4] = tx * m2[0] + ty * m2[2] + m2[4];
310
+ m[5] = tx * m2[1] + ty * m2[3] + m2[5];
311
+ }
312
+ if (invert) {
313
+ a = m[0];
314
+ b = m[1];
315
+ c = m[2];
316
+ d = m[3];
317
+ tx = m[4];
318
+ ty = m[5];
319
+ determinant = (a * d - b * c);
320
+ m[0] = d / determinant;
321
+ m[1] = -b / determinant;
322
+ m[2] = -c / determinant;
323
+ m[3] = a / determinant;
324
+ m[4] = (c * ty - d * tx) / determinant;
325
+ m[5] = -(a * ty - b * tx) / determinant;
326
+ }
327
+ return m;
328
+ },
329
+ _localToGlobal = function(e, p, decoratee) {
330
+ var m = _getConcatenatedMatrix(e),
331
+ x = p.x,
332
+ y = p.y;
333
+ decoratee = (decoratee === true) ? p : decoratee || {};
334
+ decoratee.x = x * m[0] + y * m[2] + m[4];
335
+ decoratee.y = x * m[1] + y * m[3] + m[5];
336
+ return decoratee;
337
+ },
338
+ _localizePoint = function(p, localToGlobal, globalToLocal) {
339
+ var x = p.x * localToGlobal[0] + p.y * localToGlobal[2] + localToGlobal[4],
340
+ y = p.x * localToGlobal[1] + p.y * localToGlobal[3] + localToGlobal[5];
341
+ p.x = x * globalToLocal[0] + y * globalToLocal[2] + globalToLocal[4];
342
+ p.y = x * globalToLocal[1] + y * globalToLocal[3] + globalToLocal[5];
343
+ return p;
344
+ },
345
+ _getElementBounds = function(e, context) {
346
+ var origin, left, right, top, bottom, mLocalToGlobal, mGlobalToLocal, p1, p2, p3, p4;
347
+ if (e === window) {
348
+ top = (e.pageYOffset != null) ? e.pageYOffset : (_doc.scrollTop != null) ? _doc.scrollTop : _docElement.scrollTop || _doc.body.scrollTop || 0;
349
+ left = (e.pageXOffset != null) ? e.pageXOffset : (_doc.scrollLeft != null) ? _doc.scrollLeft : _docElement.scrollLeft || _doc.body.scrollLeft || 0;
350
+ right = left + (_docElement.clientWidth || e.innerWidth || _doc.body.clientWidth || 0);
351
+ bottom = top + ((e.innerHeight - 20 < _docElement.clientHeight) ? _docElement.clientHeight : e.innerHeight || _doc.body.clientHeight || 0); //some browsers (like Firefox) ignore absolutely positioned elements, and collapse the height of the documentElement, so it could be 8px, for example, if you have just an absolutely positioned div. In that case, we use the innerHeight to resolve this.
352
+ } else {
353
+ origin = _getOffsetTransformOrigin(e);
354
+ left = -origin.x;
355
+ right = left + e.offsetWidth;
356
+ top = -origin.y;
357
+ bottom = top + e.offsetHeight;
358
+ }
359
+ if (e === context) {
360
+ return {left:left, top:top, width: right - left, height: bottom - top};
361
+ }
362
+ mLocalToGlobal = _getConcatenatedMatrix(e);
363
+ mGlobalToLocal = _getConcatenatedMatrix(context, true);
364
+ p1 = _localizePoint({x:left, y:top}, mLocalToGlobal, mGlobalToLocal);
365
+ p2 = _localizePoint({x:right, y:top}, mLocalToGlobal, mGlobalToLocal);
366
+ p3 = _localizePoint({x:right, y:bottom}, mLocalToGlobal, mGlobalToLocal);
367
+ p4 = _localizePoint({x:left, y:bottom}, mLocalToGlobal, mGlobalToLocal);
368
+ left = Math.min(p1.x, p2.x, p3.x, p4.x);
369
+ top = Math.min(p1.y, p2.y, p3.y, p4.y);
370
+ return {left:left, top:top, width:Math.max(p1.x, p2.x, p3.x, p4.x) - left, height:Math.max(p1.y, p2.y, p3.y, p4.y) - top};
371
+ },
372
+ // end matrix and point conversion methods
373
+
374
+
375
+
376
+ _isArrayLike = function(e) {
377
+ return (e.length && e[0] && ((e[0].nodeType && e[0].style && !e.nodeType) || (e[0].length && e[0][0]))) ? true : false; //could be an array of jQuery objects too, so accommodate that.
378
+ },
379
+
380
+ _flattenArray = function(a) {
381
+ var result = [],
382
+ l = a.length,
383
+ i, e, j;
384
+ for (i = 0; i < l; i++) {
385
+ e = a[i];
386
+ if (_isArrayLike(e)) {
387
+ j = e.length;
388
+ for (j = 0; j < e.length; j++) {
389
+ result.push(e[j]);
390
+ }
391
+ } else {
392
+ result.push(e);
393
+ }
394
+ }
395
+ return result;
396
+ },
397
+
398
+ _isTouchDevice = (("ontouchstart" in _docElement) && ("orientation" in window)),
399
+ _touchEventLookup = (function(types) { //we create an object that makes it easy to translate touch event types into their "pointer" counterparts if we're in a browser that uses those instead. Like IE10 uses "MSPointerDown" instead of "touchstart", for example.
400
+ var standard = types.split(","),
401
+ converted = ((_tempDiv.onpointerdown !== undefined) ? "pointerdown,pointermove,pointerup,pointercancel" : (_tempDiv.onmspointerdown !== undefined) ? "MSPointerDown,MSPointerMove,MSPointerUp,MSPointerCancel" : types).split(","),
402
+ obj = {},
403
+ i = 7;
404
+ while (--i > -1) {
405
+ obj[standard[i]] = converted[i];
406
+ obj[converted[i]] = standard[i];
407
+ }
408
+ return obj;
409
+ }("touchstart,touchmove,touchend,touchcancel")),
410
+
411
+ _addListener = function(element, type, func) {
412
+ if (element.addEventListener) {
413
+ element.addEventListener(_touchEventLookup[type] || type, func, false);
414
+ } else if (element.attachEvent) {
415
+ element.attachEvent("on" + type, func);
416
+ }
417
+ },
418
+
419
+ _removeListener = function(element, type, func) {
420
+ if (element.removeEventListener) {
421
+ element.removeEventListener(_touchEventLookup[type] || type, func);
422
+ } else if (element.detachEvent) {
423
+ element.detachEvent("on" + type, func);
424
+ }
425
+ },
426
+
427
+ _onMultiTouchDocumentEnd = function(e) {
428
+ _isMultiTouching = (e.touches && _dragCount < e.touches.length);
429
+ _removeListener(e.target, "touchend", _onMultiTouchDocumentEnd);
430
+ },
431
+
432
+ _onMultiTouchDocument = function(e) {
433
+ _isMultiTouching = (e.touches && _dragCount < e.touches.length);
434
+ _addListener(e.target, "touchend", _onMultiTouchDocumentEnd);
435
+ },
436
+
437
+ _parseThrowProps = function(draggable, snap, max, min, factor, forceZeroVelocity) {
438
+ var vars = {},
439
+ a, i, l;
440
+ if (snap) {
441
+ if (factor !== 1 && snap instanceof Array) { //some data must be altered to make sense, like if the user passes in an array of rotational values in degrees, we must convert it to radians. Or for scrollLeft and scrollTop, we invert the values.
442
+ vars.end = a = [];
443
+ l = snap.length;
444
+ for (i = 0; i < l; i++) {
445
+ a[i] = snap[i] * factor;
446
+ }
447
+ } else if (typeof(snap) === "function") {
448
+ vars.end = function(value) {
449
+ return snap.call(draggable, value) * factor; //we need to ensure that we can scope the function call to the Draggable instance itself so that users can access important values like maxX, minX, maxY, minY, x, and y from within that function.
450
+ };
451
+ } else {
452
+ vars.end = snap;
453
+ }
454
+ }
455
+ if (max || max === 0) {
456
+ vars.max = max;
457
+ }
458
+ if (min || min === 0) {
459
+ vars.min = min;
460
+ }
461
+ if (forceZeroVelocity) {
462
+ vars.velocity = 0;
463
+ }
464
+ return vars;
465
+ },
466
+
467
+ _isClickable = function(e) { //sometimes it's convenient to mark an element as clickable by adding a data-clickable="true" attribute (in which case we won't preventDefault() the mouse/touch event). This method checks if the element is an <a>, <input>, or <button> or has an onclick or has the data-clickable attribute set to true (or any of its parent elements).
468
+ var data;
469
+ return (!e || !e.getAttribute || e.nodeName === "BODY") ? false : ((data = e.getAttribute("data-clickable")) === "true" || (data !== "false" && (e.onclick || _clickableTagExp.test(e.nodeName + "")))) ? true : _isClickable(e.parentNode);
470
+ },
471
+
472
+ _addPaddingBR,
473
+ _addPaddingLeft = (function() { //this function is in charge of analyzing browser behavior related to padding. It sets the _addPaddingBR to true if the browser doesn't normally factor in the bottom or right padding on the element inside the scrolling area, and it sets _addPaddingLeft to true if it's a browser that requires the extra offset (offsetLeft) to be added to the paddingRight (like Opera).
474
+ var div = _doc.createElement("div"),
475
+ child = _doc.createElement("div"),
476
+ childStyle = child.style,
477
+ parent = _doc.body || _tempDiv,
478
+ val;
479
+ childStyle.display = "inline-block";
480
+ childStyle.position = "relative";
481
+ div.style.cssText = child.innerHTML = "width:90px; height:40px; padding:10px; overflow:auto; visibility: hidden";
482
+ div.appendChild(child);
483
+ parent.appendChild(div);
484
+ _addPaddingBR = (child.offsetHeight + 18 > div.scrollHeight); //div.scrollHeight should be child.offsetHeight + 20 because of the 10px of padding on each side, but some browsers ignore one side. We allow a 2px margin of error.
485
+ childStyle.width = "100%";
486
+ if (!_transformProp) {
487
+ childStyle.paddingRight = "500px";
488
+ val = div.scrollLeft = div.scrollWidth - div.clientWidth;
489
+ childStyle.left = "-90px";
490
+ val = (val !== div.scrollLeft);
491
+ }
492
+ parent.removeChild(div);
493
+ return val;
494
+ }()),
495
+
496
+
497
+
498
+
499
+ //The ScrollProxy class wraps an element's contents into another div (we call it "content") that we either add padding when necessary or apply a translate3d() transform in order to overscroll (scroll past the boundaries). This allows us to simply set the scrollTop/scrollLeft (or top/left for easier reverse-axis orientation, which is what we do in Draggable) and it'll do all the work for us. For example, if we tried setting scrollTop to -100 on a normal DOM element, it wouldn't work - it'd look the same as setting it to 0, but if we set scrollTop of a ScrollProxy to -100, it'll give the correct appearance by either setting paddingTop of the wrapper to 100 or applying a 100-pixel translateY.
500
+ ScrollProxy = function(element, vars) {
501
+ element = _unwrapElement(element);
502
+ vars = vars || {};
503
+ var content = _doc.createElement("div"),
504
+ style = content.style,
505
+ node = element.firstChild,
506
+ offsetTop = 0,
507
+ offsetLeft = 0,
508
+ prevTop = element.scrollTop,
509
+ prevLeft = element.scrollLeft,
510
+ extraPadRight = 0,
511
+ maxLeft = 0,
512
+ maxTop = 0,
513
+ elementWidth, elementHeight, contentHeight, nextNode, transformStart, transformEnd;
514
+
515
+ if (_supports3D && vars.force3D !== false) {
516
+ transformStart = "translate3d(";
517
+ transformEnd = "px,0px)";
518
+ } else if (_transformProp) {
519
+ transformStart = "translate(";
520
+ transformEnd = "px)";
521
+ }
522
+
523
+ this.scrollTop = function(value, force) {
524
+ if (!arguments.length) {
525
+ return -this.top();
526
+ }
527
+ this.top(-value, force);
528
+ };
529
+
530
+ this.scrollLeft = function(value, force) {
531
+ if (!arguments.length) {
532
+ return -this.left();
533
+ }
534
+ this.left(-value, force);
535
+ };
536
+
537
+ this.left = function(value, force) {
538
+ if (!arguments.length) {
539
+ return -(element.scrollLeft + offsetLeft);
540
+ }
541
+ var dif = element.scrollLeft - prevLeft,
542
+ oldOffset = offsetLeft;
543
+ if ((dif > 2 || dif < -2) && !force) { //if the user interacts with the scrollbar (or something else scrolls it, like the mouse wheel), we should kill any tweens of the ScrollProxy.
544
+ prevLeft = element.scrollLeft;
545
+ TweenLite.killTweensOf(this, true, {left:1, scrollLeft:1});
546
+ this.left(-prevLeft);
547
+ if (vars.onKill) {
548
+ vars.onKill();
549
+ }
550
+ return;
551
+ }
552
+ value = -value; //invert because scrolling works in the opposite direction
553
+ if (value < 0) {
554
+ offsetLeft = (value - 0.5) | 0;
555
+ value = 0;
556
+ } else if (value > maxLeft) {
557
+ offsetLeft = (value - maxLeft) | 0;
558
+ value = maxLeft;
559
+ } else {
560
+ offsetLeft = 0;
561
+ }
562
+ if (offsetLeft || oldOffset) {
563
+ if (transformStart) {
564
+ if (!this._suspendTransforms) {
565
+ style[_transformProp] = transformStart + -offsetLeft + "px," + -offsetTop + transformEnd;
566
+ }
567
+ } else {
568
+ style.left = -offsetLeft + "px";
569
+ }
570
+ if (_addPaddingLeft && offsetLeft + extraPadRight >= 0) {
571
+ style.paddingRight = offsetLeft + extraPadRight + "px";
572
+ }
573
+ }
574
+ element.scrollLeft = value | 0;
575
+ prevLeft = element.scrollLeft; //don't merge this with the line above because some browsers adjsut the scrollLeft after it's set, so in order to be 100% accurate in tracking it, we need to ask the browser to report it.
576
+ };
577
+
578
+ this.top = function(value, force) {
579
+ if (!arguments.length) {
580
+ return -(element.scrollTop + offsetTop);
581
+ }
582
+ var dif = element.scrollTop - prevTop,
583
+ oldOffset = offsetTop;
584
+ if ((dif > 2 || dif < -2) && !force) { //if the user interacts with the scrollbar (or something else scrolls it, like the mouse wheel), we should kill any tweens of the ScrollProxy.
585
+ prevTop = element.scrollTop;
586
+ TweenLite.killTweensOf(this, true, {top:1, scrollTop:1});
587
+ this.top(-prevTop);
588
+ if (vars.onKill) {
589
+ vars.onKill();
590
+ }
591
+ return;
592
+ }
593
+ value = -value; //invert because scrolling works in the opposite direction
594
+ if (value < 0) {
595
+ offsetTop = (value - 0.5) | 0;
596
+ value = 0;
597
+ } else if (value > maxTop) {
598
+ offsetTop = (value - maxTop) | 0;
599
+ value = maxTop;
600
+ } else {
601
+ offsetTop = 0;
602
+ }
603
+ if (offsetTop || oldOffset) {
604
+ if (transformStart) {
605
+ if (!this._suspendTransforms) {
606
+ style[_transformProp] = transformStart + -offsetLeft + "px," + -offsetTop + transformEnd;
607
+ }
608
+ } else {
609
+ style.top = -offsetTop + "px";
610
+ }
611
+ }
612
+ element.scrollTop = value | 0;
613
+ prevTop = element.scrollTop;
614
+ };
615
+
616
+ this.maxScrollTop = function() {
617
+ return maxTop;
618
+ };
619
+
620
+ this.maxScrollLeft = function() {
621
+ return maxLeft;
622
+ };
623
+
624
+ this.disable = function() {
625
+ node = content.firstChild;
626
+ while (node) {
627
+ nextNode = node.nextSibling;
628
+ element.appendChild(node);
629
+ node = nextNode;
630
+ }
631
+ if (element === content.parentNode) { //in case disable() is called when it's already disabled.
632
+ element.removeChild(content);
633
+ }
634
+ };
635
+
636
+ this.enable = function() {
637
+ node = element.firstChild;
638
+ if (node === content) {
639
+ return;
640
+ }
641
+ while (node) {
642
+ nextNode = node.nextSibling;
643
+ content.appendChild(node);
644
+ node = nextNode;
645
+ }
646
+ element.appendChild(content);
647
+ this.calibrate();
648
+ };
649
+
650
+ this.calibrate = function(force) {
651
+ var widthMatches = (element.clientWidth === elementWidth),
652
+ x, y;
653
+ prevTop = element.scrollTop;
654
+ prevLeft = element.scrollLeft;
655
+ if (widthMatches && element.clientHeight === elementHeight && content.offsetHeight === contentHeight && !force) {
656
+ return; //no need to recalculate things if the width and height haven't changed.
657
+ }
658
+ if (offsetTop || offsetLeft) {
659
+ x = this.left();
660
+ y = this.top();
661
+ this.left(-element.scrollLeft);
662
+ this.top(-element.scrollTop);
663
+ }
664
+ //first, we need to remove any width constraints to see how the content naturally flows so that we can see if it's wider than the containing element. If so, we've got to record the amount of overage so that we can apply that as padding in order for browsers to correctly handle things. Then we switch back to a width of 100% (without that, some browsers don't flow the content correctly)
665
+ if (!widthMatches || force) {
666
+ style.display = "block";
667
+ style.width = "auto";
668
+ style.paddingRight = "0px";
669
+ extraPadRight = Math.max(0, element.scrollWidth - element.clientWidth);
670
+ //if the content is wider than the container, we need to add the paddingLeft and paddingRight in order for things to behave correctly.
671
+ if (extraPadRight) {
672
+ extraPadRight += _getStyle(element, "paddingLeft") + (_addPaddingBR ? _getStyle(element, "paddingRight") : 0);
673
+ }
674
+ }
675
+ style.display = "inline-block";
676
+ style.position = "relative";
677
+ style.overflow = "visible";
678
+ style.width = "100%";
679
+ style.paddingRight = extraPadRight + "px";
680
+ //some browsers neglect to factor in the bottom padding when calculating the scrollHeight, so we need to add that padding to the content when that happens. Allow a 2px margin for error
681
+ if (_addPaddingBR) {
682
+ style.paddingBottom = _getStyle(element, "paddingBottom", true);
683
+ }
684
+ if (_isOldIE) {
685
+ style.zoom = "1";
686
+ }
687
+ elementWidth = element.clientWidth;
688
+ elementHeight = element.clientHeight;
689
+ maxLeft = element.scrollWidth - elementWidth;
690
+ maxTop = element.scrollHeight - elementHeight;
691
+ contentHeight = content.offsetHeight;
692
+ if (x || y) {
693
+ this.left(x);
694
+ this.top(y);
695
+ }
696
+ };
697
+
698
+ this.content = content;
699
+ this.element = element;
700
+ this._suspendTransforms = false;
701
+ this.enable();
702
+ },
703
+
704
+
705
+
706
+
707
+
708
+ Draggable = function(target, vars) {
709
+ EventDispatcher.call(this, target);
710
+ target = _unwrapElement(target); //in case the target is a selector object or selector text
711
+ if (!ThrowPropsPlugin) {
712
+ ThrowPropsPlugin = (window.GreenSockGlobals || window).com.greensock.plugins.ThrowPropsPlugin;
713
+ }
714
+ this.vars = vars = vars || {};
715
+ this.target = target;
716
+ this.x = this.y = this.rotation = 0;
717
+ this.dragResistance = parseFloat(vars.dragResistance) || 0;
718
+ this.edgeResistance = isNaN(vars.edgeResistance) ? 1 : parseFloat(vars.edgeResistance) || 0;
719
+ this.lockAxis = vars.lockAxis;
720
+ var type = (vars.type || (_isOldIE ? "top,left" : "x,y")).toLowerCase(),
721
+ xyMode = (type.indexOf("x") !== -1 || type.indexOf("y") !== -1),
722
+ rotationMode = (type.indexOf("rotation") !== -1),
723
+ xProp = xyMode ? "x" : "left",
724
+ yProp = xyMode ? "y" : "top",
725
+ allowX = (type.indexOf("x") !== -1 || type.indexOf("left") !== -1 || type === "scroll"),
726
+ allowY = (type.indexOf("y") !== -1 || type.indexOf("top") !== -1 || type === "scroll"),
727
+ self = this,
728
+ trigger = _unwrapElement(vars.trigger || vars.handle || target),
729
+ killProps = {},
730
+ scrollProxy, startMouseX, startMouseY, startElementX, startElementY, hasBounds, hasDragCallback, maxX, minX, maxY, minY, tempVars, cssVars, touch, touchID, rotationOrigin, dirty, old, snapX, snapY, isClicking, touchEventTarget, lockedAxis, matrix, interrupted,
731
+
732
+ //this method gets called on every tick of TweenLite.ticker which allows us to synchronize the renders to the core engine (which is typically synchronized with the display refresh via requestAnimationFrame). This is an optimization - it's better than applying the values inside the "mousemove" or "touchmove" event handler which may get called many times inbetween refreshes.
733
+ render = function(suppressEvents) {
734
+ if (dirty) {
735
+ var x = self.x,
736
+ y = self.y,
737
+ min = 0.000001;
738
+ if (x < min && x > -min) { //browsers don't handle super small decimals well.
739
+ x = 0;
740
+ }
741
+ if (y < min && y > -min) {
742
+ y = 0;
743
+ }
744
+ if (rotationMode) {
745
+ cssVars.rotation = self.rotation = self.x;
746
+ TweenLite.set(target, tempVars);
747
+ } else {
748
+ if (scrollProxy) {
749
+ if (allowY) {
750
+ scrollProxy.top(y);
751
+ }
752
+ if (allowX) {
753
+ scrollProxy.left(x);
754
+ }
755
+ } else if (xyMode) {
756
+ if (allowY) {
757
+ cssVars.y = y;
758
+ }
759
+ if (allowX) {
760
+ cssVars.x = x;
761
+ }
762
+ TweenLite.set(target, tempVars);
763
+ } else {
764
+ if (allowY) {
765
+ target.style.top = y + "px";
766
+ }
767
+ if (allowX) {
768
+ target.style.left = x + "px";
769
+ }
770
+ }
771
+ }
772
+ if (hasDragCallback && !suppressEvents) {
773
+ _dispatchEvent(self, "drag", "onDrag");
774
+ }
775
+ }
776
+ dirty = false;
777
+ },
778
+
779
+ //copies the x/y from the element (whether that be transforms, top/left, or ScrollProxy's top/left) to the Draggable's x and y (and rotation if necessary) properties so that they reflect reality and it also (optionally) applies any snapping necessary. This is used by the ThrowPropsPlugin tween in an onUpdate to ensure things are synced and snapped.
780
+ syncXY = function(skipOnUpdate, skipSnap) {
781
+ var snappedValue;
782
+ if (xyMode) {
783
+ self.y = target._gsTransform.y;
784
+ self.x = target._gsTransform.x;
785
+ } else if (rotationMode) {
786
+ self.x = self.rotation = target._gsTransform.rotation;
787
+ } else if (scrollProxy) {
788
+ self.y = scrollProxy.top();
789
+ self.x = scrollProxy.left();
790
+ } else {
791
+ self.y = parseInt(target.style.top, 10) || 0;
792
+ self.x = parseInt(target.style.left, 10) || 0;
793
+ }
794
+ if ((snapX || snapY) && !skipSnap) {
795
+ if (snapX) {
796
+ snappedValue = snapX(self.x);
797
+ if (snappedValue !== self.x) {
798
+ self.x = snappedValue;
799
+ if (rotationMode) {
800
+ self.rotation = snappedValue;
801
+ }
802
+ dirty = true;
803
+ }
804
+ }
805
+ if (snapY) {
806
+ snappedValue = snapY(self.y);
807
+ if (snappedValue !== self.y) {
808
+ self.y = snappedValue;
809
+ dirty = true;
810
+ }
811
+ }
812
+ if (dirty) {
813
+ render(true);
814
+ }
815
+ }
816
+ if (vars.onThrowUpdate && !skipOnUpdate) {
817
+ vars.onThrowUpdate.apply(vars.onThrowUpdateScope || self, vars.onThrowUpdateParams || _emptyArray);
818
+ }
819
+ },
820
+
821
+ calculateBounds = function() {
822
+ var bounds, targetBounds, snap, snapIsRaw;
823
+ hasBounds = false;
824
+ if (scrollProxy) {
825
+ scrollProxy.calibrate();
826
+ self.minX = minX = -scrollProxy.maxScrollLeft();
827
+ self.minY = minY = -scrollProxy.maxScrollTop();
828
+ self.maxX = maxX = self.maxY = maxY = 0;
829
+ hasBounds = true;
830
+ } else if (!!vars.bounds) {
831
+ bounds = _getBounds(vars.bounds, target.parentNode); //could be a selector/jQuery object or a DOM element or a generic object like {top:0, left:100, width:1000, height:800} or {minX:100, maxX:1100, minY:0, maxY:800}
832
+ if (rotationMode) {
833
+ self.minX = minX = bounds.left;
834
+ self.maxX = maxX = bounds.left + bounds.width;
835
+ self.minY = minY = self.maxY = maxY = 0;
836
+ } else if (vars.bounds.maxX !== undefined || vars.bounds.maxY !== undefined) {
837
+ bounds = vars.bounds;
838
+ self.minX = minX = bounds.minX;
839
+ self.minY = minY = bounds.minY;
840
+ self.maxX = maxX = bounds.maxX;
841
+ self.maxY = maxY = bounds.maxY;
842
+ } else {
843
+ targetBounds = _getBounds(target, target.parentNode);
844
+ self.minX = minX = _getStyle(target, xProp) + bounds.left - targetBounds.left;
845
+ self.minY = minY = _getStyle(target, yProp) + bounds.top - targetBounds.top;
846
+ self.maxX = maxX = minX + (bounds.width - targetBounds.width);
847
+ self.maxY = maxY = minY + (bounds.height - targetBounds.height);
848
+ }
849
+ if (minX > maxX) {
850
+ self.minX = maxX;
851
+ self.maxX = maxX = minX;
852
+ minX = self.minX;
853
+ }
854
+ if (minY > maxY) {
855
+ self.minY = maxY;
856
+ self.maxY = maxY = minY;
857
+ minY = self.minY;
858
+ }
859
+ if (rotationMode) {
860
+ self.minRotation = minX;
861
+ self.maxRotation = maxX;
862
+ }
863
+ hasBounds = true;
864
+ }
865
+ if (vars.liveSnap) {
866
+ snap = (vars.liveSnap === true) ? (vars.snap || {}) : vars.liveSnap;
867
+ snapIsRaw = (snap instanceof Array || typeof(snap) === "function");
868
+ if (rotationMode) {
869
+ snapX = buildSnapFunc((snapIsRaw ? snap : snap.rotation), minX, maxX, 1);
870
+ snapY = null;
871
+ } else {
872
+ snapX = buildSnapFunc((snapIsRaw ? snap : snap.x || snap.left || snap.scrollLeft), minX, maxX, scrollProxy ? -1 : 1);
873
+ snapY = buildSnapFunc((snapIsRaw ? snap : snap.y || snap.top || snap.scrollTop), minY, maxY, scrollProxy ? -1 : 1);
874
+ }
875
+ }
876
+
877
+ },
878
+
879
+ animate = function(throwProps, forceZeroVelocity) {
880
+ var snap, snapIsRaw, tween;
881
+ if (throwProps && ThrowPropsPlugin) {
882
+ if (throwProps === true) {
883
+ snap = vars.snap || {};
884
+ snapIsRaw = (snap instanceof Array || typeof(snap) === "function");
885
+ throwProps = {resistance:(vars.throwResistance || vars.resistance || 1000) / (rotationMode ? 10 : 1)};
886
+ if (rotationMode) {
887
+ throwProps.rotation = _parseThrowProps(self, snapIsRaw ? snap : snap.rotation, maxX, minX, 1, forceZeroVelocity);
888
+ } else {
889
+ if (allowX) {
890
+ throwProps[xProp] = _parseThrowProps(self, snapIsRaw ? snap : snap.x || snap.left || snap.scrollLeft, maxX, minX, scrollProxy ? -1 : 1, forceZeroVelocity || (self.lockAxis && lockedAxis === "x"));
891
+ }
892
+ if (allowY) {
893
+ throwProps[yProp] = _parseThrowProps(self, snapIsRaw ? snap : snap.y || snap.top || snap.scrollTop, maxY, minY, scrollProxy ? -1 : 1, forceZeroVelocity || (self.lockAxis && lockedAxis === "y"));
894
+ }
895
+ }
896
+ }
897
+ self.tween = tween = ThrowPropsPlugin.to(scrollProxy || target, {throwProps:throwProps, ease:(vars.ease || Power3.easeOut), onComplete:vars.onThrowComplete, onCompleteParams:vars.onThrowCompleteParams, onCompleteScope:(vars.onThrowCompleteScope || self), onUpdate:(vars.fastMode ? vars.onThrowUpdate : syncXY), onUpdateParams:vars.onThrowUpdateParams, onUpdateScope:(vars.onThrowUpdateScope || self)}, (isNaN(vars.maxDuration) ? 2 : vars.maxDuration), (isNaN(vars.minDuration) ? 0.5 : vars.minDuration), (isNaN(vars.overshootTolerance) ? (1 - self.edgeResistance) + 0.2 : vars.overshootTolerance));
898
+ if (!vars.fastMode) {
899
+ //to populate the end values, we just scrub the tween to the end, record the values, and then jump back to the beginning.
900
+ if (scrollProxy) {
901
+ scrollProxy._suspendTransforms = true; //Microsoft browsers have a bug that causes them to briefly render the position incorrectly (it flashes to the end state when we seek() the tween even though we jump right back to the current position, and this only seems to happen when we're affecting both top and left), so we set a _suspendTransforms flag to prevent it from actually applying the values in the ScrollProxy.
902
+ }
903
+ tween.seek(tween.duration());
904
+ syncXY(true, true);
905
+ self.endX = self.x;
906
+ self.endY = self.y;
907
+ if (rotationMode) {
908
+ self.endRotation = self.x;
909
+ }
910
+ tween.play(0);
911
+ syncXY(true, true);
912
+ if (scrollProxy) {
913
+ scrollProxy._suspendTransforms = false;
914
+ }
915
+ }
916
+ } else if (hasBounds) {
917
+ self.applyBounds();
918
+ }
919
+ },
920
+
921
+ recordStartPositions = function() {
922
+ var edgeTolerance = 1 - self.edgeResistance;
923
+ matrix = _getConcatenatedMatrix(target.parentNode, true);
924
+ if (!matrix[1] && !matrix[2] && matrix[0] == 1 && matrix[3] == 1) { //if there are no transforms, we can optimize performance by not factoring in the matrix
925
+ matrix = null;
926
+ }
927
+ if (scrollProxy) {
928
+ calculateBounds();
929
+ startElementY = scrollProxy.top();
930
+ startElementX = scrollProxy.left();
931
+ } else {
932
+ //if the element is in the process of tweening, don't force snapping to occur because it could make it jump. Imagine the user throwing, then before it's done, clicking on the element in its inbetween state.
933
+ if (isTweening()) {
934
+ syncXY(true, true);
935
+ calculateBounds();
936
+ } else {
937
+ self.applyBounds();
938
+ }
939
+ if (rotationMode) {
940
+ rotationOrigin = _localToGlobal(target, {x:0, y:0});
941
+ syncXY(true, true);
942
+ startElementX = self.x; //starting rotation (x always refers to rotation in type:"rotation", measured in degrees)
943
+ startElementY = self.y = Math.atan2(rotationOrigin.y - startMouseY, startMouseX - rotationOrigin.x) * _RAD2DEG;
944
+ } else {
945
+ startElementY = _getStyle(target, yProp); //record the starting top and left values so that we can just add the mouse's movement to them later.
946
+ startElementX = _getStyle(target, xProp);
947
+ }
948
+ }
949
+ if (hasBounds && edgeTolerance) {
950
+ if (startElementX > maxX) {
951
+ startElementX = maxX + (startElementX - maxX) / edgeTolerance;
952
+ } else if (startElementX < minX) {
953
+ startElementX = minX - (minX - startElementX) / edgeTolerance;
954
+ }
955
+ if (!rotationMode) {
956
+ if (startElementY > maxY) {
957
+ startElementY = maxY + (startElementY - maxY) / edgeTolerance;
958
+ } else if (startElementY < minY) {
959
+ startElementY = minY - (minY - startElementY) / edgeTolerance;
960
+ }
961
+ }
962
+ }
963
+ },
964
+
965
+ isTweening = function() {
966
+ return (self.tween && self.tween.isActive());
967
+ },
968
+
969
+ buildSnapFunc = function(snap, min, max, factor) {
970
+ if (typeof(snap) === "function") {
971
+ return function(n) {
972
+ var edgeTolerance = !self.isDragging ? 1 : 1 - self.edgeResistance; //if we're tweening, disable the edgeTolerance because it's already factored into the tweening values (we don't want to apply it multiple times)
973
+ return snap.call(self, (n > max ? max + (n - max) * edgeTolerance : (n < min) ? min + (n - min) * edgeTolerance : n)) * factor;
974
+ };
975
+ }
976
+ if (snap instanceof Array) {
977
+ return function(n) {
978
+ var i = snap.length,
979
+ closest = 0,
980
+ absDif = _max,
981
+ val, dif;
982
+ while (--i > -1) {
983
+ val = snap[i];
984
+ dif = val - n;
985
+ if (dif < 0) {
986
+ dif = -dif;
987
+ }
988
+ if (dif < absDif && val >= min && val <= max) {
989
+ closest = i;
990
+ absDif = dif;
991
+ }
992
+ }
993
+ return snap[closest];
994
+ };
995
+ }
996
+ return isNaN(snap) ? function(n) { return n; } : function() { return snap * factor; };
997
+ },
998
+
999
+ //called when the mouse is pressed (or touch starts)
1000
+ onPress = function(e) {
1001
+ var temp;
1002
+ if (self.isDragging || !e) { //just in case the browser dispatches a "touchstart" and "mousedown" (some browsers emulate mouse events when using touches)
1003
+ return;
1004
+ }
1005
+ interrupted = isTweening();
1006
+ self.pointerEvent = e;
1007
+ if (_touchEventLookup[e.type]) { //note: on iOS, BOTH touchmove and mousemove are dispatched, but the mousemove has pageY and pageX of 0 which would mess up the calculations and needlessly hurt performance.
1008
+ touchEventTarget = (e.type.indexOf("touch") !== -1) ? trigger : _doc; //pointer-based touches (for Microsoft browsers) don't remain locked to the original target like other browsers, so we must use the document instead. The event type would be "MSPointerDown" or "pointerdown".
1009
+ _addListener(touchEventTarget, "touchend", onRelease);
1010
+ _addListener(touchEventTarget, "touchmove", onMove);
1011
+ _addListener(touchEventTarget, "touchcancel", onRelease);
1012
+ _addListener(_doc, "touchstart", _onMultiTouchDocument);
1013
+ } else {
1014
+ touchEventTarget = null;
1015
+ _addListener(_doc, "mousemove", onMove); //attach these to the document instead of the box itself so that if the user's mouse moves too quickly (and off of the box), things still work.
1016
+ _addListener(_doc, "mouseup", onRelease);
1017
+ }
1018
+ isClicking = (_isClickable(e.target) && !vars.dragClickables);
1019
+ if (isClicking) {
1020
+ _addListener(e.target, "change", onRelease); //in some browsers, when you mousedown on a <select> element, no mouseup gets dispatched! So we listen for a "change" event instead.
1021
+ return;
1022
+ }
1023
+ if (_isOldIE) {
1024
+ e = _populateIEEvent(e, true);
1025
+ } else if (!(e.touches && e.touches.length > _dragCount + 1)) { //in some mobile browsers, e.preventDefault() when pressing on a link (or element with an onclick) will cause the link not to work.
1026
+ e.preventDefault();
1027
+ if (e.preventManipulation) {
1028
+ e.preventManipulation(); //for some Microsoft browsers
1029
+ }
1030
+ }
1031
+ if (e.changedTouches) { //touch events store the data slightly differently
1032
+ e = touch = e.changedTouches[0];
1033
+ touchID = e.identifier;
1034
+ } else if (e.pointerId) {
1035
+ touchID = e.pointerId; //for some Microsoft browsers
1036
+ } else {
1037
+ touch = null;
1038
+ }
1039
+ _dragCount++;
1040
+ _addToRenderQueue(render); //causes the Draggable to render on each "tick" of TweenLite.ticker (performance optimization - updating values in a mousemove can cause them to happen too frequently, like multiple times between frame redraws which is wasteful, and it also prevents values from updating properly in IE8)
1041
+ if (self.tween) {
1042
+ self.tween.kill();
1043
+ }
1044
+ TweenLite.killTweensOf(scrollProxy || target, true, killProps); //in case the user tries to drag it before the last tween is done.
1045
+ startMouseY = self.pointerY = e.pageY; //record the starting x and y so that we can calculate the movement from the original in _onMouseMove
1046
+ startMouseX = self.pointerX = e.pageX;
1047
+ recordStartPositions();
1048
+ if (matrix) {
1049
+ temp = startMouseX * matrix[0] + startMouseY * matrix[2] + matrix[4];
1050
+ startMouseY = startMouseX * matrix[1] + startMouseY * matrix[3] + matrix[5];
1051
+ startMouseX = temp;
1052
+ }
1053
+ self.tween = lockedAxis = null;
1054
+ if (!rotationMode && !scrollProxy && vars.zIndexBoost !== false) {
1055
+ target.style.zIndex = Draggable.zIndex++;
1056
+ }
1057
+ self.isDragging = true;
1058
+ hasDragCallback = !!(vars.onDrag || self._listeners.drag);
1059
+ dirty = false;
1060
+ if (!rotationMode) {
1061
+ _setStyle(trigger, "cursor", vars.cursor || "move");
1062
+ }
1063
+ _dispatchEvent(self, "dragstart", "onDragStart");
1064
+ },
1065
+
1066
+ //called every time the mouse/touch moves
1067
+ onMove = function(e) {
1068
+ if (_isMultiTouching || !self.isDragging) {
1069
+ return;
1070
+ }
1071
+ if (_isOldIE) {
1072
+ e = _populateIEEvent(e, true);
1073
+ } else {
1074
+ e.preventDefault();
1075
+ if (e.preventManipulation) { //for some Microsoft browsers
1076
+ e.preventManipulation();
1077
+ }
1078
+ }
1079
+ self.pointerEvent = e;
1080
+ var touches = e.changedTouches,
1081
+ dragTolerance = 1 - self.dragResistance,
1082
+ edgeTolerance = 1 - self.edgeResistance,
1083
+ xChange, yChange, x, y, i, dif, mouseX, mouseY, temp;
1084
+ if (touches) { //touch events store the data slightly differently
1085
+ e = touches[0];
1086
+ if (e !== touch && e.identifier !== touchID) { //Usually changedTouches[0] will be what we're looking for, but in case it's not, look through the rest of the array...(and Android browsers don't reuse the event like iOS)
1087
+ i = touches.length;
1088
+ while (--i > -1 && (e = touches[i]).identifier !== touchID) {}
1089
+ if (i < 0) {
1090
+ return;
1091
+ }
1092
+ }
1093
+ } else if (e.pointerId && touchID && e.pointerId !== touchID) { //for some Microsoft browsers, we must attach the listener to the doc rather than the trigger so that when the finger moves outside the bounds of the trigger, things still work. So if the event we're receiving has a pointerId that doesn't match the touchID, ignore it (for multi-touch)
1094
+ return;
1095
+ }
1096
+ mouseX = self.pointerX = e.pageX;
1097
+ mouseY = self.pointerY = e.pageY;
1098
+ dirty = true; //a flag that indicates we need to render the target next time the TweenLite.ticker dispatches a "tick" event (typically on a requestAnimationFrame) - this is a performance optimization (we shouldn't render on every move because sometimes many move events can get dispatched between screen refreshes, and that'd be wasteful to render every time)
1099
+
1100
+ if (rotationMode) {
1101
+ y = Math.atan2(rotationOrigin.y - e.pageY, e.pageX - rotationOrigin.x) * _RAD2DEG;
1102
+ dif = self.y - y;
1103
+ self.y = y;
1104
+ if (dif > 180) {
1105
+ startElementY -= 360;
1106
+ } else if (dif < -180) {
1107
+ startElementY += 360;
1108
+ }
1109
+ x = startElementX + (startElementY - y) * dragTolerance;
1110
+
1111
+ } else {
1112
+ if (matrix) {
1113
+ temp = mouseX * matrix[0] + mouseY * matrix[2] + matrix[4];
1114
+ mouseY = mouseX * matrix[1] + mouseY * matrix[3] + matrix[5];
1115
+ mouseX = temp;
1116
+ }
1117
+ yChange = (mouseY - startMouseY);
1118
+ xChange = (mouseX - startMouseX);
1119
+ if (yChange < 2 && yChange > -2) {
1120
+ yChange = 0;
1121
+ }
1122
+ if (xChange < 2 && xChange > -2) {
1123
+ xChange = 0;
1124
+ }
1125
+ if (self.lockAxis && (xChange || yChange)) {
1126
+ if (lockedAxis === "y" || (!lockedAxis && Math.abs(xChange) > Math.abs(yChange) && allowX)) {
1127
+ yChange = 0;
1128
+ lockedAxis = "y";
1129
+ } else if (allowY) {
1130
+ xChange = 0;
1131
+ lockedAxis = "x";
1132
+ }
1133
+ }
1134
+ x = startElementX + xChange * dragTolerance;
1135
+ y = startElementY + yChange * dragTolerance;
1136
+ }
1137
+
1138
+ if (snapX || snapY) {
1139
+ if (snapX) {
1140
+ x = snapX(x);
1141
+ }
1142
+ if (snapY) {
1143
+ y = snapY(y);
1144
+ }
1145
+ } else if (hasBounds) {
1146
+ if (x > maxX) {
1147
+ x = maxX + (x - maxX) * edgeTolerance;
1148
+ } else if (x < minX) {
1149
+ x = minX + (x - minX) * edgeTolerance;
1150
+ }
1151
+ if (!rotationMode) {
1152
+ if (y > maxY) {
1153
+ y = maxY + (y - maxY) * edgeTolerance;
1154
+ } else if (y < minY) {
1155
+ y = minY + (y - minY) * edgeTolerance;
1156
+ }
1157
+ }
1158
+ }
1159
+ if (self.x !== x || (self.y !== y && !rotationMode)) {
1160
+ self.x = self.endX = x;
1161
+ if (rotationMode) {
1162
+ self.endRotation = x;
1163
+ } else {
1164
+ self.y = self.endY = y;
1165
+ }
1166
+ } else {
1167
+ dirty = false;
1168
+ }
1169
+ },
1170
+
1171
+ //called when the mouse/touch is released
1172
+ onRelease = function(e, force) {
1173
+ if (e && touchID && !force && e.pointerId && e.pointerId !== touchID) { //for some Microsoft browsers, we must attach the listener to the doc rather than the trigger so that when the finger moves outside the bounds of the trigger, things still work. So if the event we're receiving has a pointerId that doesn't match the touchID, ignore it (for multi-touch)
1174
+ return;
1175
+ }
1176
+ var originalEvent = e,
1177
+ touches, xChange, yChange, i;
1178
+ if (touchEventTarget) {
1179
+ _removeListener(touchEventTarget, "touchend", onRelease);
1180
+ _removeListener(touchEventTarget, "touchmove", onMove);
1181
+ _removeListener(touchEventTarget, "touchcancel", onRelease);
1182
+ _removeListener(_doc, "touchstart", _onMultiTouchDocument);
1183
+ } else {
1184
+ _removeListener(_doc, "mouseup", onRelease);
1185
+ _removeListener(_doc, "mousemove", onMove);
1186
+ }
1187
+ dirty = false;
1188
+ if (isClicking) {
1189
+ if (e) {
1190
+ _removeListener(e.target, "change", onRelease);
1191
+ }
1192
+ _dispatchEvent(self, "click", "onClick");
1193
+ isClicking = false;
1194
+ return;
1195
+ }
1196
+ _removeFromRenderQueue(render);
1197
+ if (!rotationMode) {
1198
+ _setStyle(trigger, "cursor", vars.cursor || "move");
1199
+ }
1200
+ self.isDragging = false;
1201
+ _dragCount--;
1202
+ if (e) {
1203
+ if (_isOldIE) {
1204
+ e = _populateIEEvent(e, false);
1205
+ }
1206
+ touches = e.changedTouches;
1207
+ if (touches) { //touch events store the data slightly differently
1208
+ e = touches[0];
1209
+ if (e !== touch && e.identifier !== touchID) { //Usually changedTouches[0] will be what we're looking for, but in case it's not, look through the rest of the array...(and Android browsers don't reuse the event like iOS)
1210
+ i = touches.length;
1211
+ while (--i > -1 && (e = touches[i]).identifier !== touchID) {}
1212
+ if (i < 0) {
1213
+ return;
1214
+ }
1215
+ }
1216
+ }
1217
+ self.pointerEvent = originalEvent;
1218
+ self.pointerX = e.pageX;
1219
+ self.pointerY = e.pageY;
1220
+ yChange = (e.pageY - startMouseY);
1221
+ xChange = (e.pageX - startMouseX);
1222
+ }
1223
+ if (originalEvent && xChange < 2 && xChange > -2 && yChange < 2 && yChange > -2) {
1224
+ if (interrupted && vars.snap) { //otherwise, if the user clicks on the object while it's animating to a snapped position, and then releases without moving 3 pixels, it will just stay there (it should animate/snap)
1225
+ animate(vars.throwProps);
1226
+ }
1227
+ _dispatchEvent(self, "click", "onClick");
1228
+ } else {
1229
+ animate(vars.throwProps); //will skip if throwProps isn't defined or ThrowPropsPlugin isn't loaded.
1230
+ if (!_isOldIE && originalEvent && (vars.dragClickables || !_isClickable(originalEvent.target))) {
1231
+ originalEvent.preventDefault();
1232
+ if (originalEvent.preventManipulation) {
1233
+ originalEvent.preventManipulation(); //for some Microsoft browsers
1234
+ }
1235
+ }
1236
+ }
1237
+ _dispatchEvent(self, "dragend", "onDragEnd");
1238
+ return true;
1239
+ };
1240
+
1241
+ old = Draggable.get(this.target);
1242
+ if (old) {
1243
+ old.kill(); // avoids duplicates (an element can only be controlled by one Draggable)
1244
+ }
1245
+
1246
+ //give the user access to start/stop dragging...
1247
+ this.startDrag = onPress;
1248
+ this.endDrag = function(e) {
1249
+ onRelease(e, true);
1250
+ };
1251
+
1252
+ this.applyBounds = function(newBounds) {
1253
+ var x, y;
1254
+ if (newBounds && vars.bounds !== newBounds) {
1255
+ vars.bounds = newBounds;
1256
+ return self.update(true);
1257
+ }
1258
+ syncXY(true);
1259
+ calculateBounds();
1260
+ if (hasBounds) {
1261
+ x = self.x;
1262
+ y = self.y;
1263
+ if (hasBounds) {
1264
+ if (x > maxX) {
1265
+ x = maxX;
1266
+ } else if (x < minX) {
1267
+ x = minX;
1268
+ }
1269
+ if (y > maxY) {
1270
+ y = maxY;
1271
+ } else if (y < minY) {
1272
+ y = minY;
1273
+ }
1274
+ }
1275
+ if (self.x !== x || self.y !== y) {
1276
+ self.x = self.endX = x;
1277
+ if (rotationMode) {
1278
+ self.endRotation = x;
1279
+ } else {
1280
+ self.y = self.endY = y;
1281
+ }
1282
+ dirty = true;
1283
+ render();
1284
+ }
1285
+ }
1286
+ return self;
1287
+ };
1288
+
1289
+ this.update = function(applyBounds) {
1290
+ var x = self.x,
1291
+ y = self.y;
1292
+ if (applyBounds) {
1293
+ self.applyBounds();
1294
+ } else {
1295
+ syncXY(true);
1296
+ }
1297
+ if (self.isDragging && (x !== self.x || (y !== self.y && !rotationMode))) {
1298
+ recordStartPositions();
1299
+ }
1300
+ return self;
1301
+ };
1302
+
1303
+ this.enable = function() {
1304
+ var id;
1305
+ _addListener(trigger, "mousedown", onPress);
1306
+ _addListener(trigger, "touchstart", onPress);
1307
+ if (!rotationMode) {
1308
+ _setStyle(trigger, "cursor", vars.cursor || "move");
1309
+ }
1310
+ trigger.ondragstart = trigger.onselectstart = _emptyFunc; //prevent text selection (and prevent IE from dragging images)
1311
+ _setStyle(trigger, "userSelect", "none");
1312
+ _setStyle(trigger, "touchCallout", "none");
1313
+ _setStyle(trigger, "touchAction", "none");
1314
+ if (ThrowPropsPlugin) {
1315
+ ThrowPropsPlugin.track(scrollProxy || target, (xyMode ? "x,y" : rotationMode ? "rotation" : "top,left"));
1316
+ }
1317
+ if (scrollProxy) {
1318
+ scrollProxy.enable();
1319
+ }
1320
+ target._gsDragID = id = "d" + (_lookupCount++);
1321
+ _lookup[id] = this;
1322
+ if (scrollProxy) {
1323
+ scrollProxy.element._gsDragID = id;
1324
+ }
1325
+ TweenLite.set(target, {x:"+=0"}); //simply ensures that there's a _gsTransform on the element.
1326
+ this.update();
1327
+ return self;
1328
+ };
1329
+
1330
+ this.disable = function() {
1331
+ var dragging = this.isDragging;
1332
+ if (!rotationMode) {
1333
+ _setStyle(trigger, "cursor", null);
1334
+ }
1335
+ TweenLite.killTweensOf(scrollProxy || target, true, killProps);
1336
+ trigger.ondragstart = trigger.onselectstart = null;
1337
+ _setStyle(trigger, "userSelect", "text");
1338
+ _setStyle(trigger, "touchCallout", "default");
1339
+ _setStyle(trigger, "MSTouchAction", "auto");
1340
+ _removeListener(trigger, "mousedown", onPress);
1341
+ _removeListener(trigger, "touchstart", onPress);
1342
+ if (touchEventTarget) {
1343
+ _removeListener(touchEventTarget, "touchcancel", onRelease);
1344
+ _removeListener(touchEventTarget, "touchend", onRelease);
1345
+ _removeListener(touchEventTarget, "touchmove", onMove);
1346
+ }
1347
+ _removeListener(_doc, "mouseup", onRelease);
1348
+ _removeListener(_doc, "mousemove", onMove);
1349
+ if (ThrowPropsPlugin) {
1350
+ ThrowPropsPlugin.untrack(scrollProxy || target, (xyMode ? "x,y" : rotationMode ? "rotation" : "top,left"));
1351
+ }
1352
+ if (scrollProxy) {
1353
+ scrollProxy.disable();
1354
+ }
1355
+ _removeFromRenderQueue(render);
1356
+ this.isDragging = isClicking = false;
1357
+ if (dragging) {
1358
+ _dispatchEvent(this, "dragend", "onDragEnd");
1359
+ }
1360
+ return self;
1361
+ };
1362
+
1363
+ this.kill = function() {
1364
+ self.disable();
1365
+ delete _lookup[target._gsDragID];
1366
+ return self;
1367
+ };
1368
+
1369
+ if (type.indexOf("scroll") !== -1) {
1370
+ scrollProxy = this.scrollProxy = new ScrollProxy(target, _extend({onKill:function() { //ScrollProxy's onKill() gets called if/when the ScrollProxy senses that the user interacted with the scroll position manually (like using the scrollbar). IE9 doesn't fire the "mouseup" properly when users drag the scrollbar of an element, so this works around that issue.
1371
+ if (self.isDragging) {
1372
+ onRelease(null);
1373
+ }}}, vars));
1374
+ //a bug in many Android devices' stock browser causes scrollTop to get forced back to 0 after it is altered via JS, so we set overflow to "hidden" on mobile/touch devices (they hide the scroll bar anyway). That works around the bug. (This bug is discussed at https://code.google.com/p/android/issues/detail?id=19625)
1375
+ target.style.overflowY = (allowY && !_isTouchDevice) ? "auto" : "hidden";
1376
+ target.style.overflowX = (allowX && !_isTouchDevice) ? "auto" : "hidden";
1377
+ target = scrollProxy.content;
1378
+ }
1379
+
1380
+ if (vars.force3D !== false) {
1381
+ TweenLite.set(target, {force3D:true}); //improve performance by forcing a GPU layer when possible
1382
+ }
1383
+ if (rotationMode) {
1384
+ killProps.rotation = 1;
1385
+ } else {
1386
+ if (allowX) {
1387
+ killProps[xProp] = 1;
1388
+ }
1389
+ if (allowY) {
1390
+ killProps[yProp] = 1;
1391
+ }
1392
+ }
1393
+ if (rotationMode) {
1394
+ tempVars = _tempVarsRotation;
1395
+ cssVars = tempVars.css;
1396
+ tempVars.overwrite = false;
1397
+ } else if (xyMode) {
1398
+ tempVars = (allowX && allowY) ? _tempVarsXY : allowX ? _tempVarsX : _tempVarsY;
1399
+ cssVars = tempVars.css;
1400
+ tempVars.overwrite = false;
1401
+ }
1402
+
1403
+ this.isDragging = false;
1404
+ this.enable();
1405
+ },
1406
+ p = Draggable.prototype = new EventDispatcher();
1407
+
1408
+ p.constructor = Draggable;
1409
+ p.pointerX = p.pointerY = 0;
1410
+ Draggable.version = "0.9.9";
1411
+ Draggable.zIndex = 1000;
1412
+
1413
+ _addListener(_doc, "touchcancel", function() {
1414
+ //some older Android devices intermittently stop dispatching "touchmove" events if we don't listen for "touchcancel" on the document. Very strange indeed.
1415
+ });
1416
+
1417
+ Draggable.create = function(targets, vars) {
1418
+ if (typeof(targets) === "string") {
1419
+ targets = TweenLite.selector(targets);
1420
+ }
1421
+ var a = _isArrayLike(targets) ? _flattenArray(targets) : [targets],
1422
+ i = a.length;
1423
+ while (--i > -1) {
1424
+ a[i] = new Draggable(a[i], vars);
1425
+ }
1426
+ return a;
1427
+ };
1428
+
1429
+ Draggable.get = function(target) {
1430
+ return _lookup[(_unwrapElement(target) || {})._gsDragID];
1431
+ };
1432
+
1433
+ return Draggable;
1434
+
1435
+ }, true);
1436
+
1437
+
1438
+ }); if (window._gsDefine) { window._gsQueue.pop()(); }