circular_motion.html 972 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
  5. <title>Creating a circular motion (easing === awesome)</title>
  6. <link href="fixed-positioning.css" rel="stylesheet" type="text/css" />
  7. <style type="text/css">
  8. #thing {
  9. width:32px;
  10. height:32px;
  11. border-radius:16px;
  12. background:#000;
  13. }
  14. </style>
  15. </head>
  16. <body>
  17. <div id="thing" data-0="left[cos]:10%;top[sin]:10%;" data-10000="left:90%;top:90%;"></div>
  18. <script type="text/javascript" src="../dist/skrollr.min.js"></script>
  19. <script type="text/javascript">
  20. skrollr.init({
  21. easing: {
  22. sin: function(p) {
  23. return (Math.sin(p * Math.PI * 2 - Math.PI/2) + 1) / 2;
  24. },
  25. cos: function(p) {
  26. return (Math.cos(p * Math.PI * 2 - Math.PI/2) + 1) / 2;
  27. },
  28. },
  29. render: function(data) {
  30. //Loop
  31. if(data.curTop === data.maxTop) {
  32. this.setScrollTop(0, true);
  33. }
  34. }
  35. });
  36. </script>
  37. </body>
  38. </html>