v-visibility-change
Page Visibility API wrapper for vuejs.
Features
- no denpendencies
- support vue directive && global callback
- detect page visibility state
- full tests in chrome, theoretically compatible with IE > 10, Firefox > 10, Safari > 6.1
Usage
install
npm
$ npm i vue-visibility-change -S
script
可以直接使用script
标签引入
global
;; // registry directiveVue; // global modeconst handler = visibility; visibility; // Return true if page now isn’t visible to user. visibility; // Remove `change` listener by it's handler. visibility; // Return true if browser support Page Visibility API.
vue-directive
Demo
visit Demo page, open console pane
in the lower right corner, switch broswer tab to see output.
License
Copyright (c) 2017-present, xlaoyu