使用jQuery,我尝试根据屏幕大小有条件地加载Magellan sticky nav plugin of the Foundation framework:
window width > 640px ==>使用指定选项加载麦哲伦
window width < 640px ==>关闭麦哲伦
调整大小事件似乎会触发,但插件似乎没有off选项。
我得到了以下JS:
$(document).ready(function() {
/* foundation magellan scroller*/
function checkWidth() {
var $windowSize = $(window).width();
if ( $windowSize > 640 ) {
$(document).foundation({
"magellan-expedition": {
active_class: 'active', // specify the class used for active sections
threshold: 0, // how many pixels until the magellan bar sticks, 0 = auto
destination_threshold: 50, // pixels from the top of destination for it to be considered active
throttle_delay: 50, // calSculation throttling to increase framerate
fixed_top: 75, // top distance in pixels assigend to the fixed element on scroll
offset_by_height: true // whether to offset the destination by the expedition height. Usually you want this to be true, unless your expedition is on the side.
}
});
} else {
$(document).foundation('magellan', 'off');
}
}
// Execute on load
checkWidth();
// Bind event listener
$(window).resize(checkWidth);
});发布于 2015-04-23 01:42:30
您没有html标记,但是您可以通过删除data属性来删除或关闭麦哲伦粘性标记
如果您的html如下所示
在您的else语句中删除att.
else {
$(".navi-f").removeAttr("data-magellan-expedition");
}这样就像关闭插件一样
https://stackoverflow.com/questions/29783895
复制相似问题