[improvement] sort out utils (#2672)
This commit is contained in:
+15
-12
@@ -1,7 +1,13 @@
|
||||
import { use } from '../utils';
|
||||
import utils from '../utils/scroll';
|
||||
import Loading from '../loading';
|
||||
import { on, off } from '../utils/event';
|
||||
import {
|
||||
getScrollTop,
|
||||
getElementTop,
|
||||
getVisibleHeight,
|
||||
getComputedStyle,
|
||||
getScrollEventTarget
|
||||
} from '../utils/scroll';
|
||||
|
||||
const [sfc, bem, t] = use('list');
|
||||
|
||||
@@ -28,7 +34,7 @@ export default sfc({
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.scroller = utils.getScrollEventTarget(this.$el);
|
||||
this.scroller = getScrollEventTarget(this.$el);
|
||||
this.handler(true);
|
||||
|
||||
if (this.immediateCheck) {
|
||||
@@ -66,18 +72,14 @@ export default sfc({
|
||||
|
||||
const el = this.$el;
|
||||
const { scroller } = this;
|
||||
const scrollerHeight = utils.getVisibleHeight(scroller);
|
||||
const scrollerHeight = getVisibleHeight(scroller);
|
||||
|
||||
/* istanbul ignore next */
|
||||
if (
|
||||
!scrollerHeight ||
|
||||
utils.getComputedStyle(el).display === 'none' ||
|
||||
el.offsetParent === null
|
||||
) {
|
||||
if (!scrollerHeight || getComputedStyle(el).display === 'none' || el.offsetParent === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
const scrollTop = utils.getScrollTop(scroller);
|
||||
const scrollTop = getScrollTop(scroller);
|
||||
const targetBottom = scrollTop + scrollerHeight;
|
||||
|
||||
let reachBottom = false;
|
||||
@@ -86,8 +88,7 @@ export default sfc({
|
||||
if (el === scroller) {
|
||||
reachBottom = scroller.scrollHeight - targetBottom < this.offset;
|
||||
} else {
|
||||
const elBottom =
|
||||
utils.getElementTop(el) - utils.getElementTop(scroller) + utils.getVisibleHeight(el);
|
||||
const elBottom = getElementTop(el) - getElementTop(scroller) + getVisibleHeight(el);
|
||||
reachBottom = elBottom - scrollerHeight < this.offset;
|
||||
}
|
||||
|
||||
@@ -128,7 +129,9 @@ export default sfc({
|
||||
<div class={bem('finished-text')}>{this.finishedText}</div>
|
||||
)}
|
||||
{this.error && this.errorText && (
|
||||
<div onClick={this.clickErrorText} class={bem('error-text')}>{this.errorText}</div>
|
||||
<div onClick={this.clickErrorText} class={bem('error-text')}>
|
||||
{this.errorText}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user