gpt4 book ai didi

jQuery.waypoint - 方向未定义

转载 作者:行者123 更新时间:2023-12-01 00:48:28 24 4
gpt4 key购买 nike

我在使用 waypoint 插件时遇到问题,就像 http://webdesign.tutsplus.com/tutorials/javascript-tutorials/create-a-sticky-navigation-header-using-jquery-waypoints/ 等许多教程一样。建议。

这是我的代码:

<script type="text/javascript">

jQuery(function() {
var nav_container = jQuery("#menu-wrapper");
var nav = jQuery("#menu");
nav_container.waypoint(function(event, direction) {

jQuery("#fixed").toggleClass('stickyfixed');
jQuery('#zweitenavigation').toggleClass('invisible');
alert(direction);
var new_height = (direction === "down") ? '92px' : '195px';
jQuery("#header").animate({'height': new_height}, 300);
},{offset:50}
);
});
</script>

问题是

direction === "down"

不会评估 true 或 false,它只是未定义。因此动画只触发一次。

有谁知道问题出在哪里吗?顺便说一句,toggleClass 工作得很好。

感谢您的帮助和最诚挚的问候斯蒂芬

最佳答案

Waypoints 2.0 版删除了 event 参数。现在只有方向。您引用的教程在链接到这个新版本的 Waypoints 时犯了一个相当大的错误,而没有更新其教程以匹配新的处理程序签名。

关于jQuery.waypoint - 方向未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14489504/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com