Akryum / vue-observe-visibility

Detect when an element is becoming visible or hidden on the page.
https://jsfiddle.net/Akryum/ppt7endj/
1.65k stars 87 forks source link

Accept options when registering plugin to override defaults #211

Open a-kriya opened 4 years ago

a-kriya commented 4 years ago

It would reduce duplication and declutter templates if the plugin allowed overriding defaults:

import Vue from 'vue'
import VueObserveVisibility from 'vue-observe-visibility'

Vue.use(VueObserveVisibility, {
  once: true
})

If majority of my use cases require once to be set to true, then I can just do that, and if I need to set it to false occasionally, I can still do:

<div v-observe-visibility="{
  callback: visibilityChanged,
  once: false,
}">

This applies to all options, and so could also resolve #201.