Advertisement
Guest User

Untitled

a guest
Apr 21st, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. <script>
  2. const triggerPosition = ".video1"; //Change to trigger loading from somewhere else
  3. const onWhat = "video"; //On which elements animation will be added
  4.  
  5.  
  6. $(window).on("load", function () { //Loading function
  7. $(".pageloader").fadeOut(300); //Fades out loader when page loaded
  8. });
  9.  
  10. $(document).ready(function () {
  11. document.documentElement.style.overflowX = 'hidden'; //Disable horizontal overflow
  12. if ($(triggerPosition).css('visibility', 'hidden') && $(triggerPosition).offset().top > 700) { //IF NOT YET LOADED...
  13. $(window).scroll(function () {
  14. let hT = $(triggerPosition).offset().top, //Calculate x where ".video1" appears
  15. hH = $(triggerPosition).outerHeight(),
  16. wH = $(window).height(),
  17. wS = $(this).scrollTop();
  18. if (wS > (hT + hH - wH)) { //IF SCROLED TO x where ".video1" appears
  19. addAnimations(onWhat);
  20. }
  21. });
  22. }
  23.  
  24. if ($(triggerPosition).css('visibility', 'hidden') && $(document).scrollTop() > 200) { //If the player have scrolled, still load
  25. addAnimations(onWhat);
  26. }
  27. });
  28.  
  29. function addAnimations(element) {
  30. $.each($(element), function (i, el) {
  31. setTimeout(function () { //Iteratively add timers to objects so they appear one by one
  32. $(el).css('visibility', 'visible'); //VISIBILITY: Hidden on each video by default, so have to remove
  33. $(el).addClass("sliding"); //ADD ANIMATION!
  34. }, 100 + (i * 100)); //Call itself and recalculate new time
  35. });
  36. }
  37.  
  38. function playSound(e) {
  39. e.target.muted = false;
  40. e.target.volume = 0.9;
  41. e.target.play();
  42. e.target.scale
  43. }
  44.  
  45. function stopSound(e) {
  46. e.target.muted = true;
  47. e.target.pause();
  48. }
  49. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement