v-in-viewport

judge el is in viewport (carry out once)

Usage no npm install needed!

<script type="module">
  import vInViewport from 'https://cdn.skypack.dev/v-in-viewport';
</script>

README

INSTALL

npm i -S v-in-viewport

USAGE

<div v-in-viewport="log_one"></div>
<!-- fn is your function name -->
<div v-in-viewport="{ fn: log_two, npm: 'InViewport', delay: 1000, msg: 'a message' }"></div>
<script>
import InViewport from 'v-in-viewport'
new Vue({
    directives: {
        InViewport
    },
    methods: {
        log_one () {
            console.log('span is in view port now')
        },
        // delay 1000ms
        log_two ({ npm, msg }) {
            console.log(npm, msg)
        }
    }
})
</script>