Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

65 строки
1.3 KiB

  1. <style>
  2. canvas {
  3. border: 1px solid #eee;
  4. }
  5. </style>
  6. <script src="../build/build.js"></script>
  7. <canvas width=500 height=400></canvas>
  8. <script>
  9. var Tween = require('tween');
  10. var raf = require('component-raf');
  11. var canvas = document.querySelector('canvas');
  12. var ctx = canvas.getContext('2d');
  13. var w = canvas.width, h = canvas.height;
  14. var tween = Tween({ x: w/2, y: 20, r: 10, a: .5 })
  15. .ease('out-bounce')
  16. .to({ x: w/2, y: h-8, r: 10, a: .5 })
  17. .duration(2000);
  18. tween.update(function(o){
  19. canvas.width = canvas.width;
  20. ctx.fillStyle = 'red';
  21. ctx.globalAlpha = o.a;
  22. ctx.arc(o.x | 0, o.y | 0, o.r, 0, Math.PI * 2, false);
  23. ctx.fill();
  24. });
  25. var n = 0;
  26. tween.on('end', function(){
  27. switch (n++) {
  28. case 0:
  29. tween
  30. .to({ x: w/2, y: 20, r: 10, a: .5 })
  31. .ease('out-sine')
  32. .duration(500);
  33. break;
  34. case 1:
  35. tween
  36. .to({ x: w/2, y: h/2, r: 10, a: .5 })
  37. .ease('in-out-back')
  38. .duration(800);
  39. break;
  40. case 2:
  41. tween
  42. .to({ x: w/2, y: h/2, r: 80, a: 1 })
  43. .ease('out-bounce')
  44. .duration(1500);
  45. break;
  46. default:
  47. animate = function(){};
  48. }
  49. });
  50. function animate() {
  51. raf(animate);
  52. tween.update();
  53. }
  54. animate();
  55. </script>