# **元理分析**
****
~~~
$(function () {
var winH = $(window).height();
$('div').each(function () {
$(this).css({visibility: 'hidden'})//讓每一個元素都隱藏
this.xy = $(this).attr('class')//獲取每一個元素的類名并且添加到dom對象的xy屬性上
$(this).removeClass()//移除所有類名,作用就是清掉元素的運動狀態。
});
$(window).scroll(function () {
var winT = $(window).scrollTop();
$('div').each(function () {
var divT = $(this).offset().top;
if (winH + winT - divT > 100 && divT > winT) {
$('div').css({visibility: ''})
$(this).addClass('animated ' + this.xy)
}
})
})
$(window).trigger('scroll')
})
~~~