62 lines
1.9 KiB
JavaScript
62 lines
1.9 KiB
JavaScript
|
export default {
|
||
|
mounted(){
|
||
|
var wow = new window.WOW(
|
||
|
{
|
||
|
boxClass: 'wow', // animated element css class (default is wow)
|
||
|
animateClass: 'animated', // animation css class (default is animated)
|
||
|
offset: 0, // distance to the element when triggering the animation (default is 0)
|
||
|
mobile: true, // trigger animations on mobile devices (default is true)
|
||
|
live: false, // act on asynchronously loaded content (default is true)
|
||
|
callback: function(box) {
|
||
|
// the callback is fired every time an animation is started
|
||
|
// the argument that is passed in is the DOM node being animated
|
||
|
},
|
||
|
scrollContainer: null // optional scroll container selector, otherwise use window
|
||
|
}
|
||
|
);
|
||
|
wow.init();
|
||
|
},
|
||
|
methods:{
|
||
|
// 一般 用在 请求接口 数据
|
||
|
// 防抖动 作用 在 滚动 resize ,scroll ,输入框内容校 监听,
|
||
|
debounce(func, wait=0) {
|
||
|
if (typeof func !== 'function') {
|
||
|
throw new TypeError('need a function arguments')
|
||
|
}
|
||
|
let timeid = null;
|
||
|
let result;
|
||
|
|
||
|
return function() {
|
||
|
let context = this;
|
||
|
let args = arguments;
|
||
|
|
||
|
if (timeid) {
|
||
|
clearTimeout(timeid);
|
||
|
}
|
||
|
timeid = setTimeout(function() {
|
||
|
result = func.apply(context, args);
|
||
|
}, wait);
|
||
|
|
||
|
return result;
|
||
|
}
|
||
|
},
|
||
|
// 一般 用在 请求接口 数据
|
||
|
// 节流 作用 在 滚动 resize ,scroll ,输入框内容校 监听,
|
||
|
throttle (func, delay) {
|
||
|
if (typeof func !== 'function') {
|
||
|
throw new TypeError('need a function arguments')
|
||
|
}
|
||
|
var prev = Date.now();
|
||
|
return function() {
|
||
|
var context = this;
|
||
|
var args = arguments;
|
||
|
var now = Date.now();
|
||
|
if (now - prev >= delay) {
|
||
|
func.apply(context, args);
|
||
|
prev = Date.now();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|