throttle events based on requestAnimationFrame
$throttle
in every Vue Component$ npm install vue-throttle-event --save-dev
import VueThrottleEvent from 'vue-throttle-event'
Vue.use(VueThrottleEvent)
methods: {
customEventHandler (e) {
// e.detail.origin is the original event object
// logic here..
}
}
created () {
this.$throttle('mousemove', 'mouse-moved-throttled')
this.$on('mouse-moved-throttled', this.customEventHandler)
}
function
representing the real function added to the targetObject
, so you can unbind it when you wantThis software uses mocha as testing framework
cd vue-throttle-event
npm install
npm test
Feel free to contribute and ask questions