File tree Expand file tree Collapse file tree 6 files changed +2978
-2867
lines changed
packages/components/bolt-image Expand file tree Collapse file tree 6 files changed +2978
-2867
lines changed Original file line number Diff line number Diff line change 27
27
" packages/*" ,
28
28
" packages/*/*" ,
29
29
" packages/build-tools/plugins/*"
30
+ ],
31
+ "nohoist" : [
32
+ " lazysizes" ,
33
+ " **/lazysizes"
30
34
]
31
35
},
32
36
"scripts" : {
Original file line number Diff line number Diff line change 30
30
"access" : " public" ,
31
31
"tag" : " next"
32
32
},
33
+ "scripts" : {
34
+ "postinstall" : " patch-package"
35
+ },
33
36
"dependencies" : {
34
37
"@bolt/components-ratio" : " ^2.5.2" ,
35
38
"@bolt/core" : " ^2.5.2" ,
36
- "lazysizes" : " ^4.1.4"
39
+ "lazysizes" : " ^4.1.4" ,
40
+ "patch-package" : " ^6.1.2" ,
41
+ "postinstall-postinstall" : " ^2.0.0"
37
42
},
38
43
"style" : " index.scss" ,
39
44
"main" : " index.js" ,
Original file line number Diff line number Diff line change
1
+ diff --git a/node_modules/lazysizes/lazysizes.js b/node_modules/lazysizes/lazysizes.js
2
+ index 26ba477..076c71e 100644
3
+ --- a/node_modules/lazysizes/lazysizes.js
4
+ +++ b/node_modules/lazysizes/lazysizes.js
5
+ @@ -97,7 +97,12 @@
6
+ };
7
+
8
+ var getCSS = function (elem, style){
9
+ - return (getComputedStyle(elem, null) || {})[style];
10
+ + try {
11
+ + return (getComputedStyle(elem, null) || {})[style];
12
+ + }
13
+ + catch {
14
+ + return {}[style];
15
+ + }
16
+ };
17
+
18
+ var getWidth = function(elem, parent, width){
19
+ @@ -586,8 +591,21 @@
20
+ _: function(){
21
+ started = Date.now();
22
+
23
+ - lazysizes.elements = document.getElementsByClassName(lazySizesConfig.lazyClass);
24
+ - preloadElems = document.getElementsByClassName(lazySizesConfig.lazyClass + ' ' + lazySizesConfig.preloadClass);
25
+ + lazysizes.elements = lazySizesConfig.getElements
26
+ + ? lazySizesConfig.getElements(`.${lazySizesConfig.lazyClass}`)
27
+ + : document.getElementsByClassName(lazySizesConfig.lazyClass);
28
+ +
29
+ + preloadElems = lazySizesConfig.getElements
30
+ + ? lazySizesConfig.getElements(
31
+ + `.${lazySizesConfig.lazyClass}.${
32
+ + lazySizesConfig.preloadClass
33
+ + }`,
34
+ + )
35
+ + : document.getElementsByClassName(
36
+ + lazySizesConfig.lazyClass +
37
+ + ' ' +
38
+ + lazySizesConfig.preloadClass,
39
+ + );
40
+
41
+ addEventListener('scroll', throttledCheckElements, true);
42
+
Original file line number Diff line number Diff line change 1
- import lazySizes from 'lazysizes' ; // Mostly just for automatic `size` attribute support
1
+ import lazySizes from 'lazysizes/lazysizes.js ' ; // Mostly just for automatic `size` attribute support
2
2
// import 'lazysizes/src/lazysizes-intersection';
3
3
import 'lazysizes/plugins/unveilhooks/ls.unveilhooks' ;
4
4
import 'lazysizes/plugins/progressive/ls.progressive' ;
@@ -8,8 +8,18 @@ import 'lazysizes/plugins/respimg/ls.respimg'; // Lighter weight version of pict
8
8
// lazySizes.cfg == window.lazySizesConfig
9
9
Object . assign ( lazySizes . cfg , {
10
10
lazyClass : 'js-lazyload' ,
11
+ preloadClass : 'js-lazypreload' ,
11
12
loadingClass : 'is-lazyloading' ,
12
13
loadedClass : 'is-lazyloaded' ,
13
14
preloadAfterLoad : true ,
14
15
// preloadAfterLoad: false,
16
+ getElements ( selector ) {
17
+ let elements = Array . from ( document . querySelectorAll ( 'bolt-image' ) ) . map (
18
+ elem => elem . renderRoot . querySelector ( selector ) ,
19
+ ) ;
20
+ elements = elements . filter ( function ( el ) {
21
+ return el != null ;
22
+ } ) ;
23
+ return elements ;
24
+ } ,
15
25
} ) ;
Original file line number Diff line number Diff line change @@ -67,8 +67,6 @@ class BoltImage extends withLitHtml() {
67
67
68
68
lazyloadImage ( image ) {
69
69
if ( ! this . isLoaded ) {
70
- // Note: This immediately unveils the image. Add intersection observer?
71
- lazySizes . loader . unveil ( image ) ;
72
70
this . isLoaded = true ;
73
71
}
74
72
}
You can’t perform that action at this time.
0 commit comments