Skip to content

Commit 5e64a27

Browse files
committed
Merge remote-tracking branch 'web-animations-next/master' into HEAD
2 parents e0da8dd + 4b3f032 commit 5e64a27

File tree

4 files changed

+32
-90
lines changed

4 files changed

+32
-90
lines changed

README.md

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,14 @@ For more details see the
2020
What is the polyfill?
2121
---------------------
2222

23-
The polyfill is a JavaScript implementation of the Web Animations API. It works
24-
on modern versions of all major browsers. For more details about browser
25-
support see <https://www.polymer-project.org/resources/compatibility.html>.
23+
The polyfill is a JavaScript implementation of the Web Animations API. It is
24+
supported on modern versions of all major browsers, including:
25+
26+
* Chrome
27+
* Firefox 27+
28+
* IE10+ (including Edge)
29+
* Safari (iOS) 7.1+
30+
* Safari (Mac) 9+
2631

2732
Getting Started
2833
---------------
@@ -31,19 +36,21 @@ Here's a simple example of an animation that scales and changes the opacity of
3136
a `<div>` over 0.5 seconds. The animation alternates producing a pulsing
3237
effect.
3338

34-
<script src="web-animations.min.js"></script>
35-
<div class="pulse" style="width:150px;">Hello world!</div>
36-
<script>
37-
var elem = document.querySelector('.pulse');
38-
var animation = elem.animate([
39-
{opacity: 0.5, transform: "scale(0.5)"},
40-
{opacity: 1.0, transform: "scale(1)"}
41-
], {
42-
direction: 'alternate',
43-
duration: 500,
44-
iterations: Infinity
45-
});
46-
</script>
39+
```html
40+
<script src="web-animations.min.js"></script>
41+
<div class="pulse" style="width:150px;">Hello world!</div>
42+
<script>
43+
var elem = document.querySelector('.pulse');
44+
var animation = elem.animate([
45+
{opacity: 0.5, transform: "scale(0.5)"},
46+
{opacity: 1.0, transform: "scale(1)"}
47+
], {
48+
direction: 'alternate',
49+
duration: 500,
50+
iterations: Infinity
51+
});
52+
</script>
53+
```
4754

4855
Web Animations supports off-main-thread animations, and also allows procedural
4956
generation of animations and fine-grained control of animation playback. See
@@ -124,11 +131,15 @@ The polyfill will automatically detect the correctly prefixed name to use when
124131
writing animated properties back to the platform. Where possible, the polyfill
125132
will only accept unprefixed versions of experimental features. For example:
126133

127-
var effect = new KeyframeEffect(elem, {"transform": "translate(100px, 100px)"}, 2000);
134+
```js
135+
var effect = new KeyframeEffect(elem, {"transform": "translate(100px, 100px)"}, 2000);
136+
```
128137

129138
will work in all browsers that implement a conforming version of transform, but
130139

131-
var effect = new KeyframeEffect(elem, {"-webkit-transform": "translate(100px, 100px)"}, 2000);
140+
```js
141+
var effect = new KeyframeEffect(elem, {"-webkit-transform": "translate(100px, 100px)"}, 2000);
142+
```
132143

133144
will not work anywhere.
134145

src/tick.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
} else {
7878
var now = function() {
7979
if (_now == undefined)
80-
_now = performance.now();
80+
_now = window.performance && performance.now ? performance.now() : Date.now();
8181
return _now;
8282
};
8383
}

test/js/effect-callback.js

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -79,74 +79,4 @@ suite('effect-callback', function() {
7979
assert.equal(callbackAnim, animation);
8080
assert.equal(callbackEffect.target, document.body);
8181
});
82-
83-
test('animations starting in the future are not in effect (old version)', function() {
84-
var fractions = [];
85-
tick(100);
86-
var animation = document.body.animate(function(fraction) { fractions.push(fraction); }, 1000);
87-
animation.startTime = 1000;
88-
tick(200);
89-
tick(1000);
90-
tick(1100);
91-
assert.deepEqual(fractions, [0, 0.1]);
92-
});
93-
94-
test('duration 0 animations get sampled at least once (old version)', function() {
95-
var timeFraction;
96-
tick(0);
97-
var animation = document.body.animate(function(t) {
98-
timeFraction = t;
99-
}, {duration: 0, fill: 'both'});
100-
tick(100);
101-
assert.equal(timeFraction, 1);
102-
assert.equal(isTicking(), false);
103-
});
104-
105-
test('animations added during custom effect callbacks get updated in the same tick (old version)', function() {
106-
var animation;
107-
var called = false;
108-
tick(0);
109-
document.body.animate(function() {
110-
animation = document.body.animate(function() {
111-
called = true;
112-
}, 1);
113-
}, 2);
114-
tick(1);
115-
assert.isTrue(animation.startTime >= 0);
116-
assert.isFalse(called);
117-
});
118-
119-
test('custom effect should be called after cancel (old version)', function() {
120-
var fractions = [];
121-
var animation = document.body.animate(function(fraction) { fractions.push(fraction); }, 1000);
122-
tick(0);
123-
tick(500);
124-
animation.cancel();
125-
tick(501);
126-
assert.deepEqual(fractions, [0, 0.5, null]);
127-
});
128-
129-
test('element.animate is given effect (old version)', function() {
130-
var callbackAnim;
131-
var animation = document.body.animate(function(t, target, a) {
132-
callbackAnim = a;
133-
}, 100);
134-
tick(50);
135-
tick(150);
136-
assert.equal(isTicking(), false);
137-
assert(callbackAnim, 'callback should be set');
138-
assert.equal(callbackAnim.target, document.body);
139-
});
140-
141-
test('custom callback on effect is given source effect (old version)', function() {
142-
var callbackAnim;
143-
var effect = new KeyframeEffect(document.body, function(t, target, a) {
144-
callbackAnim = a;
145-
}, 1000);
146-
var animation = document.timeline.play(effect);
147-
tick(50);
148-
tick(550);
149-
assert.equal(animation.currentTime, 500);
150-
assert.equal(callbackAnim, effect);
151-
});
15282
});

test/js/keyframe-effect-constructor.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ suite('keyframe-effect-constructor', function() {
127127
test('Remove custom effect from directly associated animation', function() {
128128
var target = document.createElement('div');
129129
document.body.appendChild(target);
130-
var custom = new KeyframeEffect(null, function(x) {target.style.opacity = x;}, 10);
130+
var custom = new KeyframeEffect(null, [], 10);
131+
custom.onsample = function(x) { target.style.opacity = x; };
131132
var animation = document.timeline.play(custom);
132133
tick(0);
133134
assert.equal(getComputedStyle(target).opacity, 0);

0 commit comments

Comments
 (0)