mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
perf(@vant/lazyload): remove edge 15 polyfill
This commit is contained in:
parent
3ad17abd52
commit
00b1568887
@ -1,8 +1,7 @@
|
|||||||
import { h } from 'vue';
|
import { h } from 'vue';
|
||||||
import { inBrowser } from './util';
|
import { inBrowser } from './util';
|
||||||
|
|
||||||
export default (lazy) => {
|
export default (lazy) => ({
|
||||||
return {
|
|
||||||
props: {
|
props: {
|
||||||
tag: {
|
tag: {
|
||||||
type: String,
|
type: String,
|
||||||
@ -66,5 +65,4 @@ export default (lazy) => {
|
|||||||
return this.$destroy;
|
return this.$destroy;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
});
|
||||||
};
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { inBrowser, loadImageAsync, noop } from './util';
|
import { inBrowser, loadImageAsync, noop } from './util';
|
||||||
|
|
||||||
export default (lazyManager) => {
|
export default (lazyManager) => ({
|
||||||
return {
|
|
||||||
props: {
|
props: {
|
||||||
src: [String, Object],
|
src: [String, Object],
|
||||||
tag: {
|
tag: {
|
||||||
@ -103,5 +102,4 @@ export default (lazyManager) => {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
});
|
||||||
};
|
|
||||||
|
@ -1,31 +1,10 @@
|
|||||||
const inBrowser = typeof window !== 'undefined' && window !== null;
|
const inBrowser = typeof window !== 'undefined';
|
||||||
|
|
||||||
function checkIntersectionObserver() {
|
export const hasIntersectionObserver =
|
||||||
if (
|
|
||||||
inBrowser &&
|
inBrowser &&
|
||||||
'IntersectionObserver' in window &&
|
'IntersectionObserver' in window &&
|
||||||
'IntersectionObserverEntry' in window &&
|
'IntersectionObserverEntry' in window &&
|
||||||
'intersectionRatio' in window.IntersectionObserverEntry.prototype
|
'intersectionRatio' in window.IntersectionObserverEntry.prototype;
|
||||||
) {
|
|
||||||
// Minimal polyfill for Edge 15's lack of `isIntersecting`
|
|
||||||
// See: https://github.com/w3c/IntersectionObserver/issues/211
|
|
||||||
if (!('isIntersecting' in window.IntersectionObserverEntry.prototype)) {
|
|
||||||
Object.defineProperty(
|
|
||||||
window.IntersectionObserverEntry.prototype,
|
|
||||||
'isIntersecting',
|
|
||||||
{
|
|
||||||
get() {
|
|
||||||
return this.intersectionRatio > 0;
|
|
||||||
},
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const hasIntersectionObserver = checkIntersectionObserver();
|
|
||||||
|
|
||||||
export const modeType = {
|
export const modeType = {
|
||||||
event: 'event',
|
event: 'event',
|
||||||
@ -86,7 +65,7 @@ function getBestSelectionFromSrcset(el, scale) {
|
|||||||
return [tmpWidth, tmpSrc];
|
return [tmpWidth, tmpSrc];
|
||||||
});
|
});
|
||||||
|
|
||||||
result.sort(function (a, b) {
|
result.sort((a, b) => {
|
||||||
if (a[0] < b[0]) {
|
if (a[0] < b[0]) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -236,17 +215,13 @@ const loadImageAsync = (item, resolve, reject) => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const style = (el, prop) => {
|
const style = (el, prop) =>
|
||||||
return typeof getComputedStyle !== 'undefined'
|
typeof getComputedStyle !== 'undefined'
|
||||||
? getComputedStyle(el, null).getPropertyValue(prop)
|
? getComputedStyle(el, null).getPropertyValue(prop)
|
||||||
: el.style[prop];
|
: el.style[prop];
|
||||||
};
|
|
||||||
|
|
||||||
const overflow = (el) => {
|
const overflow = (el) =>
|
||||||
return (
|
style(el, 'overflow') + style(el, 'overflow-y') + style(el, 'overflow-x');
|
||||||
style(el, 'overflow') + style(el, 'overflow-y') + style(el, 'overflow-x')
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const scrollParent = (el) => {
|
const scrollParent = (el) => {
|
||||||
if (!inBrowser) return;
|
if (!inBrowser) return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user