@docusaurus/plugin-ideal-image 3.7.0-canary-6265 → 3.7.0-canary-6266
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -8,6 +8,17 @@ function addEventListener(element, type, listener, options) {
|
|
|
8
8
|
element.addEventListener(type, listener, options);
|
|
9
9
|
return () => element.removeEventListener(type, listener, options);
|
|
10
10
|
}
|
|
11
|
+
// Because waypoint may fire before the setState() updates due to batching
|
|
12
|
+
// queueMicrotask is a better option than setTimeout() or React.flushSync()
|
|
13
|
+
// See https://github.com/facebook/docusaurus/issues/11018
|
|
14
|
+
// See https://github.com/civiccc/react-waypoint/blob/0905ac5a073131147c96dd0694bd6f1b6ee8bc97/src/onNextTick.js
|
|
15
|
+
function subscribeMicrotask(callback) {
|
|
16
|
+
let subscribed = true;
|
|
17
|
+
queueMicrotask(() => {
|
|
18
|
+
if (subscribed) callback();
|
|
19
|
+
});
|
|
20
|
+
return () => (subscribed = false);
|
|
21
|
+
}
|
|
11
22
|
export function Waypoint(props) {
|
|
12
23
|
return typeof window !== 'undefined' ? (
|
|
13
24
|
<WaypointClient {...props}>{props.children}</WaypointClient>
|
|
@@ -43,11 +54,14 @@ class WaypointClient extends React.Component {
|
|
|
43
54
|
this._handleScroll,
|
|
44
55
|
{passive: true},
|
|
45
56
|
);
|
|
57
|
+
const unsubscribeInitialScroll = subscribeMicrotask(() => {
|
|
58
|
+
this._handleScroll();
|
|
59
|
+
});
|
|
46
60
|
this.unsubscribe = () => {
|
|
47
61
|
unsubscribeScroll();
|
|
48
62
|
unsubscribeResize();
|
|
63
|
+
unsubscribeInitialScroll();
|
|
49
64
|
};
|
|
50
|
-
this._handleScroll();
|
|
51
65
|
}
|
|
52
66
|
componentDidUpdate() {
|
|
53
67
|
this._handleScroll();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/plugin-ideal-image",
|
|
3
|
-
"version": "3.7.0-canary-
|
|
3
|
+
"version": "3.7.0-canary-6266",
|
|
4
4
|
"description": "Docusaurus Plugin to generate an almost ideal image (responsive, lazy-loading, and low quality placeholder).",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/plugin-ideal-image.d.ts",
|
|
@@ -20,18 +20,18 @@
|
|
|
20
20
|
},
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@docusaurus/core": "3.7.0-canary-
|
|
24
|
-
"@docusaurus/lqip-loader": "3.7.0-canary-
|
|
23
|
+
"@docusaurus/core": "3.7.0-canary-6266",
|
|
24
|
+
"@docusaurus/lqip-loader": "3.7.0-canary-6266",
|
|
25
25
|
"@docusaurus/responsive-loader": "^1.7.0",
|
|
26
|
-
"@docusaurus/theme-translations": "3.7.0-canary-
|
|
27
|
-
"@docusaurus/types": "3.7.0-canary-
|
|
28
|
-
"@docusaurus/utils-validation": "3.7.0-canary-
|
|
26
|
+
"@docusaurus/theme-translations": "3.7.0-canary-6266",
|
|
27
|
+
"@docusaurus/types": "3.7.0-canary-6266",
|
|
28
|
+
"@docusaurus/utils-validation": "3.7.0-canary-6266",
|
|
29
29
|
"sharp": "^0.32.3",
|
|
30
30
|
"tslib": "^2.6.0",
|
|
31
31
|
"webpack": "^5.88.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@docusaurus/module-type-aliases": "3.7.0-canary-
|
|
34
|
+
"@docusaurus/module-type-aliases": "3.7.0-canary-6266",
|
|
35
35
|
"fs-extra": "^11.1.0"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"engines": {
|
|
48
48
|
"node": ">=18.0"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "4e16ac7fa667cc4cd798ba112971bfae8215d2e2"
|
|
51
51
|
}
|
|
@@ -18,6 +18,18 @@ function addEventListener(
|
|
|
18
18
|
return () => element.removeEventListener(type, listener, options);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
// Because waypoint may fire before the setState() updates due to batching
|
|
22
|
+
// queueMicrotask is a better option than setTimeout() or React.flushSync()
|
|
23
|
+
// See https://github.com/facebook/docusaurus/issues/11018
|
|
24
|
+
// See https://github.com/civiccc/react-waypoint/blob/0905ac5a073131147c96dd0694bd6f1b6ee8bc97/src/onNextTick.js
|
|
25
|
+
function subscribeMicrotask(callback: () => void) {
|
|
26
|
+
let subscribed = true;
|
|
27
|
+
queueMicrotask(() => {
|
|
28
|
+
if (subscribed) callback();
|
|
29
|
+
});
|
|
30
|
+
return () => (subscribed = false);
|
|
31
|
+
}
|
|
32
|
+
|
|
21
33
|
type Position = 'above' | 'inside' | 'below' | 'invisible';
|
|
22
34
|
|
|
23
35
|
type Props = {
|
|
@@ -70,12 +82,15 @@ class WaypointClient extends React.Component<Props> {
|
|
|
70
82
|
{passive: true},
|
|
71
83
|
);
|
|
72
84
|
|
|
85
|
+
const unsubscribeInitialScroll = subscribeMicrotask(() => {
|
|
86
|
+
this._handleScroll();
|
|
87
|
+
});
|
|
88
|
+
|
|
73
89
|
this.unsubscribe = () => {
|
|
74
90
|
unsubscribeScroll();
|
|
75
91
|
unsubscribeResize();
|
|
92
|
+
unsubscribeInitialScroll();
|
|
76
93
|
};
|
|
77
|
-
|
|
78
|
-
this._handleScroll();
|
|
79
94
|
}
|
|
80
95
|
|
|
81
96
|
override componentDidUpdate() {
|