- constructor: yf.argcd(
- function (pairs) {
- Envelope.call(this, pairs, 1);
- },
- function (pairs, scale) {
- pairs = pairs || { "0": 1, "100%": 1 };
- this.ts = Object.keys(pairs);
- this.vs = yf.map.call(pairs, yf.getter, this.ts);
- this.scale = scale;
- var a = 0, b = 0;
- var unlimited = false;
- yf.each(function (t) {
- if (+t) {
- a = Math.max(+t, a);
- b = Math.min(+t, b);
- }
- unlimited = unlimited || (t[t.length - 1] === "%");
- }, this.ts);
- this.minDuration = a - b;
- this.maxDuration = (unlimited || a === b)
- ? Infinity
- : this.minDuration;
- var vMin = Math.min.apply(Math, this.vs);
- var vMax = Math.max.apply(Math, this.vs);
- this.constant = vMin === vMax && this.vs[0] * this.scale;
- }
- ),
+ constructor: function (timeline) {
+ timeline = timeline || { 0: 1 };
+ this.ts = Object.keys(timeline);
+ this.vs = yf.map.call(timeline, yf.getter, this.ts);
+ var ts = this.ts.filter(isFinite);
+ this.duration = (Math.max.apply(Math, ts)
+ - Math.min.apply(Math, ts));
+ this.unlimited = !this.duration || ts.length !== this.ts.length;
+ },
+
+ clampDuration: function (duration) {
+ return this.unlimited
+ ? Math.max(duration, this.duration)
+ : this.duration;
+ },