使用jQuery,我试图有条件地加载Magellan sticky nav plugin of the Foundation framework,具体取决于screenize:
窗口宽度> 640px ==>使用指定选项加载麦哲伦
窗口宽度< 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);
});
答案 0 :(得分:1)
您没有html标记,但可以通过删除数据属性来删除或关闭magellan粘性
如果你的HTML看起来像这样
在你的其他声明中删除att
else {
$(".navi-f").removeAttr("data-magellan-expedition");
}
这样就像关闭插件一样