2016-08-14 88 views
0

Waypoints插件不能正常工作,直到我調整窗口的大小。我不知道爲什麼,也找不到這個問題的原因。 窗口調整大小後,所有成爲正確的。航點不能正常工作,直到窗口調整大小

這裏是我的代碼部分:

$(function)(){ 
//menu active change while scroll 
var about_us = $("section.about-us"); 
waypoints = about_us.waypoint(function(direction){ 

    console.log("about_us section"); 
    changeActiveMenu("about_us-menu"); 

    if (direction === 'down') { 
     $(".to-top").addClass("show"); 
     console.log("show-to-top"); 
    }else if (direction === 'up') { 
     $(".to-top").removeClass("show"); 
     console.log("hide-to-top"); 
    } 

},{ 
    offset: "30%" 
}); 


var building = $("section.building"); 
waypoints = building.waypoint(function(){ 
    console.log("building section"); 

    changeActiveMenu("building-menu", "service-menu"); 
},{ 
    offset: "30%" 
}); 
}); 

這裏是有問題的鏈接:http://sandbox.maximshadrin.ru/aquanomika/

回答

0

我找到了解決辦法。問題出在代碼順序上。初始化waypoint和$(html).height()參數後,我初始化滑塊,因爲height包含所有幻燈片(一個在另一個上,而不是在左側)。 所以我得出結論:「始終在代碼的底部初始化航點」