Skip to content

Commit

Permalink
LoadingPlugin: add delay param (#2331)
Browse files Browse the repository at this point in the history
* 添加延迟启用loading参数delay

* 添加change文件
  • Loading branch information
Estelle00 authored and airyland committed Dec 27, 2017
1 parent 5bf23bf commit 866a763
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/plugins/loading/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { mergeOptions } from '../../libs/plugin_helper'

let $vm
let watcher

let delayTime = null
const plugin = {
install (vue, options) {
const Loading = vue.extend(LoadingComponent)
Expand All @@ -30,9 +30,15 @@ const plugin = {
val === false && options.onHide && options.onHide($vm)
})
}
$vm.show = true
delayTime = setTimeout(() => {
$vm.show = true
}, options.delay || 0)
},
hide () {
if (delayTime) {
clearTimeout(delayTime)
delayTime = null
}
$vm.show = false
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/plugins/loading/metas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ changes:
next:
zh-CN:
- '[fix] 默认插件 options 参数置为空对象,避免调用出错'
- '[enhance] 默认插件 options参数添加delay参数'
en:
- '[fix] set default plugin options to empty object'
- '[fix] set default plugin options to empty object'
- '[enhance] set default plugin options parameter add delay'

0 comments on commit 866a763

Please sign in to comment.