diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 870a768..0000000 --- a/.editorconfig +++ /dev/null @@ -1,12 +0,0 @@ -root = true - -[*] -indent_size = 2 -charset = utf-8 -indent_style = space -end_of_line = lf -insert_final_newline = true -trim_trailing_whitespace = true - -[*.md] -indent_size = 4 diff --git a/README.md b/README.md index 2f3f856..91fdfdd 100644 --- a/README.md +++ b/README.md @@ -1,114 +1,65 @@ # vue-observer-directive -## 在线Demo - -[https://xunleif2e.github.io/vue-clickout/demo/dist/index.html](https://xunleif2e.github.io/vue-clickout/demo/dist/index.html) - -## Installation - -``` -npm i @xunlei/vue-clickout -S -``` - -## 注册指令 - -`clickout`事件是通过指令的方式实现的,因此使用前需注册指令,可以全局注册也可以局部注册。 - -### 全局注册 -```javascript -import Vue from 'vue' -import VueClickout from '@xunlei/vue-clickout' - -Vue.use(VueClickout) -``` -### 局部注册 -```html - - -``` -### 用法 +通过[`window.IntersectionObserver`](https://developer.mozilla.org/zh-CN/docs/Web/API/IntersectionObserver)判断DOM是否在视口展示,在Vue自定义指令中进行方法执行。 -```html - - - -``` -### 参数 +1. npm: +2. demo: + +### 安装 +1. node安装 + + ```bash + npm install vue-observer-directive + ``` +2. 浏览器引用 -参数 | 说明 | 类型 | -| :-- | :-- | :-- | -| exceptRefs | 要排除的Ref,默认为指令所在的DOM | Array + ```html + + ``` -## 开发命令 +### 注册指令 +1. 全局注册 -``` bash -# install deps -npm install + ```javascript + import Vue from 'vue' + import vueObserverDirective from 'vue-observer-directive' -# serve demo at localhost:8080 -npm run dev + // 全局注册 + Vue.use(vueObserverDirective) + ``` +2. 局部注册 -# build library and demo -npm run build + ```javascript + import vueObserverDirective from 'vue-observer-directive' + + export default { + directives: { + // 局部注册 + observer: vueObserverDirective.observer + } + } + ``` + +### 用法 +1. 指令名称:`v-observer` +2. 指令参数: -# build library -npm run build:library + 1. 传给指令的参数:`:数字`(数字:1~100) + 2. 修饰符:`.once` + 3. 绑定值:`{ show: 可见时方法, hide: 非可见时方法 }` -# build demo -npm run build:demo +- e.g. -# pre publish -npm run prepublish -``` + ```vue + + first -## License + + second -[MIT](http://opensource.org/licenses/MIT) + + third -Copyright (c) 2018 [greenfavo](https://github.com/greenfavo) + + four + ``` diff --git a/build/rollup.config.js b/build/rollup.config.js index 6b5291e..68b536d 100644 --- a/build/rollup.config.js +++ b/build/rollup.config.js @@ -7,7 +7,6 @@ const config = { plugins: [ babel({ ...babelrc({ - addModuleOptions: false, addExternalHelpersPlugin: false }), exclude: 'node_modules/**' @@ -18,23 +17,27 @@ const config = { ] } -export default [{ - ...config, - output: { - format: 'iife', //