11<template >
2- <div class =" mt-loadmore" >
2+ <div class =" mt-loadmore" ref = " scroller " >
33 <div
4- class =" mint -loadmore-content"
4+ class =" wc -loadmore-content"
55 :class =" { 'is-dropped': topDropped || bottomDropped }"
66 :style =" { transform: transform }"
77 >
8- <slot name =" top " >
8+ <slot name =" header " >
99 <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> -->
1210 <Header :icon-run =" iconRun" ></Header >
1311 </div >
1412 </slot >
1513 <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 >
2214 </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 >
2327 </div >
2428</template >
2529
@@ -113,6 +117,23 @@ export default {
113117 return this .translate === 0
114118 ? null
115119 : " 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+ };
116137 }
117138 },
118139
@@ -174,22 +195,23 @@ export default {
174195 },
175196
176197 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;
193215 },
194216
195217 getScrollTop (element ) {
@@ -254,11 +276,23 @@ export default {
254276 document .body .scrollHeight
255277 );
256278 } else {
257- return (
279+ let a =
258280 parseInt (this .$el .getBoundingClientRect ().bottom , 10 ) <=
259281 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 )
261287 );
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;
262296 }
263297 },
264298
@@ -286,6 +320,8 @@ export default {
286320 this .currentY = event .touches [0 ].clientY ;
287321 let distance = (this .currentY - this .startY ) / this .distanceIndex ;
288322 this .direction = distance > 0 ? " down" : " up" ;
323+ console .log (this .startScrollTop );
324+ console .log (distance);
289325 if (
290326 typeof this .topMethod === " function" &&
291327 this .direction === " down" &&
@@ -339,6 +375,7 @@ export default {
339375 this .bottomStatus =
340376 - this .translate >= this .bottomDistance ? " drop" : " pull" ;
341377 }
378+ console .log (this .translate );
342379 this .$emit (" translate-change" , this .translate );
343380 },
344381
@@ -383,19 +420,12 @@ export default {
383420</script >
384421
385422<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- }
396423.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 ;
399429 .is-dropped {
400430 transition : 0.2s ;
401431 }
@@ -406,14 +436,35 @@ export default {
406436 text-align : center ;
407437 height : 50px ;
408438 line-height : 50px ;
439+ color : #999 ;
409440 }
410441
411442 .mint-loadmore-top {
412443 margin-top : -50px ;
413444 }
414445
446+ // .mint-loadmore-bottom {
447+ // margin-bottom: -50px;
448+ // }
415449 .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 ;
417468 }
418469}
419470</style >
0 commit comments