OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <meta charset=utf-8> | 2 <meta charset=utf-8> |
3 <title>Keyframe spacing tests</title> | 3 <title>Keyframe spacing tests</title> |
4 <link rel="help" href="https://w3c.github.io/web-animations/#spacing-keyframes"> | 4 <link rel="help" href="https://w3c.github.io/web-animations/#spacing-keyframes"> |
5 <script src="/resources/testharness.js"></script> | 5 <script src="/resources/testharness.js"></script> |
6 <script src="/resources/testharnessreport.js"></script> | 6 <script src="/resources/testharnessreport.js"></script> |
7 <script src="../../testcommon.js"></script> | 7 <script src="../../testcommon.js"></script> |
8 <body> | 8 <body> |
9 <div id="log"></div> | 9 <div id="log"></div> |
10 <script> | 10 <script> |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 var frames = anim.effect.getKeyframes(); | 315 var frames = anim.effect.getKeyframes(); |
316 assert_equals(frames[1].computedOffset, 0.5 * 1 / 2, | 316 assert_equals(frames[1].computedOffset, 0.5 * 1 / 2, |
317 '2nd frame offset using distribute spacing'); | 317 '2nd frame offset using distribute spacing'); |
318 assert_equals(frames[3].computedOffset, 0.5 + 0.5 * 1 / 2, | 318 assert_equals(frames[3].computedOffset, 0.5 + 0.5 * 1 / 2, |
319 '4th frame offset using distribute spacing because it is the ' + | 319 '4th frame offset using distribute spacing because it is the ' + |
320 'first paceable keyframe from a non-null offset keyframe'); | 320 'first paceable keyframe from a non-null offset keyframe'); |
321 }, 'Test paced spacing only for keyframes specifying all some components, ' + | 321 }, 'Test paced spacing only for keyframes specifying all some components, ' + |
322 'and falling back to distribute spacing for the reset with some specific ' + | 322 'and falling back to distribute spacing for the reset with some specific ' + |
323 'offsets'); | 323 'offsets'); |
324 | 324 |
325 // Tests for setting spacing by KeyframeEffect.spacing. | 325 // Bug 1276193: Test for mixing percent and pixel values. |
326 | |
327 test(function(t) { | |
328 var anim = createDiv(t).animate([ { marginLeft: '0px' }, | |
329 { marginLeft: '-20px' }, | |
330 { marginLeft: '100px' }, | |
331 { marginLeft: '50px' } ], | |
332 { duration: 100 * MS_PER_SEC }); | |
333 | |
334 anim.effect.spacing = 'paced(margin-left)'; | |
335 | |
336 var frames = anim.effect.getKeyframes(); | |
337 var cumDist = [0, 20, 140, 190]; | |
338 assert_equals(frames[0].computedOffset, 0.0, | |
339 '1st frame offset'); | |
340 assert_equals(frames[1].computedOffset, cumDist[1] / cumDist[3], | |
341 '2nd frame offset'); | |
342 assert_equals(frames[2].computedOffset, cumDist[2] / cumDist[3], | |
343 '3rd frame offset'); | |
344 assert_equals(frames[3].computedOffset, 1.0, | |
345 'last frame offset'); | |
346 }, 'Test paced spacing by setter'); | |
347 | |
348 test(function(t) { | |
349 var anim = createDiv(t).animate([ { marginLeft: '0px' }, | |
350 { marginLeft: '-20px' }, | |
351 { marginLeft: '100px' }, | |
352 { marginLeft: '50px' } ], | |
353 { duration: 100 * MS_PER_SEC, | |
354 spacing: 'paced(margin-left)' }); | |
355 | |
356 anim.effect.spacing = 'distribute'; | |
357 | |
358 var frames = anim.effect.getKeyframes(); | |
359 var slots = frames.length - 1; | |
360 assert_equals(frames[0].computedOffset, 0.0, '1st frame offset'); | |
361 assert_equals(frames[1].computedOffset, 1.0 / slots, '2nd frame offset'); | |
362 assert_equals(frames[2].computedOffset, 2.0 / slots, '3rd frame offset'); | |
363 assert_equals(frames[3].computedOffset, 1.0, 'last frame offset'); | |
364 }, 'Test distribute spacing by setter'); | |
365 | |
366 test(function(t) { | |
367 var anim = | |
368 createDiv(t).animate([ { marginLeft: '0px', borderRadius: '0%' }, | |
369 { marginLeft: '-20px', borderRadius: '50%' }, | |
370 { marginLeft: '100px', borderRadius: '25%' }, | |
371 { marginLeft: '50px', borderRadius: '100%' } ], | |
372 { duration: 100 * MS_PER_SEC, | |
373 spacing: 'paced(margin-left)' }); | |
374 | |
375 anim.effect.spacing = 'paced(border-radius)'; | |
376 | |
377 var frames = anim.effect.getKeyframes(); | |
378 var cumDist = [0, 50, 50 + 25, 50 + 25 + 75]; | |
379 | |
380 assert_equals(frames[0].computedOffset, 0.0, | |
381 '1st frame offset'); | |
382 assert_equals(frames[1].computedOffset, cumDist[1] / cumDist[3], | |
383 '2nd frame offset'); | |
384 assert_equals(frames[2].computedOffset, cumDist[2] / cumDist[3], | |
385 '3rd frame offset'); | |
386 assert_equals(frames[3].computedOffset, 1.0, | |
387 'last frame offset'); | |
388 }, 'Test paced spacing by changing the paced property'); | |
389 | 326 |
390 </script> | 327 </script> |
391 </body> | 328 </body> |
OLD | NEW |