将jquery-script与waypoints JS连接起来
Connect jquery-script with waypoints JS
我已经在我的网站上包含了waypoints.js脚本。现在我想把这个脚本和一些jquery连接起来。如果内容在视口中,脚本应该"启动"。
在另一个站点我使用
$('.fly-in-animation').waypoint(function() {
$(this.element).addClass('animated fadeInUp');
}, { offset: '100%' });
但是我不知道如何连接的路径点脚本与这些jquery:
$({countNum: $('#counter-laender').text()}).animate({countNum: 14}, {
duration: 2000,
easing:'linear',
step: function() {
$('#counter-laender').text(Math.floor(this.countNum));
},
complete: function() {
$('#counter-laender').text(this.countNum);
}
});
使用来自Waypoints站点的示例代码结合您提供的内容(假设您希望在#counter-laender
进入视口时发生这种情况):
$(document).ready(function() {
$('#counter-laender').waypoint(function() {
myFunction();
});
});
function myFunction() {
$({
countNum: $('#counter-laender').text()
}).animate({
countNum: 14
}, {
duration: 2000,
easing: 'linear',
step: function () {
$('#counter-laender').text(Math.floor(this.countNum));
},
complete: function () {
$('#counter-laender').text(this.countNum);
}
});
}
相关文章:
- javascript/angularjs 将 String 与 number for loop 连接起来
- 如何使用套接字将node.js与ada连接起来
- 如何将变量与问候语连接起来
- 将javascript与html连接起来(a href)
- 如何将字符串与变量连接起来/传递到链接
- Knockout JS-将函数名与数组值连接起来
- Django Template+JavaScript:如何将Django模板url与JavaScript变量连接起来
- 当附加到DOM时,可以将变量与字符串连接起来吗?它能处理逃跑吗
- 如何正确地将异步回调与react中的表单操作连接起来
- 调用一个位于字符串内部的JavaScript函数,并将params与一个变量连接起来
- GoogleMaps API:如何将geoJSON属性与信息框中的静态文本连接起来
- 如何将css文件与Grunt/Gulp/Webpack中Bower的图像和字体连接起来
- 将匿名函数中的 JavaScript 与 gulp 连接起来
- PHP 注册类与前端表单连接起来
- 如何将两个 JavaScript 对象与 JavaScript 连接起来
- 如何将 Javascript/Jquery 函数与 html 表单连接起来
- 将 requirejs 模块与构建脚本连接起来
- 将 HTML、Javascript 和 PHP 与 Sessions 连接起来
- 将数字与 opeartor 连接起来,以便在 javascript 中进行比较
- 将 D3 与 MeanJS 连接起来