CH4-7滾動加入animation
//滾動animation
//先宣告程式
if ($(window).width() > 767) {
//當視窗高度到達物件時的動作
function scrollanimation(a,b){
$(a).each(function() {
// Check the location of each desired element //
var objectBottom = $(this).offset().top + $(this).outerHeight();
var windowBottom = $(window).scrollTop() + $(window).innerHeight();
if (objectBottom < windowBottom) {
$(this).addClass(b);
}
});
};
//滾動到物件高度時啟動程式
$(window).on("load",function() {
$(window).scroll(function() {
//把控制項加入陣列
//要做效果的class物件
var fadein_index=[
".aboutus h1",
".aboutus .container",
".service h1",
".service p",
".service .container",
".section_news .col-sm-3",
".section_news .col-sm-9"
];
//迴圈產出
for(i=0;i<10;i++){
scrollanimation(fadein_index[i],'animated fadeIn');
}
});
});