@mts-pjsc/image-optimize 1.1.5 → 1.2.0
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.
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
export interface IImageOptions {
|
|
2
|
+
export interface IImageOptions extends React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement> {
|
|
3
3
|
src: string;
|
|
4
4
|
alt: string;
|
|
5
5
|
offset?: number;
|
|
6
6
|
quality?: number;
|
|
7
|
-
className?: string;
|
|
8
7
|
setRef?: (elem: HTMLImageElement | null) => void;
|
|
9
8
|
}
|
|
10
9
|
export declare class Image<P extends IImageOptions> extends React.Component<P> {
|
package/dist/components/Image.js
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
1
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
13
|
import * as React from "react";
|
|
3
14
|
import { getFormatFeatures } from "../helpers/get-format-features.js";
|
|
@@ -27,19 +38,20 @@ export class Image extends React.Component {
|
|
|
27
38
|
this.checks = 0;
|
|
28
39
|
// Raf for correct image position after redraw outer components
|
|
29
40
|
requestAnimationFrame(() => this.checkImage());
|
|
30
|
-
return true;
|
|
31
41
|
}
|
|
32
|
-
return
|
|
42
|
+
return true;
|
|
33
43
|
}
|
|
34
44
|
componentWillUnmount() {
|
|
35
45
|
window.removeEventListener("resize", this.windowResizeHandler);
|
|
36
46
|
}
|
|
37
47
|
render() {
|
|
38
|
-
|
|
48
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
49
|
+
const _a = this.props, { offset, quality, setRef, src, alt } = _a, props = __rest(_a, ["offset", "quality", "setRef", "src", "alt"]);
|
|
50
|
+
return (_jsx("img", Object.assign({}, props, { alt: alt, onLoad: () => requestAnimationFrame(() => this.checkImage()), ref: (elem) => {
|
|
39
51
|
var _a, _b;
|
|
40
52
|
this.thisComponent = elem;
|
|
41
53
|
(_b = (_a = this.props).setRef) === null || _b === void 0 ? void 0 : _b.call(_a, elem);
|
|
42
|
-
}, src: this.resultUrl }));
|
|
54
|
+
}, src: this.resultUrl })));
|
|
43
55
|
}
|
|
44
56
|
async checkImage(isResize = false) {
|
|
45
57
|
if (this.checks > 1) {
|