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 { inBrowser } from './util';
|
||||
|
||||
export default (lazy) => {
|
||||
return {
|
||||
export default (lazy) => ({
|
||||
props: {
|
||||
tag: {
|
||||
type: String,
|
||||
@ -66,5 +65,4 @@ export default (lazy) => {
|
||||
return this.$destroy;
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
});
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { inBrowser, loadImageAsync, noop } from './util';
|
||||
|
||||
export default (lazyManager) => {
|
||||
return {
|
||||
export default (lazyManager) => ({
|
||||
props: {
|
||||
src: [String, Object],
|
||||
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() {
|
||||
if (
|
||||
export const hasIntersectionObserver =
|
||||
inBrowser &&
|
||||
'IntersectionObserver' in window &&
|
||||
'IntersectionObserverEntry' in window &&
|
||||
'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();
|
||||
'intersectionRatio' in window.IntersectionObserverEntry.prototype;
|
||||
|
||||
export const modeType = {
|
||||
event: 'event',
|
||||
@ -86,7 +65,7 @@ function getBestSelectionFromSrcset(el, scale) {
|
||||
return [tmpWidth, tmpSrc];
|
||||
});
|
||||
|
||||
result.sort(function (a, b) {
|
||||
result.sort((a, b) => {
|
||||
if (a[0] < b[0]) {
|
||||
return 1;
|
||||
}
|
||||
@ -236,17 +215,13 @@ const loadImageAsync = (item, resolve, reject) => {
|
||||
};
|
||||
};
|
||||
|
||||
const style = (el, prop) => {
|
||||
return typeof getComputedStyle !== 'undefined'
|
||||
const style = (el, prop) =>
|
||||
typeof getComputedStyle !== 'undefined'
|
||||
? getComputedStyle(el, null).getPropertyValue(prop)
|
||||
: el.style[prop];
|
||||
};
|
||||
|
||||
const overflow = (el) => {
|
||||
return (
|
||||
style(el, 'overflow') + style(el, 'overflow-y') + style(el, 'overflow-x')
|
||||
);
|
||||
};
|
||||
const overflow = (el) =>
|
||||
style(el, 'overflow') + style(el, 'overflow-y') + style(el, 'overflow-x');
|
||||
|
||||
const scrollParent = (el) => {
|
||||
if (!inBrowser) return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user