wangweiwei / vue-resize-observer

Vue Resize Observer
MIT License
61 stars 9 forks source link

Throttle config option #7

Open alexcroox opened 3 years ago

alexcroox commented 3 years ago

When using this plugin I have to wrap my functions in the same throttle code every time to stop them firing too often:

import throttle from 'lodash.throttle'

methods: {
    onResize: throttle(
      function ({ width, height }) {
        // Logic
      },
      1000,
      { trailing: true }
    )
  }

It would be great if this could be part of the initial config (optionally of course)

Vue.use(VueResizeObserver, {
 throttle: {
   waitMs: 1000,
   trailing: true
  }
})

More config options: https://lodash.com/docs/4.17.15#throttle