@sheinx/hooks 3.4.5-beta.5 → 3.4.5-beta.6
Sign up to get free protection for your applications and to get access to all the features.
- package/cjs/components/use-image/use-image.d.ts.map +1 -1
- package/cjs/components/use-image/use-image.js +7 -0
- package/cjs/components/use-image/use-image.type.d.ts +7 -0
- package/cjs/components/use-image/use-image.type.d.ts.map +1 -1
- package/cjs/utils/lazyload.d.ts +1 -0
- package/cjs/utils/lazyload.d.ts.map +1 -1
- package/cjs/utils/lazyload.js +3 -0
- package/esm/components/use-image/use-image.d.ts.map +1 -1
- package/esm/components/use-image/use-image.js +7 -0
- package/esm/components/use-image/use-image.type.d.ts +7 -0
- package/esm/components/use-image/use-image.type.d.ts.map +1 -1
- package/esm/utils/lazyload.d.ts +1 -0
- package/esm/utils/lazyload.d.ts.map +1 -1
- package/esm/utils/lazyload.js +3 -0
- package/package.json +1 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-image.d.ts","sourceRoot":"","sources":["use-image.ts"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AACzC,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG5D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAWlD,QAAA,MAAM,QAAQ,WAAW,cAAc;;;;;;;;;;yBA6D3B,gBAAgB,CAAC,gBAAgB,GAAG,cAAc,CAAC;;;;;;;;;;;
|
1
|
+
{"version":3,"file":"use-image.d.ts","sourceRoot":"","sources":["use-image.ts"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AACzC,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG5D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAWlD,QAAA,MAAM,QAAQ,WAAW,cAAc;;;;;;;;;;yBA6D3B,gBAAgB,CAAC,gBAAgB,GAAG,cAAc,CAAC;;;;;;;;;;;CAmF9D,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
@@ -139,10 +139,17 @@ var useImage = function useImage() {
|
|
139
139
|
offset: typeof lazy === 'number' ? lazy : 0,
|
140
140
|
element: elementRef.current,
|
141
141
|
render: markToRender,
|
142
|
+
offscreen: function offscreen() {
|
143
|
+
setStatus(PLACEHOLDER);
|
144
|
+
},
|
145
|
+
noRemove: props.inViewOnly,
|
142
146
|
container: typeof container === 'string' ? document.querySelector(container) : container
|
143
147
|
});
|
144
148
|
}
|
145
149
|
}
|
150
|
+
return function () {
|
151
|
+
if (lazyId) (0, _utils.removeStack)(lazyId);
|
152
|
+
};
|
146
153
|
}, [src]);
|
147
154
|
return {
|
148
155
|
src: src,
|
@@ -54,6 +54,13 @@ export interface BaseImageProps {
|
|
54
54
|
* @default false
|
55
55
|
*/
|
56
56
|
lazy?: boolean | number;
|
57
|
+
/**
|
58
|
+
* @en Whether to load only when in view
|
59
|
+
* @cn 是否仅在视图内加载
|
60
|
+
* @default false
|
61
|
+
* @version 3.4.5 3.4.4-beta.83.5.0
|
62
|
+
*/
|
63
|
+
inViewOnly?: boolean;
|
57
64
|
/**
|
58
65
|
* @en The original property of html
|
59
66
|
* @cn 是否禁止 img 元素原生 draggable 属性
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-image.type.d.ts","sourceRoot":"","sources":["use-image.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,QAAQ,GAAG,WAAW,CAAC;AAChE,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,GAAG,SAAS,CAAC;AACjE,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,WAAW,CAAC;AAE1E,MAAM,MAAM,MAAM,GAAG;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CA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oB,CAAC;CACjC,CAAC;AAoBF,wBAAgB,QAAQ,SAgBvB;AAWD,wBAAgB,WAAW,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,cAAc,CAAC,EAAE,OAAO,QAUvE;
|
1
|
+
{"version":3,"file":"lazyload.d.ts","sourceRoot":"","sources":["lazyload.ts"],"names":[],"mappings":"AAIA,KAAK,UAAU,GAAG;IAChB,SAAS,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,oBAAoB,CAAC;CACjC,CAAC;AAoBF,wBAAgB,QAAQ,SAgBvB;AAWD,wBAAgB,WAAW,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,cAAc,CAAC,EAAE,OAAO,QAUvE;AAwBD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,UAAU,iBA4BvC"}
|
package/cjs/utils/lazyload.js
CHANGED
@@ -68,12 +68,15 @@ function getObserver(obj, id) {
|
|
68
68
|
container = _obj$container === void 0 ? null : _obj$container,
|
69
69
|
offset = obj.offset,
|
70
70
|
render = obj.render,
|
71
|
+
offscreen = obj.offscreen,
|
71
72
|
noRemove = obj.noRemove;
|
72
73
|
var observer = new IntersectionObserver(function (entries) {
|
73
74
|
entries.forEach(function (en) {
|
74
75
|
if (en.isIntersecting || en.intersectionRatio > 0) {
|
75
76
|
render();
|
76
77
|
if (!noRemove) removeStack(id);
|
78
|
+
} else {
|
79
|
+
offscreen && offscreen();
|
77
80
|
}
|
78
81
|
});
|
79
82
|
}, {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-image.d.ts","sourceRoot":"","sources":["use-image.ts"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AACzC,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG5D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAWlD,QAAA,MAAM,QAAQ,WAAW,cAAc;;;;;;;;;;yBA6D3B,gBAAgB,CAAC,gBAAgB,GAAG,cAAc,CAAC;;;;;;;;;;;
|
1
|
+
{"version":3,"file":"use-image.d.ts","sourceRoot":"","sources":["use-image.ts"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AACzC,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG5D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAWlD,QAAA,MAAM,QAAQ,WAAW,cAAc;;;;;;;;;;yBA6D3B,gBAAgB,CAAC,gBAAgB,GAAG,cAAc,CAAC;;;;;;;;;;;CAmF9D,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
@@ -132,10 +132,17 @@ var useImage = function useImage() {
|
|
132
132
|
offset: typeof lazy === 'number' ? lazy : 0,
|
133
133
|
element: elementRef.current,
|
134
134
|
render: markToRender,
|
135
|
+
offscreen: function offscreen() {
|
136
|
+
setStatus(PLACEHOLDER);
|
137
|
+
},
|
138
|
+
noRemove: props.inViewOnly,
|
135
139
|
container: typeof container === 'string' ? document.querySelector(container) : container
|
136
140
|
});
|
137
141
|
}
|
138
142
|
}
|
143
|
+
return function () {
|
144
|
+
if (lazyId) removeStack(lazyId);
|
145
|
+
};
|
139
146
|
}, [src]);
|
140
147
|
return {
|
141
148
|
src: src,
|
@@ -54,6 +54,13 @@ export interface BaseImageProps {
|
|
54
54
|
* @default false
|
55
55
|
*/
|
56
56
|
lazy?: boolean | number;
|
57
|
+
/**
|
58
|
+
* @en Whether to load only when in view
|
59
|
+
* @cn 是否仅在视图内加载
|
60
|
+
* @default false
|
61
|
+
* @version 3.4.5 3.4.4-beta.83.5.0
|
62
|
+
*/
|
63
|
+
inViewOnly?: boolean;
|
57
64
|
/**
|
58
65
|
* @en The original property of html
|
59
66
|
* @cn 是否禁止 img 元素原生 draggable 属性
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-image.type.d.ts","sourceRoot":"","sources":["use-image.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,QAAQ,GAAG,WAAW,CAAC;AAChE,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,GAAG,SAAS,CAAC;AACjE,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,WAAW,CAAC;AAE1E,MAAM,MAAM,MAAM,GAAG;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,WAAW,cAAc;IAC7B;;;;;;;;;OASG;IACH;;;OAGG;IACH,GAAG,CAAC,EAAE,YAAY,CAAC;IAEnB;;;;OAIG;IACH;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;IAEjC;;;;OAIG;IACH;;;OAGG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;
|
1
|
+
{"version":3,"file":"use-image.type.d.ts","sourceRoot":"","sources":["use-image.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,QAAQ,GAAG,WAAW,CAAC;AAChE,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,GAAG,SAAS,C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AAE,KAAK,CAAC,iBAAiB,CAAC;IAClC;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC5C"}
|
package/esm/utils/lazyload.d.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"lazyload.d.ts","sourceRoot":"","sources":["lazyload.ts"],"names":[],"mappings":"AAIA,KAAK,UAAU,GAAG;IAChB,SAAS,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,oBAAoB,CAAC;CACjC,CAAC;AAoBF,wBAAgB,QAAQ,SAgBvB;AAWD,wBAAgB,WAAW,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,cAAc,CAAC,EAAE,OAAO,QAUvE;
|
1
|
+
{"version":3,"file":"lazyload.d.ts","sourceRoot":"","sources":["lazyload.ts"],"names":[],"mappings":"AAIA,KAAK,UAAU,GAAG;IAChB,SAAS,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,oBAAoB,CAAC;CACjC,CAAC;AAoBF,wBAAgB,QAAQ,SAgBvB;AAWD,wBAAgB,WAAW,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,cAAc,CAAC,EAAE,OAAO,QAUvE;AAwBD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,UAAU,iBA4BvC"}
|
package/esm/utils/lazyload.js
CHANGED
@@ -60,12 +60,15 @@ function getObserver(obj, id) {
|
|
60
60
|
container = _obj$container === void 0 ? null : _obj$container,
|
61
61
|
offset = obj.offset,
|
62
62
|
render = obj.render,
|
63
|
+
offscreen = obj.offscreen,
|
63
64
|
noRemove = obj.noRemove;
|
64
65
|
var observer = new IntersectionObserver(function (entries) {
|
65
66
|
entries.forEach(function (en) {
|
66
67
|
if (en.isIntersecting || en.intersectionRatio > 0) {
|
67
68
|
render();
|
68
69
|
if (!noRemove) removeStack(id);
|
70
|
+
} else {
|
71
|
+
offscreen && offscreen();
|
69
72
|
}
|
70
73
|
});
|
71
74
|
}, {
|