| OLD | NEW |
| (Empty) |
| 1 <!-- | |
| 2 Copyright 2012 Google Inc. All Rights Reserved. | |
| 3 | |
| 4 Licensed under the Apache License, Version 2.0 (the "License"); | |
| 5 you may not use this file except in compliance with the License. | |
| 6 You may obtain a copy of the License at | |
| 7 | |
| 8 http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 | |
| 10 Unless required by applicable law or agreed to in writing, software | |
| 11 distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 See the License for the specific language governing permissions and | |
| 14 limitations under the License. | |
| 15 --> | |
| 16 | |
| 17 <!DOCTYPE html><meta charset="UTF-8"> | |
| 18 <style> | |
| 19 canvas { | |
| 20 border: silver solid 1px; | |
| 21 padding: 5px; | |
| 22 } | |
| 23 span { | |
| 24 display: inline-block; | |
| 25 padding: 5px; | |
| 26 } | |
| 27 </style> | |
| 28 <body> | |
| 29 | |
| 30 <script src="../../web-animations.js"></script> | |
| 31 <script> | |
| 32 "use strict"; | |
| 33 | |
| 34 var size = 100; | |
| 35 var duration = 3.0 * 1000; | |
| 36 | |
| 37 function testTiming(name) { | |
| 38 var canvas = document.createElement('canvas'); | |
| 39 canvas.width = canvas.height = size; | |
| 40 var ctx = canvas.getContext('2d'); | |
| 41 ctx.strokeStyle = 'blue'; | |
| 42 ctx.beginPath(); | |
| 43 ctx.moveTo(0, size); | |
| 44 var span = document.createElement('span'); | |
| 45 span.appendChild(canvas); | |
| 46 span.appendChild(document.createElement('br')); | |
| 47 span.appendChild(document.createTextNode(name)); | |
| 48 document.body.appendChild(span); | |
| 49 return new Animation(ctx, | |
| 50 function(timeFraction, animation) { | |
| 51 var inputTimeFraction = player.currentTime / duration; | |
| 52 animation.target.lineTo(inputTimeFraction * size, size - timeFraction * si
ze); | |
| 53 animation.target.stroke(); | |
| 54 }, { | |
| 55 duration: duration, | |
| 56 easing: name, | |
| 57 }); | |
| 58 } | |
| 59 | |
| 60 // TODO: Making player global like this is is rather ugly. It would be nice if | |
| 61 // the animation or player were passed to the custom animation effect's sample | |
| 62 // function. | |
| 63 var player = document.timeline.play(new AnimationGroup([ | |
| 64 testTiming('ease'), | |
| 65 testTiming('linear'), | |
| 66 testTiming('ease-in'), | |
| 67 testTiming('ease-out'), | |
| 68 testTiming('ease-in-out'), | |
| 69 ])); | |
| 70 | |
| 71 </script> | |
| OLD | NEW |