throttle events based on requestAnimationFrame
- Uses requestAnimationFrame
- Exposes an istance method called
$throttlein every Vue Component - Fires a CustomEvent when ready
$ 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) }- type (String): the event type
- customEventName (String): the custom event name that will be fired on next requestAnimationFrame
- targetObject (Object) [optional]: the physical EventTarget where the CustomEvent will be fired, defaults on vm.$el
functionrepresenting the real function added to thetargetObject, so you can unbind it when you want
This software uses mocha as testing framework
- Clone this repository
cd vue-throttle-eventnpm installnpm test
Feel free to contribute and ask questions