File tree 1 file changed +21
-14
lines changed
1 file changed +21
-14
lines changed Original file line number Diff line number Diff line change 5
5
import { DirectiveBinding } from 'vue/types/options' ;
6
6
import PullToRefresh from 'pulltorefreshjs' ;
7
7
8
+ let counter = 1 ;
9
+
8
10
export default {
9
- bind ( el : Element , binding : DirectiveBinding ) {
11
+ inserted ( el : Element , binding : DirectiveBinding ) {
10
12
const callback = binding . value ;
11
- // 向下拉刷新列表
12
- PullToRefresh . init ( {
13
- instructionsPullToRefresh : '下拉刷新' ,
14
- instructionsReleaseToRefresh : '松开刷新' ,
15
- instructionsRefreshing : '加载中' ,
16
- passive : true ,
17
- onRefresh : ( ) => {
18
- return callback && callback ( ) ;
19
- } ,
20
- shouldPullToRefresh ( ) {
21
- return ! document . body . scrollTop && ! window . scrollY ;
22
- }
23
- } ) ;
13
+ let query = `pull_refresh_trigger_${ counter ++ } ` ;
14
+ el . classList . add ( query ) ;
15
+ query = '.' + query ;
16
+ setTimeout ( ( ) => {
17
+ PullToRefresh . init ( {
18
+ triggerElement : query ,
19
+ instructionsPullToRefresh : '下拉刷新' ,
20
+ instructionsReleaseToRefresh : '松开刷新' ,
21
+ instructionsRefreshing : '加载中' ,
22
+ passive : true ,
23
+ onRefresh : ( ) => {
24
+ return callback && callback ( ) ;
25
+ } ,
26
+ shouldPullToRefresh ( ) {
27
+ return ! document . body . scrollTop && ! window . scrollY ;
28
+ }
29
+ } ) ;
30
+ } , 0 ) ;
24
31
} ,
25
32
unbind ( ) {
26
33
PullToRefresh . destroyAll ( ) ;
You can’t perform that action at this time.
0 commit comments