1
1
<template >
2
- <div class =" mt-loadmore" >
2
+ <div class =" mt-loadmore" ref = " scroller " >
3
3
<div
4
- class =" mint -loadmore-content"
4
+ class =" wc -loadmore-content"
5
5
:class =" { 'is-dropped': topDropped || bottomDropped }"
6
6
:style =" { transform: transform }"
7
7
>
8
- <slot name =" top " >
8
+ <slot name =" header " >
9
9
<div class =" mint-loadmore-top" v-if =" topMethod" >
10
- <!-- <span class="weui-loading" v-if="topStatus === 'loading'" ></span>
11
- <span class="mint-loadmore-text">{{ topText }}</span> -->
12
10
<Header :icon-run =" iconRun" ></Header >
13
11
</div >
14
12
</slot >
15
13
<slot ></slot >
16
- <slot name =" bottom" >
17
- <div class =" mint-loadmore-bottom" v-if =" bottomMethod" >
18
- <span class =" weui-loading" v-if =" bottomStatus === 'loading'" ></span >
19
- <span class =" mint-loadmore-text" >{{ bottomText }}</span >
20
- </div >
21
- </slot >
22
14
</div >
15
+ <!-- footer -->
16
+ <slot name =" footer" >
17
+ <div
18
+ class =" mint-loadmore-bottom"
19
+ v-if =" bottomMethod"
20
+ :style =" footerStyle"
21
+ >
22
+ <i class =" weui-loading" v-if =" bottomStatus === 'loading'" ></i >
23
+ <i class =" wc-loadmore-arrow" :style =" arrowStyle" v-else ></i >
24
+ <span class =" mint-loadmore-text" >{{ bottomText }}</span >
25
+ </div >
26
+ </slot >
23
27
</div >
24
28
</template >
25
29
@@ -113,6 +117,23 @@ export default {
113
117
return this .translate === 0
114
118
? null
115
119
: " translate3d(0, " + this .translate + " px, 0)" ;
120
+ },
121
+
122
+ // 箭头旋转
123
+ arrowStyle () {
124
+ if (this .bottomStatus === " drop" ) {
125
+ let transform = " rotate(180deg)" ;
126
+ return {
127
+ transform
128
+ };
129
+ }
130
+ return null ;
131
+ },
132
+ // footerStyle
133
+ footerStyle () {
134
+ return {
135
+ bottom: this .translate === 0 ? " -50px" : - 1 * this .translate + " px"
136
+ };
116
137
}
117
138
},
118
139
@@ -174,22 +195,23 @@ export default {
174
195
},
175
196
176
197
getScrollEventTarget (element ) {
177
- let currentNode = element;
178
- while (
179
- currentNode &&
180
- currentNode .tagName !== " HTML" &&
181
- currentNode .tagName !== " BODY" &&
182
- currentNode .nodeType === 1
183
- ) {
184
- let overflowY = document .defaultView .getComputedStyle (currentNode)
185
- .overflowY ;
186
- if (overflowY === " scroll" || overflowY === " auto" ) {
187
- console .log (" currentNode is" , currentNode);
188
- return currentNode;
189
- }
190
- currentNode = currentNode .parentNode ;
191
- }
192
- return window ;
198
+ return this .$refs .scroller ;
199
+ // let currentNode = element;
200
+ // while (
201
+ // currentNode &&
202
+ // currentNode.tagName !== "HTML" &&
203
+ // currentNode.tagName !== "BODY" &&
204
+ // currentNode.nodeType === 1
205
+ // ) {
206
+ // let overflowY = document.defaultView.getComputedStyle(currentNode)
207
+ // .overflowY;
208
+ // if (overflowY === "scroll" || overflowY === "auto") {
209
+ // console.log("currentNode is", currentNode);
210
+ // return currentNode;
211
+ // }
212
+ // currentNode = currentNode.parentNode;
213
+ // }
214
+ // return window;
193
215
},
194
216
195
217
getScrollTop (element ) {
@@ -254,11 +276,23 @@ export default {
254
276
document .body .scrollHeight
255
277
);
256
278
} else {
257
- return (
279
+ let a =
258
280
parseInt (this .$el .getBoundingClientRect ().bottom , 10 ) <=
259
281
parseInt (this .scrollEventTarget .getBoundingClientRect ().bottom , 10 ) +
260
- 1
282
+ 1 ;
283
+ console .log (" object" );
284
+ console .log (parseInt (this .$el .getBoundingClientRect ().bottom , 10 ));
285
+ console .log (
286
+ parseInt (this .scrollEventTarget .getBoundingClientRect ().bottom , 10 )
261
287
);
288
+ let scrollEventTarget = this .scrollEventTarget ;
289
+ let c = scrollEventTarget .scrollTop + scrollEventTarget .clientHeight ;
290
+ let b = scrollEventTarget .scrollHeight ;
291
+ console .log (" ----" );
292
+ console .log (c);
293
+ console .log (b);
294
+ console .log (" checkBottomReached is" , a);
295
+ return c >= b;
262
296
}
263
297
},
264
298
@@ -286,6 +320,8 @@ export default {
286
320
this .currentY = event .touches [0 ].clientY ;
287
321
let distance = (this .currentY - this .startY ) / this .distanceIndex ;
288
322
this .direction = distance > 0 ? " down" : " up" ;
323
+ console .log (this .startScrollTop );
324
+ console .log (distance);
289
325
if (
290
326
typeof this .topMethod === " function" &&
291
327
this .direction === " down" &&
@@ -339,6 +375,7 @@ export default {
339
375
this .bottomStatus =
340
376
- this .translate >= this .bottomDistance ? " drop" : " pull" ;
341
377
}
378
+ console .log (this .translate );
342
379
this .$emit (" translate-change" , this .translate );
343
380
},
344
381
@@ -383,19 +420,12 @@ export default {
383
420
</script >
384
421
385
422
<style lang="scss" scoped>
386
- /* 这个文件主要是修改AUI提供的默认样式,FBI Warning !!! 只准修改全局AUI的样式,不然就滚😡 */
387
-
388
- /* 让下拉刷新的三个小点居中 */
389
- .mint-loadmore-top .ptr-instructions .inside {
390
- margin-top : 12px ;
391
- }
392
- /* 让下拉刷新的时间不要显示 */
393
- .mint-loadmore-top .ptr-instructions .time {
394
- display : none ;
395
- }
396
423
.mt-loadmore {
397
- overflow : hidden ;
398
- .mint-loadmore-content {
424
+ overflow : scroll ;
425
+ position : relative ;
426
+ height : 100% ;
427
+ .wc-loadmore-content {
428
+ position : static !important ;
399
429
.is-dropped {
400
430
transition : 0.2s ;
401
431
}
@@ -406,14 +436,35 @@ export default {
406
436
text-align : center ;
407
437
height : 50px ;
408
438
line-height : 50px ;
439
+ color : #999 ;
409
440
}
410
441
411
442
.mint-loadmore-top {
412
443
margin-top : -50px ;
413
444
}
414
445
446
+ // .mint-loadmore-bottom {
447
+ // margin-bottom: -50px;
448
+ // }
415
449
.mint-loadmore-bottom {
416
- margin-bottom : -50px ;
450
+ position : absolute ;
451
+ width : 100% ;
452
+ bottom : -50px ;
453
+ }
454
+
455
+ .weui-loading ,
456
+ .wc-loadmore-arrow {
457
+ margin-right : 10px ;
458
+ }
459
+
460
+ .wc-loadmore-arrow {
461
+ background-image : url (" ./loadmore_up_arrow.png" );
462
+ background-repeat : no-repeat ;
463
+ background-size : 100% ;
464
+ width : 20px ;
465
+ height : 20px ;
466
+ display : inline-block ;
467
+ vertical-align : middle ;
417
468
}
418
469
}
419
470
</style >
0 commit comments