Используем HTML5 History API
Рубрика: JS
Accordion-JS
https://accordion.js.org/
ПАРАЛЛАКС ЭФФЕКТ ПРИ ДВИЖЕНИИ МЫШИ
https://atuin.ru/blog/parallaks-effekt-pri-dvizhenii-myshi/
locomotive-scroll
https://locomotivemtl.github.io/locomotive-scroll/
Scroll (Horizontal) Parallax
https://codepen.io/KhaledPen/pen/YzXeXLm
Кастомный Scrollbar
Performant Custom Scrollbar JavaScript Library – SimpleBar
7 CSS-анимаций с использованием SVG + сайты применяющие эффект
Анимация пузырьков. 7 CSS-анимаций с использованием SVG + сайты применяющие эффект
Воспроизведение и остановка аудиофайла
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
let flag = 0; let myAudio = new Audio(); $(function(){ $('.videoAudio_audio_content_comment_button .button').on('click', function(){ myAudio.src = $(this).attr('data-sound'); if (flag == 0){ $(this).addClass('active'); myAudio.play(); flag = 1; console.log(myAudio); console.log(flag); } else { $('.videoAudio_audio_content_comment_button .button').removeClass('active'); myAudio.pause(); myAudio.currentTime = 0; flag = 0; console.log(myAudio); console.log(flag); } }); }); |
|
1 |
<div class="button" data-sound="https://cdn-static.namobilu.com/u/ring/f/910/102/md_dj_bleeding_love.mp3"></div> |
Производительность загрузки страницы
Вариант
|
1 2 3 4 5 6 7 8 9 10 11 |
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <title>Script at the end of page</title> </head> <body> <!-- All the HTML content here --> <script src="index.js"></script> </body> </html> |
2. Вариант
|
1 2 3 4 5 6 7 8 9 10 11 |
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <title>Script with async attribute</title> <script async src="index.js"></script> </head> <body> <!-- All the HTML content here --> </body> </html> |
3. Вариант
|
1 2 3 4 5 6 7 8 9 10 11 |
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <title>Script with defer attribute</title> <script defer src="index.js"></script> </head> <body> <!-- All the HTML content here --> </body> </html> |
JS комплексная библиотека анимации
https://github.com/christinecha/choreographer-js
Модальное окно
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> body {font-family: Arial, Helvetica, sans-serif;} /* The Modal (background) */ .modal { display: none; /* Hidden by default */ position: fixed; /* Stay in place */ z-index: 1; /* Sit on top */ padding-top: 100px; /* Location of the box */ left: 0; top: 0; width: 100%; /* Full width */ height: 100%; /* Full height */ overflow: auto; /* Enable scroll if needed */ background-color: rgb(0,0,0); /* Fallback color */ background-color: rgba(0,0,0,0.4); /* Black w/ opacity */ } /* Modal Content */ .modal-content { background-color: #fefefe; margin: auto; padding: 20px; border: 1px solid #888; width: 80%; } /* The Close Button */ .close { color: #aaaaaa; float: right; font-size: 28px; font-weight: bold; } .close:hover, .close:focus { color: #000; text-decoration: none; cursor: pointer; } </style> </head> <body> <h2>Modal Example</h2> <!-- Trigger/Open The Modal --> <button id="myBtn">Open Modal</button> <!-- The Modal --> <div id="myModal" class="modal"> <!-- Modal content --> <div class="modal-content"> <span class="close">×</span> <p>Some text in the Modal..</p> </div> </div> <script> // Get the modal var modal = document.getElementById("myModal"); // Get the button that opens the modal var btn = document.getElementById("myBtn"); // Get the <span> element that closes the modal var span = document.getElementsByClassName("close")[0]; // When the user clicks the button, open the modal btn.onclick = function() { modal.style.display = "block"; } // When the user clicks on <span> (x), close the modal span.onclick = function() { modal.style.display = "none"; } // When the user clicks anywhere outside of the modal, close it window.onclick = function(event) { if (event.target == modal) { modal.style.display = "none"; } } </script> </body> </html> |
Плавный скролл к верху страницы
|
1 2 3 4 |
$("a[href='#top']").click(function() { $("html, body").animate({ scrollTop: 0 }, "slow"); return false; }); |