对如何使用带有或不带有jQuery的新版Waypoints感到困惑

Confused on how to use new version of Waypoints with or without jQuery

本文关键字:Waypoints 新版 jQuery 何使用      更新时间:2023-09-26

我正在尝试使用带有或不带有jQuery的Waypoints 3,但我都无法使用。文档没有太大帮助,因为它提到了适配器和扩展,但没有说明要加载哪些适配器和扩展以及是在主waypoint.js文件之前还是之后加载它们。

我想走jQuery路线。

这是我现在拥有的。。。

<script type="text/javascript" src="js/jquery-zepto-fn-extension.js"></script>
<script type="text/javascript" src="js/jquery-waypoints-adapter.js"></script>
<script type="text/javascript" src="js/waypoints.js"></script>

在一个main.js文件中,我有。。。

var waypoints = $('p.number').waypoint(function(direction) {
    console.log("I'm 25% from the top");
}, {
    offset: '25%'
});

当然html很简单。。。

<p class="number">100</p>

这将导致以下错误。。。

jquery路点适配器.js

Uncaught TypeError: Cannot read property 'adapters' of undefined

jquery zepto fn extension.js

Uncaught TypeError: undefined is not a function 

看起来您正试图使用所有源文件来加载库。这是没有必要的。lib目录包含jQuery、Zepto的单文件构建,并且没有框架。

你在用jQuery吗?

<script src="/path/to/jquery.js"></script>
<script src="/path/to/jquery.waypoints.js"></script>

你在用Zepto吗?

<script src="/path/to/zepto.js"></script>
<script src="/path/to/zepto.waypoints.js"></script>

你是不是都没用?

<script src="/path/to/noframework.waypoints.js"></script>