Advertisement
afsarwebdev

Scroll Bottom Y Handeler Function

Sep 3rd, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Window scroll spy box show after scrolling in footer right</title>
  6. <style media="screen">
  7. body {background: lime;}
  8. h1 {font-size: 40px; text-align: center; margin: 30px;}
  9. p {font-size: 20px; text-align: center;}
  10. #spybox {position: fixed;bottom: 0px; right: -352px;width: 300px; height: 200px;background: #ddd;padding: 25px;
  11. font-size: 30px;}
  12. .bodyContent {height: 1600px;}
  13. </style>
  14. <script type="text/javascript">
  15. function yScrollHandler() {
  16. var win = document.getElementById("spybox");
  17. if((window.pageYOffset + window.innerHeight) >= document.body.offsetHeight){
  18. win.style.right = "0px";
  19. win.style.webkitTransition = "right 0.7s ease-in-out 0s";
  20. win.style.transition = "right 0.7s ease-in-out 0s";
  21. }
  22. else {
  23. win.style.right = "-460px";
  24. }
  25. }
  26. window.onscroll = yScrollHandler;
  27. </script>
  28. </head>
  29. <body>
  30. <div class="bodyContent">
  31. <h1>Scroll Bottom Y Handeler Function</h1>
  32. <p>
  33. Scroll to the bottom of the page to use a spy box effect
  34. </p>
  35. </div>
  36. <div id="spybox">Write your content here</div>
  37. </body>
  38. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement