Skip to content

Commit 32beb87

Browse files
committed
Merge pull request #68 from alancutter/pushNewRelease
Publish version 2.2.0
2 parents 37184a9 + 72f57ca commit 32beb87

34 files changed

+637
-193
lines changed

Gruntfile.js

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -116,31 +116,33 @@ module.exports = function(grunt) {
116116
WEB_ANIMATIONS_TESTING: false
117117
};
118118

119-
function buildWebAnimations1(target) {
119+
function build(target) {
120120
var config = targetConfig[target];
121-
return genTarget(target).concat([
122-
concat(config.scopeSrc.concat(config.sharedSrc).concat(config.webAnimations1Src), 'inter-raw-' + target + '.js', concatDefines),
123-
guard('inter-raw-' + target + '.js', 'inter-' + target + '.js'),
124-
compress('inter-' + target + '.js', target + '.min.js', concatDefines)
125-
]);
126-
}
127-
128-
function buildWebAnimationsNext(target) {
129-
var config = targetConfig[target];
130-
return genTarget(target).concat([
121+
var steps = [
131122
concat(config.scopeSrc.concat(config.sharedSrc), 'inter-' + target + '-preamble.js', concatDefines),
132-
concat(config.webAnimations1Src, 'inter-component-' + target + 'web-animations-1.js', concatDefines),
133-
guard('inter-component-' + target + 'web-animations-1.js', 'inter-guarded-' + target + '-web-animations-1.js'),
134-
concat(config.webAnimationsNextSrc, 'inter-component-' + target + '.js', concatDefines),
135-
concatWithMaps(['inter-' + target + '-preamble.js', 'inter-guarded-' + target + '-web-animations-1.js', 'inter-component-' + target + '.js'],
136-
'inter-' + target + '.js'),
123+
concat(config.webAnimations1Src, 'inter-component-' + target + '-web-animations-1.js', concatDefines),
124+
guard('inter-component-' + target + '-web-animations-1.js', 'inter-guarded-' + target + '-web-animations-1.js'),
125+
concat(config.webAnimations1BonusSrc, 'inter-bonus-' + target + '.js', concatDefines),
126+
];
127+
var filenames = [
128+
'inter-' + target + '-preamble.js',
129+
'inter-guarded-' + target + '-web-animations-1.js',
130+
'inter-bonus-' + target + '.js',
131+
];
132+
if (config.webAnimationsNextSrc.length > 0) {
133+
steps.push(concat(config.webAnimationsNextSrc, 'inter-component-' + target + '.js', concatDefines));
134+
filenames.push('inter-component-' + target + '.js');
135+
}
136+
steps.push(
137+
concatWithMaps(filenames, 'inter-' + target + '.js'),
137138
compress('inter-' + target + '.js', target + '.min.js', concatDefines)
138-
]);
139+
);
140+
return genTarget(target).concat(steps);
139141
}
140142

141-
grunt.registerTask('web-animations', buildWebAnimations1('web-animations'));
142-
grunt.registerTask('web-animations-next', buildWebAnimationsNext('web-animations-next'));
143-
grunt.registerTask('web-animations-next-lite', buildWebAnimationsNext('web-animations-next-lite'));
143+
grunt.registerTask('web-animations', build('web-animations'));
144+
grunt.registerTask('web-animations-next', build('web-animations-next'));
145+
grunt.registerTask('web-animations-next-lite', build('web-animations-next-lite'));
144146

145147
var testTargets = {'web-animations': {}, 'web-animations-next': {}};
146148

History.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,31 @@
1+
### 2.2.0 - *April 6 2016*
2+
* Deprecated the use of hyphens in property names.
3+
4+
For example, this is deprecated:
5+
6+
element.animate([{'font-size': '0px'}, {'font-size': '10px'}]);
7+
8+
and this should be used instead:
9+
10+
element.animate([{fontSize: '0px'}, {fontSize: '10px'}]);
11+
12+
* Added arbitrary easing capitalisation.
13+
* Added "id" effect option. (http://w3c.github.io/web-animations/#dom-keyframeanimationoptions-id)
14+
* Added "oncancel" event handler.
15+
* Added value list keyframe syntax.
16+
17+
As as alternative to:
18+
19+
element.animate([{color: 'red'}, {color: 'green'}, {color: 'blue'}]);
20+
21+
you can now use:
22+
23+
element.animate({color: ['red', 'green', 'blue']});
24+
25+
* Fixed easing TypeError in FireFox Nightly when using groups.
26+
* Fixed delayed animation updates on Safari and Firefox
27+
* Fixed infinite recursion when setting onfinish to null.
28+
129
### 2.1.4 - *December 1 2015*
230
* Use `Date.now()` instead of `performace.now()` for mobile Safari.
331

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ effect.
5454

5555
Web Animations supports off-main-thread animations, and also allows procedural
5656
generation of animations and fine-grained control of animation playback. See
57-
<http://web-animations.github.io> for ideas and inspiration!
57+
<http://web-animations.github.io> for ideas and inspiration - or [web-animations-codelabs](https://github.com/web-animations/web-animations-codelabs).
5858

5959
Native Fallback
6060
---------------

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"type": "git",
66
"url": "https://github.com/web-animations/web-animations-js.git"
77
},
8-
"version": "2.1.4",
8+
"version": "2.2.0",
99
"keywords": [
1010
"animations",
1111
"polyfill"

src/animation.js

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,17 @@
3131
};
3232

3333
scope.Animation = function(effect) {
34+
this.id = '';
35+
if (effect && effect._id) {
36+
this.id = effect._id;
37+
}
3438
this._sequenceNumber = shared.sequenceNumber++;
3539
this._currentTime = 0;
3640
this._startTime = null;
3741
this._paused = false;
3842
this._playbackRate = 1;
3943
this._inTimeline = true;
40-
this._finishedFlag = false;
44+
this._finishedFlag = true;
4145
this.onfinish = null;
4246
this._finishHandlers = [];
4347
this._effect = effect;
@@ -139,12 +143,11 @@
139143
if (this._isFinished || this._idle) {
140144
this._currentTime = this._playbackRate > 0 ? 0 : this._totalDuration;
141145
this._startTime = null;
142-
scope.invalidateEffects();
143146
}
144147
this._finishedFlag = false;
145-
scope.restart();
146148
this._idle = false;
147149
this._ensureAlive();
150+
scope.invalidateEffects();
148151
},
149152
pause: function() {
150153
if (!this._isFinished && !this._paused && !this._idle) {
@@ -159,22 +162,20 @@
159162
this.currentTime = this._playbackRate > 0 ? this._totalDuration : 0;
160163
this._startTime = this._totalDuration - this.currentTime;
161164
this._currentTimePending = false;
165+
scope.invalidateEffects();
162166
},
163167
cancel: function() {
164168
if (!this._inEffect)
165169
return;
166170
this._inEffect = false;
167171
this._idle = true;
172+
this._finishedFlag = true;
168173
this.currentTime = 0;
169174
this._startTime = null;
170175
this._effect._update(null);
171176
// effects are invalid after cancellation as the animation state
172177
// needs to un-apply.
173178
scope.invalidateEffects();
174-
// in the absence of effect revalidation via getComputedStyle, we
175-
// need a single tick to remove the effect of the cancelled
176-
// animation.
177-
scope.restart();
178179
},
179180
reverse: function() {
180181
this.playbackRate *= -1;
@@ -192,29 +193,39 @@
192193
this._finishHandlers.splice(index, 1);
193194
},
194195
_fireEvents: function(baseTime) {
195-
var finished = this._isFinished;
196-
if ((finished || this._idle) && !this._finishedFlag) {
197-
var event = new AnimationEvent(this, this._currentTime, baseTime);
198-
var handlers = this._finishHandlers.concat(this.onfinish ? [this.onfinish] : []);
199-
setTimeout(function() {
200-
handlers.forEach(function(handler) {
201-
handler.call(event.target, event);
202-
});
203-
}, 0);
196+
if (this._isFinished) {
197+
if (!this._finishedFlag) {
198+
var event = new AnimationEvent(this, this._currentTime, baseTime);
199+
var handlers = this._finishHandlers.concat(this.onfinish ? [this.onfinish] : []);
200+
setTimeout(function() {
201+
handlers.forEach(function(handler) {
202+
handler.call(event.target, event);
203+
});
204+
}, 0);
205+
this._finishedFlag = true;
206+
}
207+
} else {
208+
this._finishedFlag = false;
204209
}
205-
this._finishedFlag = finished;
206210
},
207-
_tick: function(timelineTime) {
211+
_tick: function(timelineTime, isAnimationFrame) {
208212
if (!this._idle && !this._paused) {
209-
if (this._startTime == null)
210-
this.startTime = timelineTime - this._currentTime / this.playbackRate;
211-
else if (!this._isFinished)
213+
if (this._startTime == null) {
214+
if (isAnimationFrame) {
215+
this.startTime = timelineTime - this._currentTime / this.playbackRate;
216+
}
217+
} else if (!this._isFinished) {
212218
this._tickCurrentTime((timelineTime - this._startTime) * this.playbackRate);
219+
}
213220
}
214221

215-
this._currentTimePending = false;
216-
this._fireEvents(timelineTime);
217-
return !this._idle && (this._inEffect || !this._finishedFlag);
222+
if (isAnimationFrame) {
223+
this._currentTimePending = false;
224+
this._fireEvents(timelineTime);
225+
}
226+
},
227+
get _needsTick() {
228+
return (this.playState in {'pending': 1, 'running': 1}) || !this._finishedFlag;
218229
},
219230
};
220231

src/element-animatable.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313
// limitations under the License.
1414

1515
(function(scope) {
16-
window.Element.prototype.animate = function(effectInput, timingInput) {
17-
return scope.timeline._play(scope.KeyframeEffect(this, effectInput, timingInput));
16+
window.Element.prototype.animate = function(effectInput, options) {
17+
var id = '';
18+
if (options && options.id) {
19+
id = options.id;
20+
}
21+
return scope.timeline._play(scope.KeyframeEffect(this, effectInput, options, id));
1822
};
1923
})(webAnimations1);

src/group-constructors.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
return node._timing.delay + node.activeDuration + node._timing.endDelay;
1919
}
2020

21-
function constructor(children, timingInput) {
21+
function constructor(children, timingInput, id) {
22+
this._id = id;
2223
this._parent = null;
2324
this.children = children || [];
2425
this._reparent(this.children);
@@ -184,7 +185,7 @@
184185
}
185186
};
186187

187-
var underlyingEffect = new KeyframeEffect(null, [], group._timing);
188+
var underlyingEffect = new KeyframeEffect(null, [], group._timing, group._id);
188189
underlyingEffect.onsample = ticker;
189190
underlyingAnimation = scope.timeline._play(underlyingEffect);
190191
return underlyingAnimation;

src/keyframe-effect-constructor.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
this._frames = shared.normalizeKeyframes(effectInput);
5454
}
5555

56-
scope.KeyframeEffect = function(target, effectInput, timingInput) {
56+
scope.KeyframeEffect = function(target, effectInput, timingInput, id) {
5757
this.target = target;
5858
this._parent = null;
5959

@@ -71,6 +71,7 @@
7171
}
7272
this._keyframes = effectInput;
7373
this.activeDuration = shared.calculateActiveDuration(this._timing);
74+
this._id = id;
7475
return this;
7576
};
7677

@@ -96,7 +97,7 @@
9697
if (typeof this.getFrames() == 'function') {
9798
throw new Error('Cloning custom effects is not supported.');
9899
}
99-
var clone = new KeyframeEffect(this.target, [], shared.cloneTimingInput(this._timingInput));
100+
var clone = new KeyframeEffect(this.target, [], shared.cloneTimingInput(this._timingInput), this._id);
100101
clone._normalizedKeyframes = this._normalizedKeyframes;
101102
clone._keyframes = this._keyframes;
102103
return clone;
@@ -107,8 +108,12 @@
107108
};
108109

109110
var originalElementAnimate = Element.prototype.animate;
110-
Element.prototype.animate = function(effectInput, timing) {
111-
return scope.timeline._play(new scope.KeyframeEffect(this, effectInput, timing));
111+
Element.prototype.animate = function(effectInput, options) {
112+
var id = '';
113+
if (options && options.id) {
114+
id = options.id;
115+
}
116+
return scope.timeline._play(new scope.KeyframeEffect(this, effectInput, options, id));
112117
};
113118

114119
var nullTarget = document.createElementNS('http://www.w3.org/1999/xhtml', 'div');
@@ -119,13 +124,14 @@
119124
if (typeof keyframes == 'function') {
120125
keyframes = [];
121126
}
122-
var timing = keyframeEffect._timingInput;
127+
var options = keyframeEffect._timingInput;
128+
options.id = keyframeEffect._id;
123129
} else {
124130
var target = nullTarget;
125131
var keyframes = [];
126-
var timing = 0;
132+
var options = 0;
127133
}
128-
return originalElementAnimate.apply(target, [keyframes, timing]);
134+
return originalElementAnimate.apply(target, [keyframes, options]);
129135
};
130136

131137
// TODO: Remove this once we remove support for custom KeyframeEffects.

src/keyframe-effect.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
return effectTime;
2929
}
3030

31-
scope.KeyframeEffect = function(target, effectInput, timingInput) {
31+
scope.KeyframeEffect = function(target, effectInput, timingInput, id) {
3232
var effectTime = EffectTime(shared.normalizeTimingInput(timingInput));
3333
var interpolations = scope.convertEffectInput(effectInput);
3434
var timeFraction;
@@ -49,6 +49,7 @@
4949
};
5050
keyframeEffect._isCurrent = effectTime._isCurrent;
5151
keyframeEffect._totalDuration = effectTime._totalDuration;
52+
keyframeEffect._id = id;
5253
return keyframeEffect;
5354
};
5455

src/keyframe-interpolations.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,13 @@
7373
function makeInterpolations(propertySpecificKeyframeGroups) {
7474
var interpolations = [];
7575
for (var groupName in propertySpecificKeyframeGroups) {
76-
var group = propertySpecificKeyframeGroups[groupName];
77-
for (var i = 0; i < group.length - 1; i++) {
78-
var startTime = group[i].offset;
79-
var endTime = group[i + 1].offset;
80-
var startValue = group[i].value;
81-
var endValue = group[i + 1].value;
76+
var keyframes = propertySpecificKeyframeGroups[groupName];
77+
for (var i = 0; i < keyframes.length - 1; i++) {
78+
var startTime = keyframes[i].offset;
79+
var endTime = keyframes[i + 1].offset;
80+
var startValue = keyframes[i].value;
81+
var endValue = keyframes[i + 1].value;
82+
var easing = keyframes[i].easing;
8283
if (startTime == endTime) {
8384
if (endTime == 1) {
8485
startValue = endValue;
@@ -89,7 +90,7 @@
8990
interpolations.push({
9091
startTime: startTime,
9192
endTime: endTime,
92-
easing: group[i].easing,
93+
easing: shared.toTimingFunction(easing ? easing : 'linear'),
9394
property: groupName,
9495
interpolation: scope.propertyInterpolation(groupName, startValue, endValue)
9596
});

0 commit comments

Comments
 (0)