You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

131 lines
4.7 KiB

5 years ago
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Smooth Scroll</title>
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <!-- stylesheets -->
  8. <style type="text/css">
  9. body {
  10. font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
  11. font-size: 112.5%;
  12. margin-left: auto;
  13. margin-right: auto;
  14. max-width: 40em;
  15. width: 88%;
  16. }
  17. </style>
  18. </head>
  19. <body>
  20. <main id="top">
  21. <nav>
  22. <h1>Smooth Scroll</h1>
  23. <p><a href="https://github.com/cferdinandi/smooth-scroll">GitHub</a></p>
  24. <hr>
  25. </nav>
  26. <section>
  27. <p>
  28. <strong>Linear</strong><br>
  29. <a data-easing="linear" href="#bazinga">Linear (no other options)</a><br>
  30. </p>
  31. <p>
  32. <strong>Ease-In</strong><br>
  33. <a data-easing="easeInQuad" href="#bazinga">Quad</a><br>
  34. <a data-easing="easeInCubic" href="#bazinga">Cubic</a><br>
  35. <a data-easing="easeInQuart" href="#bazinga">Quart</a><br>
  36. <a data-easing="easeInQuint" href="#bazinga">Quint</a>
  37. </p>
  38. <p>
  39. <strong>Ease-In-Out</strong><br>
  40. <a data-easing="easeInOutQuad" href="#bazinga">Quad</a><br>
  41. <a data-easing="easeInOutCubic" href="#bazinga">Cubic</a><br>
  42. <a data-easing="easeInOutQuart" href="#bazinga">Quart</a><br>
  43. <a data-easing="easeInOutQuint" href="#bazinga">Quint</a>
  44. </p>
  45. <p>
  46. <strong>Ease-Out</strong><br>
  47. <a data-easing="easeOutQuad" href="#bazinga">Quad</a><br>
  48. <a data-easing="easeOutCubic" href="#bazinga">Cubic</a><br>
  49. <a data-easing="easeOutQuart" href="#bazinga">Quart</a><br>
  50. <a data-easing="easeOutQuint" href="#bazinga">Quint</a>
  51. </p>
  52. <p>
  53. .<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>
  54. .<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>
  55. .<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.
  56. </p>
  57. <p>
  58. <strong>Non-ASCII Characters</strong><br>
  59. <a href="#中文">中文</a>
  60. </p>
  61. <p>
  62. .<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>
  63. .<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>
  64. .<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.
  65. </p>
  66. <p id="中文">中文</p>
  67. <p id="bazinga"><a href="#1@#%^-bottom">Bazinga!</a></p>
  68. <p>
  69. .<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>
  70. .<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>
  71. .<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.<br>.
  72. </p>
  73. <p id="1@#%^-bottom"><a href="#top">Back to the top</a></p>
  74. </section>
  75. </main>
  76. <!-- Javascript -->
  77. <script src="dist/smooth-scroll.polyfills.js"></script>
  78. <script>
  79. // Instantiate Scrolls
  80. var scroll = new SmoothScroll('a[href*="#"]:not([data-easing])');
  81. if (document.querySelector('[data-easing]')) {
  82. var linear = new SmoothScroll('[data-easing="linear"]', {easing: 'linear'});
  83. var easeInQuad = new SmoothScroll('[data-easing="easeInQuad"]', {easing: 'easeInQuad'});
  84. var easeInCubic = new SmoothScroll('[data-easing="easeInCubic"]', {easing: 'easeInCubic'});
  85. var easeInQuart = new SmoothScroll('[data-easing="easeInQuart"]', {easing: 'easeInQuart'});
  86. var easeInQuint = new SmoothScroll('[data-easing="easeInQuint"]', {easing: 'easeInQuint'});
  87. var easeInOutQuad = new SmoothScroll('[data-easing="easeInOutQuad"]', {easing: 'easeInOutQuad'});
  88. var easeInOutCubic = new SmoothScroll('[data-easing="easeInOutCubic"]', {easing: 'easeInOutCubic'});
  89. var easeInOutQuart = new SmoothScroll('[data-easing="easeInOutQuart"]', {easing: 'easeInOutQuart'});
  90. var easeInOutQuint = new SmoothScroll('[data-easing="easeInOutQuint"]', {easing: 'easeInOutQuint'});
  91. var easeOutQuad = new SmoothScroll('[data-easing="easeOutQuad"]', {easing: 'easeOutQuad'});
  92. var easeOutCubic = new SmoothScroll('[data-easing="easeOutCubic"]', {easing: 'easeOutCubic'});
  93. var easeOutQuart = new SmoothScroll('[data-easing="easeOutQuart"]', {easing: 'easeOutQuart'});
  94. var easeOutQuint = new SmoothScroll('[data-easing="easeOutQuint"]', {easing: 'easeOutQuint'});
  95. }
  96. // // Log scroll events
  97. // var logScrollEvent = function (event) {
  98. // console.log('type:', event.type);
  99. // console.log('anchor:', event.detail.anchor);
  100. // console.log('toggle:', event.detail.toggle);
  101. // };
  102. // document.addEventListener('scrollStart', logScrollEvent, false);
  103. // document.addEventListener('scrollStop', logScrollEvent, false);
  104. // document.addEventListener('scrollCancel', logScrollEvent, false);
  105. </script>
  106. </body>
  107. </html>