$(function(){ }); function hover(obj, calssname) { obj.hover(function(){ $(this).addclass(calssname); },function(){ $(this).removeclass(calssname); }) } $(window).scroll(function () { var _ismobile = false; var windowtop = $(window).scrolltop(); var windowbottom = windowtop + $(window).height(); var shownum = !_ismobile ? 4 : 16; $('.ani-view').each(function(){ var pageq1 = $(this).offset().top + $(this).height() / shownum; var pageq3 = $(this).offset().top + $(this).height() / 1; if( ( pageq1 <= windowbottom ) && ( pageq3 >= windowtop ) ){ if( $(this).hasclass("fade-in-down") ) $(this).addclass('fadeindown'); if( $(this).hasclass("fade-in-left") ) $(this).addclass('fadeinleft'); if( $(this).hasclass("fade-in-right") ) $(this).addclass('fadeinright'); }else { // if( $(this).hasclass('fadeindown') ) $(this).removeclass(' fadeindown'); // if( $(this).hasclass('fadeinleft') ) $(this).removeclass('fadeinleft'); // if( $(this).hasclass('fadeinright') ) $(this).removeclass(' fadeinright'); if( $(this).hasclass('fadeindown') ) $(this).removeclass('ani-view fade-in-down fadeindown'); if( $(this).hasclass('fadeinleft') ) $(this).removeclass('ani-view fade-in-left fadeinleft'); if( $(this).hasclass('fadeinright') ) $(this).removeclass('ani-view fade-in-right fadeinright'); } }); });