mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
chore: remove istanbul ignore
This commit is contained in:
parent
d659c0c99e
commit
b16779d760
@ -171,7 +171,6 @@ export default createComponent({
|
|||||||
this.init();
|
this.init();
|
||||||
},
|
},
|
||||||
|
|
||||||
/* istanbul ignore next */
|
|
||||||
activated() {
|
activated() {
|
||||||
this.init();
|
this.init();
|
||||||
},
|
},
|
||||||
|
@ -42,9 +42,22 @@ export default createComponent({
|
|||||||
// use sync innerLoading state to avoid repeated loading in some edge cases
|
// use sync innerLoading state to avoid repeated loading in some edge cases
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const root = ref();
|
const root = ref();
|
||||||
const placeholderRef = ref();
|
const placeholder = ref();
|
||||||
const scrollParent = useScrollParent(root);
|
const scrollParent = useScrollParent(root);
|
||||||
|
|
||||||
|
const getScrollParentRect = () => {
|
||||||
|
const element = scrollParent.value;
|
||||||
|
if (element.getBoundingClientRect) {
|
||||||
|
return element.getBoundingClientRect();
|
||||||
|
}
|
||||||
|
const height = element.innerHeight;
|
||||||
|
return {
|
||||||
|
top: 0,
|
||||||
|
height,
|
||||||
|
bottom: height,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
const check = () => {
|
const check = () => {
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
if (loading.value || props.finished || props.error) {
|
if (loading.value || props.finished || props.error) {
|
||||||
@ -52,27 +65,14 @@ export default createComponent({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const { offset, direction } = props;
|
const { offset, direction } = props;
|
||||||
let scrollParentRect;
|
const scrollParentRect = getScrollParentRect();
|
||||||
|
|
||||||
if (scrollParent.value.getBoundingClientRect) {
|
if (!scrollParentRect.height || isHidden(root)) {
|
||||||
scrollParentRect = scrollParent.value.getBoundingClientRect();
|
|
||||||
} else {
|
|
||||||
scrollParentRect = {
|
|
||||||
top: 0,
|
|
||||||
bottom: scrollParent.value.innerHeight,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const scrollParentHeight =
|
|
||||||
scrollParentRect.bottom - scrollParentRect.top;
|
|
||||||
|
|
||||||
/* istanbul ignore next */
|
|
||||||
if (!scrollParentHeight || isHidden(root)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let isReachEdge = false;
|
let isReachEdge = false;
|
||||||
const placeholderRect = useRect(placeholderRef);
|
const placeholderRect = useRect(placeholder);
|
||||||
|
|
||||||
if (direction === 'up') {
|
if (direction === 'up') {
|
||||||
isReachEdge = scrollParentRect.top - placeholderRect.top <= offset;
|
isReachEdge = scrollParentRect.top - placeholderRect.top <= offset;
|
||||||
@ -148,9 +148,7 @@ export default createComponent({
|
|||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
const Content = slots.default?.();
|
const Content = slots.default?.();
|
||||||
const Placeholder = (
|
const Placeholder = <div ref={placeholder} class={bem('placeholder')} />;
|
||||||
<div ref={placeholderRef} class={bem('placeholder')} />
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div ref={root} role="feed" class={bem()} aria-busy={loading.value}>
|
<div ref={root} role="feed" class={bem()} aria-busy={loading.value}>
|
||||||
|
@ -9,7 +9,6 @@ if (inBrowser) {
|
|||||||
Object.defineProperty(opts, 'passive', {
|
Object.defineProperty(opts, 'passive', {
|
||||||
// eslint-disable-next-line getter-return
|
// eslint-disable-next-line getter-return
|
||||||
get() {
|
get() {
|
||||||
/* istanbul ignore next */
|
|
||||||
supportsPassive = true;
|
supportsPassive = true;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -6,7 +6,6 @@ import { inBrowser } from '..';
|
|||||||
|
|
||||||
let prev = Date.now();
|
let prev = Date.now();
|
||||||
|
|
||||||
/* istanbul ignore next */
|
|
||||||
function fallback(fn: FrameRequestCallback): number {
|
function fallback(fn: FrameRequestCallback): number {
|
||||||
const curr = Date.now();
|
const curr = Date.now();
|
||||||
const ms = Math.max(0, 16 - (curr - prev));
|
const ms = Math.max(0, 16 - (curr - prev));
|
||||||
@ -15,13 +14,10 @@ function fallback(fn: FrameRequestCallback): number {
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* istanbul ignore next */
|
|
||||||
const root = (inBrowser ? window : global) as Window;
|
const root = (inBrowser ? window : global) as Window;
|
||||||
|
|
||||||
/* istanbul ignore next */
|
|
||||||
const iRaf = root.requestAnimationFrame || fallback;
|
const iRaf = root.requestAnimationFrame || fallback;
|
||||||
|
|
||||||
/* istanbul ignore next */
|
|
||||||
const iCancel = root.cancelAnimationFrame || root.clearTimeout;
|
const iCancel = root.cancelAnimationFrame || root.clearTimeout;
|
||||||
|
|
||||||
export function raf(fn: FrameRequestCallback): number {
|
export function raf(fn: FrameRequestCallback): number {
|
||||||
|
@ -8,7 +8,6 @@ import { getRootScrollTop, setRootScrollTop } from './scroll';
|
|||||||
|
|
||||||
const isIOS = checkIsIOS();
|
const isIOS = checkIsIOS();
|
||||||
|
|
||||||
/* istanbul ignore next */
|
|
||||||
export function resetScroll() {
|
export function resetScroll() {
|
||||||
if (isIOS) {
|
if (isIOS) {
|
||||||
setRootScrollTop(getRootScrollTop());
|
setRootScrollTop(getRootScrollTop());
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
import { inBrowser } from '..';
|
import { inBrowser } from '..';
|
||||||
|
|
||||||
export function isAndroid(): boolean {
|
export function isAndroid(): boolean {
|
||||||
/* istanbul ignore next */
|
|
||||||
return inBrowser ? /android/.test(navigator.userAgent.toLowerCase()) : false;
|
return inBrowser ? /android/.test(navigator.userAgent.toLowerCase()) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isIOS(): boolean {
|
export function isIOS(): boolean {
|
||||||
/* istanbul ignore next */
|
|
||||||
return inBrowser
|
return inBrowser
|
||||||
? /ios|iphone|ipad|ipod/.test(navigator.userAgent.toLowerCase())
|
? /ios|iphone|ipad|ipod/.test(navigator.userAgent.toLowerCase())
|
||||||
: false;
|
: false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user