Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- WhatAnimation('fadescroll');
- WhatAnimation('moveleft');
- $(window).scroll(function(){
- WhatAnimation('fadescroll');
- WhatAnimation('moveleft');
- });
- function WhatAnimation(name){
- $('.' + name).each(function(){
- switch (name) {
- case 'fadescroll': AddClass(this, 'fade');
- break;
- case 'moveleft': AddClass(this, 'left');
- break;
- }
- });
- };
- function AddClass(objekt, name) {
- if(IsVisible(objekt)) {
- $(objekt).addClass(name);
- }else{
- $(objekt).removeClass(name);
- }
- }
- function IsVisible(objekt){
- var viewport = $(window).scrollTop() + $(window).height();
- var rand = $(object).offset();
- rand.bottom = rand.top + $(object).outerHeight();
- return (!(viewport < (rand.top + 250) || $(window).scrollTop() > (rand.bottom - 250)));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement