Udoro

Sync two sliders - JS

Nov 18th, 2022
769
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. <script>
  2.  
  3. function initSync() {
  4. initTimeout = setTimeout(syncSliders, 50);
  5. }
  6.  
  7. function syncOnResize() {
  8. resizeTimeout = setTimeout(syncSliders, 260);
  9.  
  10. }
  11.  
  12. function syncSliders() {
  13. const main = bricksData.splideInstances['47db29'],
  14. thumbnail = bricksData.splideInstances['636b7b']
  15.  
  16. if( main && thumbnail) {
  17. main.sync(thumbnail)
  18.  
  19. }
  20.  
  21. clearTimeout(initTimeout);
  22.  
  23. }
  24.  
  25.  
  26.  
  27. document.addEventListener( 'DOMContentLoaded', initSync)
  28. window.addEventListener("resize", syncOnResize)
  29.  
  30.  
  31. </script>
  32.  
Advertisement
Add Comment
Please, Sign In to add comment