greensock-rails 1.17.0.0 → 1.18.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * VERSION: 0.1.11
3
- * DATE: 2015-03-13
2
+ * VERSION: 0.1.12
3
+ * DATE: 2015-08-11
4
4
  * UPDATES AND DOCS AT: http://greensock.com/jquery-gsap-plugin/
5
5
  *
6
6
  * Requires TweenLite version 1.8.0 or higher and CSSPlugin.
@@ -140,8 +140,8 @@
140
140
  if (config.queue !== false) {
141
141
  obj.queue(config.queue, doAnimation); //note: the queued function will get called once for each element in the jQuery collection.
142
142
  if (typeof(config.old) === "function") {
143
- obj.queue(config.queue, function(next) {
144
- config.old.call(this);
143
+ $(obj[obj.length-1]).queue(config.queue, function(next) {
144
+ config.old.call(obj);
145
145
  next();
146
146
  });
147
147
  }
@@ -176,7 +176,7 @@
176
176
  enabled:function(value) {
177
177
  _enabled = value;
178
178
  },
179
- version:"0.1.11",
179
+ version:"0.1.12",
180
180
  legacyProps:function(value) {
181
181
  _legacyProps = _defaultLegacyProps + value + ",";
182
182
  }
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * VERSION: 0.4.0
3
- * DATE: 2015-05-06
2
+ * VERSION: 0.5.0
3
+ * DATE: 2015-08-29
4
4
  * UPDATES AND DOCS AT: http://greensock.com
5
5
  *
6
6
  * @license Copyright (c) 2008-2015, GreenSock. All rights reserved.
@@ -14,58 +14,22 @@ var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(globa
14
14
 
15
15
  "use strict";
16
16
 
17
- var _numExp = /(?:\d|\-|\+|=|#|\.)*/g,
18
- _suffixExp = /[A-Za-z%]/g;
19
-
20
17
  _gsScope._gsDefine.plugin({
21
18
  propName: "attr",
22
19
  API: 2,
23
- version: "0.4.0",
20
+ version: "0.5.0",
24
21
 
25
22
  //called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run.
26
23
  init: function(target, value, tween) {
27
- var p, start, end, suffix, i;
24
+ var p;
28
25
  if (typeof(target.setAttribute) !== "function") {
29
26
  return false;
30
27
  }
31
- this._target = target;
32
- this._proxy = {};
33
- this._start = {}; // we record start and end values exactly as they are in case they're strings (not numbers) - we need to be able to revert to them cleanly.
34
- this._end = {};
35
- this._suffix = {};
36
28
  for (p in value) {
37
- this._start[p] = this._proxy[p] = start = target.getAttribute(p) + "";
38
- this._end[p] = end = value[p] + "";
39
- this._suffix[p] = suffix = _suffixExp.test(end) ? end.replace(_numExp, "") : _suffixExp.test(start) ? start.replace(_numExp, "") : "";
40
- if (suffix) {
41
- i = end.indexOf(suffix);
42
- if (i !== -1) {
43
- end = end.substr(0, i);
44
- }
45
- }
46
- if(!this._addTween(this._proxy, p, parseFloat(start), end, p)) {
47
- this._suffix[p] = ""; //not a valid tween - perhaps something like an <img src=""> attribute.
48
- }
49
- if (end.charAt(1) === "=") {
50
- this._end[p] = (this._firstPT.s + this._firstPT.c) + suffix;
51
- }
29
+ this._addTween(target, "setAttribute", target.getAttribute(p) + "", value[p] + "", p, false, p);
52
30
  this._overwriteProps.push(p);
53
31
  }
54
32
  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(ratio) {
59
- this._super.setRatio.call(this, ratio);
60
- var props = this._overwriteProps,
61
- i = props.length,
62
- lookup = (ratio === 1) ? this._end : ratio ? this._proxy : this._start,
63
- useSuffix = (lookup === this._proxy),
64
- p;
65
- while (--i > -1) {
66
- p = props[i];
67
- this._target.setAttribute(p, lookup[p] + (useSuffix ? this._suffix[p] : ""));
68
- }
69
33
  }
70
34
 
71
35
  });
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * VERSION: 1.17.0
3
- * DATE: 2015-05-27
2
+ * VERSION: 1.18.0
3
+ * DATE: 2015-09-05
4
4
  * UPDATES AND DOCS AT: http://greensock.com
5
5
  *
6
6
  * @license Copyright (c) 2008-2015, GreenSock. All rights reserved.
@@ -31,7 +31,7 @@ var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(globa
31
31
  p = CSSPlugin.prototype = new TweenPlugin("css");
32
32
 
33
33
  p.constructor = CSSPlugin;
34
- CSSPlugin.version = "1.17.0";
34
+ CSSPlugin.version = "1.18.0";
35
35
  CSSPlugin.API = 2;
36
36
  CSSPlugin.defaultTransformPerspective = 0;
37
37
  CSSPlugin.defaultSkewType = "compensated";
@@ -174,7 +174,7 @@ var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(globa
174
174
  pix = (v / 100) * (horiz ? t.clientWidth : t.clientHeight);
175
175
  } else {
176
176
  style.cssText = "border:0 solid red;position:" + _getStyle(t, "position") + ";line-height:0;";
177
- if (sfx === "%" || !node.appendChild) {
177
+ if (sfx === "%" || !node.appendChild || sfx.charAt(0) === "v" || sfx === "rem") {
178
178
  node = t.parentNode || _doc.body;
179
179
  cache = node._gsCache;
180
180
  time = TweenLite.ticker.frame;
@@ -300,7 +300,10 @@ var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(globa
300
300
 
301
301
  // @private Parses position-related complex strings like "top left" or "50px 10px" or "70% 20%", etc. which are used for things like transformOrigin or backgroundPosition. Optionally decorates a supplied object (recObj) with the following properties: "ox" (offsetX), "oy" (offsetY), "oxp" (if true, "ox" is a percentage not a pixel value), and "oxy" (if true, "oy" is a percentage not a pixel value)
302
302
  _parsePosition = function(v, recObj) {
303
- if (v == null || v === "" || v === "auto" || v === "auto auto") { //note: Firefox uses "auto auto" as default whereas Chrome uses "auto".
303
+ if (v === "contain" || v === "auto" || v === "auto auto") {
304
+ return v + " ";
305
+ }
306
+ if (v == null || v === "") { //note: Firefox uses "auto auto" as default whereas Chrome uses "auto".
304
307
  v = "0 0";
305
308
  }
306
309
  var a = v.split(" "),
@@ -418,57 +421,96 @@ var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(globa
418
421
  },
419
422
 
420
423
  /**
421
- * @private Parses a color (like #9F0, #FF9900, or rgb(255,51,153)) into an array with 3 elements for red, green, and blue. Also handles rgba() values (splits into array of 4 elements of course)
424
+ * @private Parses a color (like #9F0, #FF9900, rgb(255,51,153) or hsl(108, 50%, 10%)) into an array with 3 elements for red, green, and blue or if toHSL parameter is true, it will populate the array with hue, saturation, and lightness values. If a relative value is found in an hsl() or hsla() string, it will preserve those relative prefixes and all the values in the array will be strings instead of numbers (in all other cases it will be populated with numbers).
422
425
  * @param {(string|number)} v The value the should be parsed which could be a string like #9F0 or rgb(255,102,51) or rgba(255,0,0,0.5) or it could be a number like 0xFF00CC or even a named color like red, blue, purple, etc.
423
- * @return {Array.<number>} An array containing red, green, and blue (and optionally alpha) in that order.
426
+ * @param {(boolean)} toHSL If true, an hsl() or hsla() value will be returned instead of rgb() or rgba()
427
+ * @return {Array.<number>} An array containing red, green, and blue (and optionally alpha) in that order, or if the toHSL parameter was true, the array will contain hue, saturation and lightness (and optionally alpha) in that order. Always numbers unless there's a relative prefix found in an hsl() or hsla() string and toHSL is true.
424
428
  */
425
- _parseColor = CSSPlugin.parseColor = function(v) {
426
- var c1, c2, c3, h, s, l;
427
- if (!v || v === "") {
428
- return _colorLookup.black;
429
- }
430
- if (typeof(v) === "number") {
431
- return [v >> 16, (v >> 8) & 255, v & 255];
432
- }
433
- if (v.charAt(v.length - 1) === ",") { //sometimes a trailing commma is included and we should chop it off (typically from a comma-delimited list of values like a textShadow:"2px 2px 2px blue, 5px 5px 5px rgb(255,0,0)" - in this example "blue," has a trailing comma. We could strip it out inside parseComplex() but we'd need to do it to the beginning and ending values plus it wouldn't provide protection from other potential scenarios like if the user passes in a similar value.
434
- v = v.substr(0, v.length - 1);
435
- }
436
- if (_colorLookup[v]) {
437
- return _colorLookup[v];
438
- }
439
- if (v.charAt(0) === "#") {
440
- if (v.length === 4) { //for shorthand like #9F0
441
- c1 = v.charAt(1),
442
- c2 = v.charAt(2),
443
- c3 = v.charAt(3);
444
- v = "#" + c1 + c1 + c2 + c2 + c3 + c3;
445
- }
446
- v = parseInt(v.substr(1), 16);
447
- return [v >> 16, (v >> 8) & 255, v & 255];
448
- }
449
- if (v.substr(0, 3) === "hsl") {
450
- v = v.match(_numExp);
451
- h = (Number(v[0]) % 360) / 360;
452
- s = Number(v[1]) / 100;
453
- l = Number(v[2]) / 100;
454
- c2 = (l <= 0.5) ? l * (s + 1) : l + s - l * s;
455
- c1 = l * 2 - c2;
456
- if (v.length > 3) {
457
- v[3] = Number(v[3]);
458
- }
459
- v[0] = _hue(h + 1 / 3, c1, c2);
460
- v[1] = _hue(h, c1, c2);
461
- v[2] = _hue(h - 1 / 3, c1, c2);
462
- return v;
463
- }
464
- v = v.match(_numExp) || _colorLookup.transparent;
465
- v[0] = Number(v[0]);
466
- v[1] = Number(v[1]);
467
- v[2] = Number(v[2]);
468
- if (v.length > 3) {
469
- v[3] = Number(v[3]);
429
+ _parseColor = CSSPlugin.parseColor = function(v, toHSL) {
430
+ var a, r, g, b, h, s, l, max, min, d, wasHSL;
431
+ if (!v) {
432
+ a = _colorLookup.black;
433
+ } else if (typeof(v) === "number") {
434
+ a = [v >> 16, (v >> 8) & 255, v & 255];
435
+ } else {
436
+ if (v.charAt(v.length - 1) === ",") { //sometimes a trailing comma is included and we should chop it off (typically from a comma-delimited list of values like a textShadow:"2px 2px 2px blue, 5px 5px 5px rgb(255,0,0)" - in this example "blue," has a trailing comma. We could strip it out inside parseComplex() but we'd need to do it to the beginning and ending values plus it wouldn't provide protection from other potential scenarios like if the user passes in a similar value.
437
+ v = v.substr(0, v.length - 1);
438
+ }
439
+ if (_colorLookup[v]) {
440
+ a = _colorLookup[v];
441
+ } else if (v.charAt(0) === "#") {
442
+ if (v.length === 4) { //for shorthand like #9F0
443
+ r = v.charAt(1);
444
+ g = v.charAt(2);
445
+ b = v.charAt(3);
446
+ v = "#" + r + r + g + g + b + b;
447
+ }
448
+ v = parseInt(v.substr(1), 16);
449
+ a = [v >> 16, (v >> 8) & 255, v & 255];
450
+ } else if (v.substr(0, 3) === "hsl") {
451
+ a = wasHSL = v.match(_numExp);
452
+ if (!toHSL) {
453
+ h = (Number(a[0]) % 360) / 360;
454
+ s = Number(a[1]) / 100;
455
+ l = Number(a[2]) / 100;
456
+ g = (l <= 0.5) ? l * (s + 1) : l + s - l * s;
457
+ r = l * 2 - g;
458
+ if (a.length > 3) {
459
+ a[3] = Number(v[3]);
460
+ }
461
+ a[0] = _hue(h + 1 / 3, r, g);
462
+ a[1] = _hue(h, r, g);
463
+ a[2] = _hue(h - 1 / 3, r, g);
464
+ } else if (v.indexOf("=") !== -1) { //if relative values are found, just return the raw strings with the relative prefixes in place.
465
+ return v.match(_relNumExp);
466
+ }
467
+ } else {
468
+ a = v.match(_numExp) || _colorLookup.transparent;
469
+ }
470
+ a[0] = Number(a[0]);
471
+ a[1] = Number(a[1]);
472
+ a[2] = Number(a[2]);
473
+ if (a.length > 3) {
474
+ a[3] = Number(a[3]);
475
+ }
476
+ }
477
+ if (toHSL && !wasHSL) {
478
+ r = a[0] / 255;
479
+ g = a[1] / 255;
480
+ b = a[2] / 255;
481
+ max = Math.max(r, g, b);
482
+ min = Math.min(r, g, b);
483
+ l = (max + min) / 2;
484
+ if (max === min) {
485
+ h = s = 0;
486
+ } else {
487
+ d = max - min;
488
+ s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
489
+ h = (max === r) ? (g - b) / d + (g < b ? 6 : 0) : (max === g) ? (b - r) / d + 2 : (r - g) / d + 4;
490
+ h *= 60;
491
+ }
492
+ a[0] = (h + 0.5) | 0;
493
+ a[1] = (s * 100 + 0.5) | 0;
494
+ a[2] = (l * 100 + 0.5) | 0;
470
495
  }
471
- return v;
496
+ return a;
497
+ },
498
+ _formatColors = function(s, toHSL) {
499
+ var colors = s.match(_colorExp) || [],
500
+ charIndex = 0,
501
+ parsed = colors.length ? "" : s,
502
+ i, color, temp;
503
+ for (i = 0; i < colors.length; i++) {
504
+ color = colors[i];
505
+ temp = s.substr(charIndex, s.indexOf(color, charIndex)-charIndex);
506
+ charIndex += temp.length + color.length;
507
+ color = _parseColor(color, toHSL);
508
+ if (color.length === 3) {
509
+ color.push(1);
510
+ }
511
+ parsed += temp + (toHSL ? "hsla(" + color[0] + "," + color[1] + "%," + color[2] + "%," + color[3] : "rgba(" + color.join(",")) + ")";
512
+ }
513
+ return parsed;
472
514
  },
473
515
  _colorExp = "(?:\\b(?:(?:rgb|rgba|hsl|hsla)\\(.+?\\))|\\B#.+?\\b"; //we'll dynamically build this Regular Expression to conserve file size. After building it, it will be able to find rgb(), rgba(), # (hexadecimal), and named color values like red, blue, purple, etc.
474
516
 
@@ -477,6 +519,21 @@ var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(globa
477
519
  }
478
520
  _colorExp = new RegExp(_colorExp+")", "gi");
479
521
 
522
+ CSSPlugin.colorStringFilter = function(a) {
523
+ var combined = a[0] + a[1],
524
+ toHSL;
525
+ _colorExp.lastIndex = 0;
526
+ if (_colorExp.test(combined)) {
527
+ toHSL = (combined.indexOf("hsl(") !== -1 || combined.indexOf("hsla(") !== -1);
528
+ a[0] = _formatColors(a[0], toHSL);
529
+ a[1] = _formatColors(a[1], toHSL);
530
+ }
531
+ };
532
+
533
+ if (!TweenLite.defaultStringFilter) {
534
+ TweenLite.defaultStringFilter = CSSPlugin.colorStringFilter;
535
+ }
536
+
480
537
  /**
481
538
  * @private Returns a formatter function that handles taking a string (or number in some cases) and returning a consistently formatted one in terms of delimiters, quantity of values, etc. For example, we may get boxShadow values defined as "0px red" or "0px 0px 10px rgb(255,0,0)" or "0px 0px 20px 20px #F00" and we need to ensure that what we get back is described with 4 numbers and a color. This allows us to feed it into the _parseComplex() method and split the values up appropriately. The neat thing about this _getFormatter() function is that the dflt defines a pattern as well as a default, so for example, _getFormatter("0px 0px 0px 0px #777", true) not only sets the default as 0px for all distances and #777 for the color, but also sets the pattern such that 4 numbers and a color will always get returned.
482
539
  * @param {!string} dflt The default value and pattern to follow. So "0px 0px 0px 0px #777" will ensure that 4 numbers and a color will always get returned.
@@ -766,7 +823,7 @@ var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(globa
766
823
  ea = e.split(", ").join(",").split(" "), //ending array
767
824
  l = ba.length,
768
825
  autoRound = (_autoRound !== false),
769
- i, xi, ni, bv, ev, bnums, enums, bn, rgba, temp, cv, str;
826
+ i, xi, ni, bv, ev, bnums, enums, bn, hasAlpha, temp, cv, str, useHSL;
770
827
  if (e.indexOf(",") !== -1 || b.indexOf(",") !== -1) {
771
828
  ba = ba.join(" ").replace(_commasOutsideParenExp, ", ").split(" ");
772
829
  ea = ea.join(" ").replace(_commasOutsideParenExp, ", ").split(" ");
@@ -779,6 +836,7 @@ var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(globa
779
836
  }
780
837
  pt.plugin = plugin;
781
838
  pt.setRatio = setRatio;
839
+ _colorExp.lastIndex = 0;
782
840
  for (i = 0; i < l; i++) {
783
841
  bv = ba[i];
784
842
  ev = ea[i];
@@ -788,26 +846,35 @@ var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(globa
788
846
  pt.appendXtra("", bn, _parseChange(ev, bn), ev.replace(_relNumExp, ""), (autoRound && ev.indexOf("px") !== -1), true);
789
847
 
790
848
  //if the value is a color
791
- } else if (clrs && (bv.charAt(0) === "#" || _colorLookup[bv] || _rgbhslExp.test(bv))) {
849
+ } else if (clrs && _colorExp.test(bv)) {
792
850
  str = ev.charAt(ev.length - 1) === "," ? ")," : ")"; //if there's a comma at the end, retain it.
793
- bv = _parseColor(bv);
794
- ev = _parseColor(ev);
795
- rgba = (bv.length + ev.length > 6);
796
- if (rgba && !_supportsOpacity && ev[3] === 0) { //older versions of IE don't support rgba(), so if the destination alpha is 0, just use "transparent" for the end color
851
+ useHSL = (ev.indexOf("hsl") !== -1 && _supportsOpacity);
852
+ bv = _parseColor(bv, useHSL);
853
+ ev = _parseColor(ev, useHSL);
854
+ hasAlpha = (bv.length + ev.length > 6);
855
+ if (hasAlpha && !_supportsOpacity && ev[3] === 0) { //older versions of IE don't support rgba(), so if the destination alpha is 0, just use "transparent" for the end color
797
856
  pt["xs" + pt.l] += pt.l ? " transparent" : "transparent";
798
857
  pt.e = pt.e.split(ea[i]).join("transparent");
799
858
  } else {
800
859
  if (!_supportsOpacity) { //old versions of IE don't support rgba().
801
- rgba = false;
860
+ hasAlpha = false;
802
861
  }
803
- pt.appendXtra((rgba ? "rgba(" : "rgb("), bv[0], ev[0] - bv[0], ",", true, true)
804
- .appendXtra("", bv[1], ev[1] - bv[1], ",", true)
805
- .appendXtra("", bv[2], ev[2] - bv[2], (rgba ? "," : str), true);
806
- if (rgba) {
862
+ if (useHSL) {
863
+ pt.appendXtra((hasAlpha ? "hsla(" : "hsl("), bv[0], _parseChange(ev[0], bv[0]), ",", false, true)
864
+ .appendXtra("", bv[1], _parseChange(ev[1], bv[1]), "%,", false)
865
+ .appendXtra("", bv[2], _parseChange(ev[2], bv[2]), (hasAlpha ? "%," : "%" + str), false);
866
+ } else {
867
+ pt.appendXtra((hasAlpha ? "rgba(" : "rgb("), bv[0], ev[0] - bv[0], ",", true, true)
868
+ .appendXtra("", bv[1], ev[1] - bv[1], ",", true)
869
+ .appendXtra("", bv[2], ev[2] - bv[2], (hasAlpha ? "," : str), true);
870
+ }
871
+
872
+ if (hasAlpha) {
807
873
  bv = (bv.length < 4) ? 1 : bv[3];
808
874
  pt.appendXtra("", bv, ((ev.length < 4) ? 1 : ev[3]) - bv, str, false);
809
875
  }
810
876
  }
877
+ _colorExp.lastIndex = 0; //otherwise the test() on the RegExp could move the lastIndex and taint future results.
811
878
 
812
879
  } else {
813
880
  bnums = bv.match(_numExp); //gets each group of numbers in the beginning value string and drops them into an array
@@ -1681,14 +1748,22 @@ var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(globa
1681
1748
  if (cssp._lastParsedTransform === vars) { return pt; } //only need to parse the transform once, and only if the browser supports it.
1682
1749
  cssp._lastParsedTransform = vars;
1683
1750
  var originalGSTransform = t._gsTransform,
1684
- m1 = cssp._transform = _getTransform(t, _cs, true, vars.parseTransform),
1685
1751
  style = t.style,
1686
1752
  min = 0.000001,
1687
1753
  i = _transformProps.length,
1688
1754
  v = vars,
1689
1755
  endRotations = {},
1690
1756
  transformOriginString = "transformOrigin",
1691
- m2, skewY, copy, orig, has3D, hasChange, dr, x, y;
1757
+ m1, m2, skewY, copy, orig, has3D, hasChange, dr, x, y;
1758
+ if (vars.display) { //if the user is setting display during this tween, it may not be instantiated yet but we must force it here in order to get accurate readings. If display is "none", some browsers refuse to report the transform properties correctly.
1759
+ copy = _getStyle(t, "display");
1760
+ style.display = "block";
1761
+ m1 = _getTransform(t, _cs, true, vars.parseTransform);
1762
+ style.display = copy;
1763
+ } else {
1764
+ m1 = _getTransform(t, _cs, true, vars.parseTransform);
1765
+ }
1766
+ cssp._transform = m1;
1692
1767
  if (typeof(v.transform) === "string" && _transformProp) { //for values like transform:"rotate(60deg) scale(0.5, 0.8)"
1693
1768
  copy = _tempDiv.style; //don't use the original target because it might be SVG in which case some browsers don't report computed style correctly.
1694
1769
  copy[_transformProp] = v.transform;
@@ -1697,6 +1772,9 @@ var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(globa
1697
1772
  _doc.body.appendChild(_tempDiv);
1698
1773
  m2 = _getTransform(_tempDiv, null, false);
1699
1774
  _doc.body.removeChild(_tempDiv);
1775
+ if (!m2.perspective) {
1776
+ m2.perspective = m1.perspective; //tweening to no perspective gives very unintuitive results - just keep the same perspective in that case.
1777
+ }
1700
1778
  if (v.xPercent != null) {
1701
1779
  m2.xPercent = _parseVal(v.xPercent, m1.xPercent);
1702
1780
  }
@@ -2294,8 +2372,8 @@ var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(globa
2294
2372
  bs = bn + "%";
2295
2373
  }
2296
2374
 
2297
- } else if (esfx === "em") {
2298
- bn /= _convertToPixels(target, p, 1, "em");
2375
+ } else if (esfx === "em" || esfx === "rem") {
2376
+ bn /= _convertToPixels(target, p, 1, esfx);
2299
2377
 
2300
2378
  //otherwise convert to pixels.
2301
2379
  } else if (esfx !== "px") {
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * VERSION: beta 1.3.0
3
- * DATE: 2015-02-06
2
+ * VERSION: beta 1.4.0
3
+ * DATE: 2015-09-03
4
4
  * UPDATES AND DOCS AT: http://greensock.com
5
5
  *
6
6
  * @license Copyright (c) 2008-2015, GreenSock. All rights reserved.
@@ -15,6 +15,7 @@ var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(globa
15
15
  "use strict";
16
16
 
17
17
  var _numExp = /(\d|\.)+/g,
18
+ _relNumExp = /(?:\d|\-\d|\.\d|\-\.\d|\+=\d|\-=\d|\+=.\d|\-=\.\d)+/g,
18
19
  _colorLookup = {aqua:[0,255,255],
19
20
  lime:[0,255,0],
20
21
  silver:[192,192,192],
@@ -39,88 +40,185 @@ var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(globa
39
40
  h = (h < 0) ? h + 1 : (h > 1) ? h - 1 : h;
40
41
  return ((((h * 6 < 1) ? m1 + (m2 - m1) * h * 6 : (h < 0.5) ? m2 : (h * 3 < 2) ? m1 + (m2 - m1) * (2 / 3 - h) * 6 : m1) * 255) + 0.5) | 0;
41
42
  },
42
- _parseColor = function(color) {
43
- if (color === "" || color == null || color === "none") {
44
- return _colorLookup.transparent;
45
- }
46
- if (_colorLookup[color]) {
47
- return _colorLookup[color];
48
- }
49
- if (typeof(color) === "number") {
50
- return [color >> 16, (color >> 8) & 255, color & 255];
43
+ /**
44
+ * @private Parses a color (like #9F0, #FF9900, rgb(255,51,153) or hsl(108, 50%, 10%)) into an array with 3 elements for red, green, and blue or if toHSL parameter is true, it will populate the array with hue, saturation, and lightness values. If a relative value is found in an hsl() or hsla() string, it will preserve those relative prefixes and all the values in the array will be strings instead of numbers (in all other cases it will be populated with numbers).
45
+ * @param {(string|number)} v The value the should be parsed which could be a string like #9F0 or rgb(255,102,51) or rgba(255,0,0,0.5) or it could be a number like 0xFF00CC or even a named color like red, blue, purple, etc.
46
+ * @param {(boolean)} toHSL If true, an hsl() or hsla() value will be returned instead of rgb() or rgba()
47
+ * @return {Array.<number>} An array containing red, green, and blue (and optionally alpha) in that order, or if the toHSL parameter was true, the array will contain hue, saturation and lightness (and optionally alpha) in that order. Always numbers unless there's a relative prefix found in an hsl() or hsla() string and toHSL is true.
48
+ */
49
+ _parseColor = function(v, toHSL) {
50
+ var a, r, g, b, h, s, l, max, min, d, wasHSL;
51
+ if (!v) {
52
+ a = _colorLookup.black;
53
+ } else if (typeof(v) === "number") {
54
+ a = [v >> 16, (v >> 8) & 255, v & 255];
55
+ } else {
56
+ if (v.charAt(v.length - 1) === ",") { //sometimes a trailing comma is included and we should chop it off (typically from a comma-delimited list of values like a textShadow:"2px 2px 2px blue, 5px 5px 5px rgb(255,0,0)" - in this example "blue," has a trailing comma. We could strip it out inside parseComplex() but we'd need to do it to the beginning and ending values plus it wouldn't provide protection from other potential scenarios like if the user passes in a similar value.
57
+ v = v.substr(0, v.length - 1);
58
+ }
59
+ if (_colorLookup[v]) {
60
+ a = _colorLookup[v];
61
+ } else if (v.charAt(0) === "#") {
62
+ if (v.length === 4) { //for shorthand like #9F0
63
+ r = v.charAt(1);
64
+ g = v.charAt(2);
65
+ b = v.charAt(3);
66
+ v = "#" + r + r + g + g + b + b;
67
+ }
68
+ v = parseInt(v.substr(1), 16);
69
+ a = [v >> 16, (v >> 8) & 255, v & 255];
70
+ } else if (v.substr(0, 3) === "hsl") {
71
+ a = wasHSL = v.match(_numExp);
72
+ if (!toHSL) {
73
+ h = (Number(a[0]) % 360) / 360;
74
+ s = Number(a[1]) / 100;
75
+ l = Number(a[2]) / 100;
76
+ g = (l <= 0.5) ? l * (s + 1) : l + s - l * s;
77
+ r = l * 2 - g;
78
+ if (a.length > 3) {
79
+ a[3] = Number(v[3]);
80
+ }
81
+ a[0] = _hue(h + 1 / 3, r, g);
82
+ a[1] = _hue(h, r, g);
83
+ a[2] = _hue(h - 1 / 3, r, g);
84
+ } else if (v.indexOf("=") !== -1) { //if relative values are found, just return the raw strings with the relative prefixes in place.
85
+ return v.match(_relNumExp);
86
+ }
87
+ } else {
88
+ a = v.match(_numExp) || _colorLookup.transparent;
89
+ }
90
+ a[0] = Number(a[0]);
91
+ a[1] = Number(a[1]);
92
+ a[2] = Number(a[2]);
93
+ if (a.length > 3) {
94
+ a[3] = Number(a[3]);
95
+ }
51
96
  }
52
- if (color.charAt(0) === "#") {
53
- if (color.length === 4) { //for shorthand like #9F0
54
- color = "#" + color.charAt(1) + color.charAt(1) + color.charAt(2) + color.charAt(2) + color.charAt(3) + color.charAt(3);
97
+ if (toHSL && !wasHSL) {
98
+ r = a[0] / 255;
99
+ g = a[1] / 255;
100
+ b = a[2] / 255;
101
+ max = Math.max(r, g, b);
102
+ min = Math.min(r, g, b);
103
+ l = (max + min) / 2;
104
+ if (max === min) {
105
+ h = s = 0;
106
+ } else {
107
+ d = max - min;
108
+ s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
109
+ h = (max === r) ? (g - b) / d + (g < b ? 6 : 0) : (max === g) ? (b - r) / d + 2 : (r - g) / d + 4;
110
+ h *= 60;
55
111
  }
56
- color = parseInt(color.substr(1), 16);
57
- return [color >> 16, (color >> 8) & 255, color & 255];
112
+ a[0] = (h + 0.5) | 0;
113
+ a[1] = (s * 100 + 0.5) | 0;
114
+ a[2] = (l * 100 + 0.5) | 0;
58
115
  }
59
- if (color.substr(0, 3) === "hsl") {
60
- color = color.match(_numExp);
61
- var h = (Number(color[0]) % 360) / 360,
62
- s = Number(color[1]) / 100,
63
- l = Number(color[2]) / 100,
64
- m2 = (l <= 0.5) ? l * (s + 1) : l + s - l * s,
65
- m1 = l * 2 - m2;
66
- if (color.length > 3) {
67
- color[3] = Number(color[3]);
116
+ return a;
117
+ },
118
+ _formatColors = function(s, toHSL) {
119
+ var colors = s.match(_colorExp) || [],
120
+ charIndex = 0,
121
+ parsed = colors.length ? "" : s,
122
+ i, color, temp;
123
+ for (i = 0; i < colors.length; i++) {
124
+ color = colors[i];
125
+ temp = s.substr(charIndex, s.indexOf(color, charIndex)-charIndex);
126
+ charIndex += temp.length + color.length;
127
+ color = _parseColor(color, toHSL);
128
+ if (color.length === 3) {
129
+ color.push(1);
68
130
  }
69
- color[0] = _hue(h + 1 / 3, m1, m2);
70
- color[1] = _hue(h, m1, m2);
71
- color[2] = _hue(h - 1 / 3, m1, m2);
72
- return color;
131
+ parsed += temp + (toHSL ? "hsla(" + color[0] + "," + color[1] + "%," + color[2] + "%," + color[3] : "rgba(" + color.join(",")) + ")";
73
132
  }
74
- return color.match(_numExp) || _colorLookup.transparent;
75
- };
133
+ return parsed;
134
+ }, p, _colorStringFilter,
135
+ TweenLite = _gsScope.TweenLite,
136
+ _colorExp = "(?:\\b(?:(?:rgb|rgba|hsl|hsla)\\(.+?\\))|\\B#.+?\\b", //we'll dynamically build this Regular Expression to conserve file size. After building it, it will be able to find rgb(), rgba(), # (hexadecimal), and named color values like red, blue, purple, etc.
137
+
76
138
 
77
- _gsScope._gsDefine.plugin({
78
- propName: "colorProps",
79
- version: "1.3.0",
80
- priority: -1,
81
- API: 2,
82
139
 
83
- //called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run.
84
- init: function(target, value, tween) {
85
- this._target = target;
86
- var p, s, c, pt;
87
- this.numFormat = (value.format === "number");
88
- for (p in value) {
89
- if (p !== "format") {
90
- c = _parseColor(value[p]);
91
- this._firstPT = pt = {_next:this._firstPT, p:p, f:(typeof(target[p]) === "function"), n:p, r:false};
92
- s = _parseColor( (!pt.f) ? target[p] : target[ ((p.indexOf("set") || typeof(target["get" + p.substr(3)]) !== "function") ? p : "get" + p.substr(3)) ]() );
93
- pt.s = Number(s[0]);
94
- pt.c = Number(c[0]) - pt.s;
95
- pt.gs = Number(s[1]);
96
- pt.gc = Number(c[1]) - pt.gs;
97
- pt.bs = Number(s[2]);
98
- pt.bc = Number(c[2]) - pt.bs;
99
- if ((pt.rgba = (s.length > 3 || c.length > 3))) { //detect an rgba() value
100
- pt.as = (s.length < 4) ? 1 : Number(s[3]);
101
- pt.ac = ((c.length < 4) ? 1 : Number(c[3])) - pt.as;
140
+ ColorPropsPlugin = _gsScope._gsDefine.plugin({
141
+ propName: "colorProps",
142
+ version: "1.4.0",
143
+ priority: -1,
144
+ API: 2,
145
+ global: true,
146
+
147
+ //called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run.
148
+ init: function(target, value, tween) {
149
+ var p, proxy, pt;
150
+ this._target = target;
151
+ this._proxy = proxy = ((value.format + "").toUpperCase() === "NUMBER") ? {} : 0;
152
+ for (p in value) {
153
+ if (p !== "format") {
154
+ if (proxy) {
155
+ this._firstNumPT = pt = {_next:this._firstNumPT, t:target, p:p, f:(typeof(target[p]) === "function")};
156
+ proxy[p] = !pt.f ? target[p] : target[ ((p.indexOf("set") || typeof(target["get" + p.substr(3)]) !== "function") ? p : "get" + p.substr(3)) ]();
157
+ }
158
+ this._addTween(proxy || target, p, "get", value[p], p, null, null, _colorStringFilter);
102
159
  }
103
- if (pt._next) {
104
- pt._next._prev = pt;
160
+ }
161
+ return true;
162
+ },
163
+
164
+ //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.)
165
+ set: function(v) {
166
+ var pt = this._firstNumPT,
167
+ val;
168
+ this._super.setRatio.call(this, v);
169
+ while (pt) {
170
+ val = _parseColor(this._proxy[pt.p], false);
171
+ val = val[0] << 16 | val[1] << 8 | val[2];
172
+ if (pt.f) {
173
+ this._target[pt.p](val);
174
+ } else {
175
+ this._target[pt.p] = val;
105
176
  }
177
+ pt = pt._next;
106
178
  }
107
179
  }
108
- return true;
109
- },
180
+ });
110
181
 
111
- //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.)
112
- set: function(v) {
113
- var pt = this._firstPT, val;
114
- while (pt) {
115
- val = this.numFormat ? (pt.s + (v * pt.c)) << 16 | (pt.gs + (v * pt.gc)) << 8 | (pt.bs + (v * pt.bc)) : (pt.rgba ? "rgba(" : "rgb(") + ((pt.s + (v * pt.c)) >> 0) + ", " + ((pt.gs + (v * pt.gc)) >> 0) + ", " + ((pt.bs + (v * pt.bc)) >> 0) + (pt.rgba ? ", " + (pt.as + (v * pt.ac)) : "") + ")";
116
- if (pt.f) {
117
- this._target[pt.p](val);
118
- } else {
119
- this._target[pt.p] = val;
182
+ for (p in _colorLookup) {
183
+ _colorExp += "|" + p + "\\b";
184
+ }
185
+ _colorExp = new RegExp(_colorExp+")", "gi");
186
+
187
+ ColorPropsPlugin.colorStringFilter = _colorStringFilter = function(a) {
188
+ var combined = a[0] + a[1],
189
+ toHSL;
190
+ _colorExp.lastIndex = 0;
191
+ if (_colorExp.test(combined)) {
192
+ toHSL = (combined.indexOf("hsl(") !== -1 || combined.indexOf("hsla(") !== -1);
193
+ a[0] = _formatColors(a[0], toHSL);
194
+ a[1] = _formatColors(a[1], toHSL);
195
+ }
196
+ };
197
+
198
+ if (!TweenLite.defaultStringFilter) {
199
+ TweenLite.defaultStringFilter = ColorPropsPlugin.colorStringFilter;
200
+ }
201
+
202
+ ColorPropsPlugin.parseColor = _parseColor;
203
+ p = ColorPropsPlugin.prototype;
204
+ p._firstNumPT = null;
205
+ p._kill = function(lookup) {
206
+ var pt = this._firstNumPT,
207
+ prev;
208
+ while (pt) {
209
+ if (pt.p in lookup) {
210
+ if (pt === p._firstNumPT) {
211
+ this._firstNumPT = pt._next;
212
+ }
213
+ if (prev) {
214
+ prev._next = pt._next;
120
215
  }
121
- pt = pt._next;
216
+ } else {
217
+ prev = pt;
122
218
  }
219
+ pt = pt._next;
123
220
  }
124
- });
221
+ return this._super._kill(lookup);
222
+ };
125
223
 
126
224
  }); if (_gsScope._gsDefine) { _gsScope._gsQueue.pop()(); }