1
- var LazyComponent = ( function ( ) {
2
- 'use strict' ;
1
+ ( function ( global , factory ) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? module . exports = factory ( ) :
3
+ typeof define === 'function' && define . amd ? define ( factory ) :
4
+ ( global = typeof globalThis !== 'undefined' ? globalThis : global || self , global . LazyComponent = factory ( ) ) ;
5
+ } ) ( this , ( function ( ) { 'use strict' ;
3
6
4
7
//
5
8
//
@@ -48,7 +51,7 @@ var LazyComponent = (function () {
48
51
default : 0
49
52
}
50
53
} ,
51
- data : function data ( ) {
54
+ data ( ) {
52
55
return {
53
56
state : {
54
57
wrapperTag : this . wrapperTag ,
@@ -61,18 +64,18 @@ var LazyComponent = (function () {
61
64
} ;
62
65
} ,
63
66
watch : {
64
- isIntersected : function isIntersected ( value ) {
67
+ isIntersected ( value ) {
65
68
if ( value ) {
66
69
this . state . isIntersected = true ;
67
70
}
68
71
} ,
69
- 'state.isIntersected' : function stateIsIntersected ( value ) {
72
+ 'state.isIntersected' ( value ) {
70
73
if ( value ) {
71
74
this . $emit ( 'intersected' , this . $el ) ;
72
75
}
73
76
}
74
77
} ,
75
- mounted : function mounted ( ) {
78
+ mounted ( ) {
76
79
if ( this . isIntersectionObserverSupported ( ) ) {
77
80
if ( ! this . state . isIntersected && ! this . state . idle ) {
78
81
this . observe ( ) ;
@@ -84,36 +87,35 @@ var LazyComponent = (function () {
84
87
this . $emit ( 'intersected' , this . $el ) ;
85
88
}
86
89
} ,
87
- beforeDestroy : function beforeDestroy ( ) {
90
+ beforeDestroy ( ) {
88
91
if ( ! this . state . isIntersected && ! this . state . idle ) {
89
92
this . unobserve ( ) ;
90
93
}
91
94
} ,
92
95
methods : {
93
- isIntersectionObserverSupported : function isIntersectionObserverSupported ( ) {
96
+ isIntersectionObserverSupported ( ) {
94
97
return 'IntersectionObserver' in window && 'IntersectionObserverEntry' in window && 'intersectionRatio' in window . IntersectionObserverEntry . prototype && 'isIntersecting' in window . IntersectionObserverEntry . prototype ;
95
98
} ,
96
- observe : function observe ( ) {
97
- var _this$state = this . state ,
98
- rootMargin = _this$state . rootMargin ,
99
- threshold = _this$state . threshold ;
100
- var config = {
99
+ observe ( ) {
100
+ const {
101
+ rootMargin,
102
+ threshold
103
+ } = this . state ;
104
+ const config = {
101
105
root : undefined ,
102
- rootMargin : rootMargin ,
103
- threshold : threshold
106
+ rootMargin,
107
+ threshold
104
108
} ;
105
109
this . state . observer = new IntersectionObserver ( this . onIntersection , config ) ;
106
110
this . state . observer . observe ( this . $el ) ;
107
111
} ,
108
- onIntersection : function onIntersection ( entries ) {
109
- this . state . isIntersected = entries . some ( function ( entry ) {
110
- return entry . intersectionRatio > 0 ;
111
- } ) ;
112
+ onIntersection ( entries ) {
113
+ this . state . isIntersected = entries . some ( entry => entry . intersectionRatio > 0 ) ;
112
114
if ( this . state . isIntersected ) {
113
115
this . unobserve ( ) ;
114
116
}
115
117
} ,
116
- unobserve : function unobserve ( ) {
118
+ unobserve ( ) {
117
119
if ( this . isIntersectionObserverSupported ( ) ) {
118
120
this . state . observer . unobserve ( this . $el ) ;
119
121
}
@@ -197,9 +199,9 @@ var LazyComponent = (function () {
197
199
}
198
200
199
201
/* script */
200
- var __vue_script__ = script ;
202
+ const __vue_script__ = script ;
201
203
/* template */
202
- var __vue_render__ = function __vue_render__ ( ) {
204
+ var __vue_render__ = function ( ) {
203
205
var _vm = this ;
204
206
var _h = _vm . $createElement ;
205
207
var _c = _vm . _self . _c || _h ;
@@ -218,43 +220,43 @@ var LazyComponent = (function () {
218
220
var __vue_staticRenderFns__ = [ ] ;
219
221
220
222
/* style */
221
- var __vue_inject_styles__ = undefined ;
223
+ const __vue_inject_styles__ = undefined ;
222
224
/* scoped */
223
- var __vue_scope_id__ = undefined ;
225
+ const __vue_scope_id__ = undefined ;
224
226
/* module identifier */
225
- var __vue_module_identifier__ = undefined ;
227
+ const __vue_module_identifier__ = undefined ;
226
228
/* functional template */
227
- var __vue_is_functional_template__ = false ;
229
+ const __vue_is_functional_template__ = false ;
228
230
/* style inject */
229
231
230
232
/* style inject SSR */
231
233
232
234
/* style inject shadow dom */
233
235
234
- var __vue_component__ = /*#__PURE__*/ normalizeComponent ( {
236
+ const __vue_component__ = /*#__PURE__*/ normalizeComponent ( {
235
237
render : __vue_render__ ,
236
238
staticRenderFns : __vue_staticRenderFns__
237
239
} , __vue_inject_styles__ , __vue_script__ , __vue_scope_id__ , __vue_is_functional_template__ , __vue_module_identifier__ , false , undefined , undefined , undefined ) ;
238
240
239
241
// Import vue component
240
242
241
243
// install function executed by Vue.use()
242
- var install = function installLazyComponent ( Vue ) {
244
+ const install = function installLazyComponent ( Vue ) {
243
245
if ( install . installed ) return ;
244
246
install . installed = true ;
245
247
Vue . component ( 'LazyComponent' , __vue_component__ ) ;
246
248
} ;
247
249
248
250
// Create module definition for Vue.use()
249
- var plugin = {
250
- install : install
251
+ const plugin = {
252
+ install
251
253
} ;
252
254
253
255
// To auto-install on non-es builds, when vue is found
254
256
// eslint-disable-next-line no-redeclare
255
257
/* global window, global */
256
258
{
257
- var GlobalVue = null ;
259
+ let GlobalVue = null ;
258
260
if ( typeof window !== 'undefined' ) {
259
261
GlobalVue = window . Vue ;
260
262
} else if ( typeof global !== 'undefined' ) {
@@ -275,4 +277,4 @@ var LazyComponent = (function () {
275
277
276
278
return __vue_component__ ;
277
279
278
- } ) ( ) ;
280
+ } ) ) ;
0 commit comments