perf(@vant/lazyload): remove edge 15 polyfill

This commit is contained in:
chenjiahan
2021-09-24 10:48:24 +08:00
committed by neverland
parent 3ad17abd52
commit 00b1568887
3 changed files with 161 additions and 190 deletions
+56 -58
View File
@@ -1,70 +1,68 @@
import { h } from 'vue';
import { inBrowser } from './util';
export default (lazy) => {
return {
props: {
tag: {
type: String,
default: 'div',
export default (lazy) => ({
props: {
tag: {
type: String,
default: 'div',
},
},
emits: ['show'],
render() {
return h(
this.tag,
this.show && this.$slots.default ? this.$slots.default() : null
);
},
data() {
return {
el: null,
state: {
loaded: false,
},
rect: {},
show: false,
};
},
mounted() {
this.el = this.$el;
lazy.addLazyBox(this);
lazy.lazyLoadHandler();
},
beforeUnmount() {
lazy.removeComponent(this);
},
methods: {
getRect() {
this.rect = this.$el.getBoundingClientRect();
},
emits: ['show'],
render() {
return h(
this.tag,
this.show && this.$slots.default ? this.$slots.default() : null
checkInView() {
this.getRect();
return (
inBrowser &&
this.rect.top < window.innerHeight * lazy.options.preLoad &&
this.rect.bottom > 0 &&
this.rect.left < window.innerWidth * lazy.options.preLoad &&
this.rect.right > 0
);
},
data() {
return {
el: null,
state: {
loaded: false,
},
rect: {},
show: false,
};
load() {
this.show = true;
this.state.loaded = true;
this.$emit('show', this);
},
mounted() {
this.el = this.$el;
lazy.addLazyBox(this);
lazy.lazyLoadHandler();
destroy() {
return this.$destroy;
},
beforeUnmount() {
lazy.removeComponent(this);
},
methods: {
getRect() {
this.rect = this.$el.getBoundingClientRect();
},
checkInView() {
this.getRect();
return (
inBrowser &&
this.rect.top < window.innerHeight * lazy.options.preLoad &&
this.rect.bottom > 0 &&
this.rect.left < window.innerWidth * lazy.options.preLoad &&
this.rect.right > 0
);
},
load() {
this.show = true;
this.state.loaded = true;
this.$emit('show', this);
},
destroy() {
return this.$destroy;
},
},
};
};
},
});