sb2014

Untitled

Sep 18th, 2018
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. WhatAnimation('fadescroll');
  2. WhatAnimation('moveleft');
  3.  
  4. $(window).scroll(function(){
  5. WhatAnimation('fadescroll');
  6. WhatAnimation('moveleft');
  7. });
  8.  
  9. function WhatAnimation(name){
  10. $('.' + name).each(function(){
  11. switch (name) {
  12. case 'fadescroll': AddClass(this, 'fade');
  13. break;
  14. case 'moveleft': AddClass(this, 'left');
  15. break;
  16. }
  17. });
  18. };
  19.  
  20. function AddClass(objekt, name) {
  21. if(IsVisible(objekt)) {
  22. $(objekt).addClass(name);
  23. }else{
  24. $(objekt).removeClass(name);
  25. }
  26. }
  27.  
  28. function IsVisible(objekt){
  29. var viewport = $(window).scrollTop() + $(window).height();
  30. var rand = $(object).offset();
  31. rand.bottom = rand.top + $(object).outerHeight();
  32. return (!(viewport < (rand.top + 250) || $(window).scrollTop() > (rand.bottom - 250)));
  33. }
Advertisement
Add Comment
Please, Sign In to add comment