@douyinfe/semi-ui 2.49.0-beta.0 → 2.49.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.
- package/dist/umd/semi-ui.js +248 -249
- package/dist/umd/semi-ui.js.map +1 -1
- package/dist/umd/semi-ui.min.js +1 -1
- package/dist/umd/semi-ui.min.js.map +1 -1
- package/lib/cjs/image/interface.d.ts +3 -3
- package/lib/cjs/image/previewFooter.js +5 -8
- package/lib/cjs/image/previewHeader.d.ts +2 -2
- package/lib/cjs/image/previewHeader.js +9 -8
- package/lib/cjs/image/previewImage.d.ts +1 -12
- package/lib/cjs/image/previewImage.js +23 -83
- package/lib/cjs/image/previewInner.d.ts +11 -2
- package/lib/cjs/image/previewInner.js +60 -42
- package/lib/es/image/interface.d.ts +3 -3
- package/lib/es/image/previewFooter.js +5 -8
- package/lib/es/image/previewHeader.d.ts +2 -2
- package/lib/es/image/previewHeader.js +4 -3
- package/lib/es/image/previewImage.d.ts +1 -12
- package/lib/es/image/previewImage.js +23 -83
- package/lib/es/image/previewInner.d.ts +11 -2
- package/lib/es/image/previewInner.js +60 -42
- package/package.json +8 -8
package/dist/umd/semi-ui.js
CHANGED
|
@@ -69381,6 +69381,7 @@ class SelectFoundation extends foundation {
|
|
|
69381
69381
|
this.close(e);
|
|
69382
69382
|
this._notifyBlur(e);
|
|
69383
69383
|
this._adapter.updateFocusState(false);
|
|
69384
|
+
this._adapter.unregisterClickOutsideHandler();
|
|
69384
69385
|
});
|
|
69385
69386
|
}
|
|
69386
69387
|
toggle2SearchInput(isShow) {
|
|
@@ -69398,7 +69399,6 @@ class SelectFoundation extends foundation {
|
|
|
69398
69399
|
this._adapter.setIsFocusInContainer(false);
|
|
69399
69400
|
// this.unBindKeyBoardEvent();
|
|
69400
69401
|
// this._notifyBlur(e);
|
|
69401
|
-
this._adapter.unregisterClickOutsideHandler();
|
|
69402
69402
|
// this._adapter.updateFocusState(false);
|
|
69403
69403
|
const isFilterable = this._isFilterable();
|
|
69404
69404
|
if (isFilterable) {
|
|
@@ -98950,14 +98950,14 @@ const PreviewContext = /*#__PURE__*/(0,external_root_React_commonjs2_react_commo
|
|
|
98950
98950
|
|
|
98951
98951
|
|
|
98952
98952
|
const previewHeader_prefixCls = `${image_constants_cssClasses.PREFIX}-preview-header`;
|
|
98953
|
-
const previewHeader_Header = _ref => {
|
|
98953
|
+
const previewHeader_Header = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.forwardRef)((_ref, ref) => {
|
|
98954
98954
|
let {
|
|
98955
98955
|
onClose,
|
|
98956
98956
|
titleStyle,
|
|
98957
98957
|
className,
|
|
98958
98958
|
renderHeader
|
|
98959
98959
|
} = _ref;
|
|
98960
|
-
return /*#__PURE__*/
|
|
98960
|
+
return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(PreviewContext.Consumer, null, _ref2 => {
|
|
98961
98961
|
let {
|
|
98962
98962
|
currentIndex,
|
|
98963
98963
|
titles
|
|
@@ -98966,17 +98966,18 @@ const previewHeader_Header = _ref => {
|
|
|
98966
98966
|
if (titles && typeof currentIndex === "number") {
|
|
98967
98967
|
title = titles[currentIndex];
|
|
98968
98968
|
}
|
|
98969
|
-
return /*#__PURE__*/
|
|
98969
|
+
return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("section", {
|
|
98970
|
+
ref: ref,
|
|
98970
98971
|
className: classnames_default()(previewHeader_prefixCls, className)
|
|
98971
|
-
}, /*#__PURE__*/
|
|
98972
|
+
}, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("section", {
|
|
98972
98973
|
className: `${previewHeader_prefixCls}-title`,
|
|
98973
98974
|
style: titleStyle
|
|
98974
|
-
}, renderHeader ? renderHeader(title) : title), /*#__PURE__*/
|
|
98975
|
+
}, renderHeader ? renderHeader(title) : title), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("section", {
|
|
98975
98976
|
className: `${previewHeader_prefixCls}-close`,
|
|
98976
98977
|
onMouseUp: onClose
|
|
98977
|
-
}, /*#__PURE__*/
|
|
98978
|
+
}, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(IconClose, null)));
|
|
98978
98979
|
});
|
|
98979
|
-
};
|
|
98980
|
+
});
|
|
98980
98981
|
/* harmony default export */ const previewHeader = (previewHeader_Header);
|
|
98981
98982
|
;// CONCATENATED MODULE: ../semi-icons/lib/es/icons/IconMinus.js
|
|
98982
98983
|
|
|
@@ -99132,7 +99133,6 @@ class PreviewFooterFoundation extends foundation {
|
|
|
99132
99133
|
} else {
|
|
99133
99134
|
onZoomOut(Number((value / 100).toFixed(2)));
|
|
99134
99135
|
}
|
|
99135
|
-
this._adapter.setStartMouseOffset(value);
|
|
99136
99136
|
};
|
|
99137
99137
|
this.handleRatioClick = () => {
|
|
99138
99138
|
const {
|
|
@@ -99165,14 +99165,9 @@ class PreviewFooterFoundation extends foundation {
|
|
|
99165
99165
|
|
|
99166
99166
|
const previewFooter_prefixCls = image_constants_cssClasses.PREFIX;
|
|
99167
99167
|
const footerPrefixCls = `${image_constants_cssClasses.PREFIX}-preview-footer`;
|
|
99168
|
-
let mouseActiveTime = 0;
|
|
99169
99168
|
class previewFooter_Footer extends BaseComponent {
|
|
99170
99169
|
get adapter() {
|
|
99171
|
-
return Object.assign(
|
|
99172
|
-
setStartMouseOffset: time => {
|
|
99173
|
-
mouseActiveTime = time;
|
|
99174
|
-
}
|
|
99175
|
-
});
|
|
99170
|
+
return Object.assign({}, super.adapter);
|
|
99176
99171
|
}
|
|
99177
99172
|
constructor(props) {
|
|
99178
99173
|
super(props);
|
|
@@ -99412,13 +99407,15 @@ class previewFooter_Footer extends BaseComponent {
|
|
|
99412
99407
|
render() {
|
|
99413
99408
|
const {
|
|
99414
99409
|
className,
|
|
99415
|
-
renderPreviewMenu
|
|
99410
|
+
renderPreviewMenu,
|
|
99411
|
+
forwardRef
|
|
99416
99412
|
} = this.props;
|
|
99417
99413
|
const menuCls = classnames_default()(footerPrefixCls, `${footerPrefixCls}-wrapper`, className, {
|
|
99418
99414
|
[`${footerPrefixCls}-content`]: !Boolean(renderPreviewMenu)
|
|
99419
99415
|
});
|
|
99420
99416
|
return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("section", {
|
|
99421
|
-
className: menuCls
|
|
99417
|
+
className: menuCls,
|
|
99418
|
+
ref: forwardRef
|
|
99422
99419
|
}, renderPreviewMenu ? this.customRenderViewMenu() : this.getFooterMenu());
|
|
99423
99420
|
}
|
|
99424
99421
|
}
|
|
@@ -99457,9 +99454,6 @@ previewFooter_Footer.defaultProps = {
|
|
|
99457
99454
|
};
|
|
99458
99455
|
;// CONCATENATED MODULE: ../semi-foundation/image/previewImageFoundation.ts
|
|
99459
99456
|
|
|
99460
|
-
|
|
99461
|
-
|
|
99462
|
-
|
|
99463
99457
|
const DefaultDOMRect = {
|
|
99464
99458
|
bottom: 0,
|
|
99465
99459
|
height: 0,
|
|
@@ -99474,6 +99468,12 @@ const DefaultDOMRect = {
|
|
|
99474
99468
|
class PreviewImageFoundation extends foundation {
|
|
99475
99469
|
constructor(adapter) {
|
|
99476
99470
|
super(Object.assign({}, adapter));
|
|
99471
|
+
this.startMouseOffset = {
|
|
99472
|
+
x: 0,
|
|
99473
|
+
y: 0
|
|
99474
|
+
};
|
|
99475
|
+
this.originImageWidth = null;
|
|
99476
|
+
this.originImageHeight = null;
|
|
99477
99477
|
this._isImageVertical = () => this.getProp("rotation") % 180 !== 0;
|
|
99478
99478
|
this._getImageBounds = () => {
|
|
99479
99479
|
const imageDOM = this._adapter.getImage();
|
|
@@ -99503,32 +99503,18 @@ class PreviewImageFoundation extends foundation {
|
|
|
99503
99503
|
this._adapter.setLoading(loading);
|
|
99504
99504
|
};
|
|
99505
99505
|
this.handleWindowResize = () => {
|
|
99506
|
-
|
|
99507
|
-
|
|
99508
|
-
setRatio
|
|
99509
|
-
} = this.getProps();
|
|
99510
|
-
const {
|
|
99511
|
-
originImageWidth,
|
|
99512
|
-
originImageHeight
|
|
99513
|
-
} = this._adapter.getOriginImageSize();
|
|
99514
|
-
if (originImageWidth && originImageHeight) {
|
|
99515
|
-
if (ratio !== "adaptation") {
|
|
99516
|
-
setRatio("adaptation");
|
|
99517
|
-
} else {
|
|
99518
|
-
this.handleResizeImage();
|
|
99519
|
-
}
|
|
99506
|
+
if (this.originImageWidth && this.originImageHeight) {
|
|
99507
|
+
this.handleResizeImage();
|
|
99520
99508
|
}
|
|
99521
99509
|
};
|
|
99522
99510
|
this.handleLoad = e => {
|
|
99523
99511
|
if (e.target) {
|
|
99524
99512
|
const {
|
|
99525
|
-
|
|
99526
|
-
|
|
99513
|
+
naturalWidth: w,
|
|
99514
|
+
naturalHeight: h
|
|
99527
99515
|
} = e.target;
|
|
99528
|
-
this.
|
|
99529
|
-
|
|
99530
|
-
originImageHeight: h
|
|
99531
|
-
});
|
|
99516
|
+
this.originImageHeight = h;
|
|
99517
|
+
this.originImageWidth = w;
|
|
99532
99518
|
this.setState({
|
|
99533
99519
|
loading: false
|
|
99534
99520
|
});
|
|
@@ -99553,13 +99539,14 @@ class PreviewImageFoundation extends foundation {
|
|
|
99553
99539
|
this.handleResizeImage = () => {
|
|
99554
99540
|
const horizontal = !this._isImageVertical();
|
|
99555
99541
|
const {
|
|
99556
|
-
|
|
99557
|
-
|
|
99558
|
-
|
|
99559
|
-
const
|
|
99560
|
-
const imgHeight = horizontal ? originImageHeight : originImageWidth;
|
|
99542
|
+
currZoom
|
|
99543
|
+
} = this.getStates();
|
|
99544
|
+
const imgWidth = horizontal ? this.originImageWidth : this.originImageHeight;
|
|
99545
|
+
const imgHeight = horizontal ? this.originImageHeight : this.originImageWidth;
|
|
99561
99546
|
const {
|
|
99562
|
-
onZoom
|
|
99547
|
+
onZoom,
|
|
99548
|
+
setRatio,
|
|
99549
|
+
ratio
|
|
99563
99550
|
} = this.getProps();
|
|
99564
99551
|
const containerDOM = this._adapter.getContainer();
|
|
99565
99552
|
if (containerDOM) {
|
|
@@ -99569,8 +99556,44 @@ class PreviewImageFoundation extends foundation {
|
|
|
99569
99556
|
} = this._getContainerBounds();
|
|
99570
99557
|
const reservedWidth = containerWidth - 80;
|
|
99571
99558
|
const reservedHeight = containerHeight - 80;
|
|
99572
|
-
|
|
99573
|
-
|
|
99559
|
+
let _zoom = 1;
|
|
99560
|
+
if (imgWidth > reservedWidth || imgHeight > reservedHeight) {
|
|
99561
|
+
_zoom = Number(Math.min(reservedWidth / imgWidth, reservedHeight / imgHeight).toFixed(2));
|
|
99562
|
+
}
|
|
99563
|
+
if (currZoom === _zoom) {
|
|
99564
|
+
this.calculatePreviewImage(_zoom, null);
|
|
99565
|
+
} else {
|
|
99566
|
+
onZoom(_zoom);
|
|
99567
|
+
}
|
|
99568
|
+
}
|
|
99569
|
+
};
|
|
99570
|
+
this.handleRatioChange = () => {
|
|
99571
|
+
if (this.originImageWidth && this.originImageHeight) {
|
|
99572
|
+
const {
|
|
99573
|
+
currZoom
|
|
99574
|
+
} = this.getStates();
|
|
99575
|
+
const {
|
|
99576
|
+
ratio,
|
|
99577
|
+
onZoom
|
|
99578
|
+
} = this.getProps();
|
|
99579
|
+
let _zoom;
|
|
99580
|
+
if (ratio === 'adaptation') {
|
|
99581
|
+
const horizontal = !this._isImageVertical();
|
|
99582
|
+
const imgWidth = horizontal ? this.originImageWidth : this.originImageHeight;
|
|
99583
|
+
const imgHeight = horizontal ? this.originImageHeight : this.originImageWidth;
|
|
99584
|
+
const {
|
|
99585
|
+
width: containerWidth,
|
|
99586
|
+
height: containerHeight
|
|
99587
|
+
} = this._getContainerBounds();
|
|
99588
|
+
const reservedWidth = containerWidth - 80;
|
|
99589
|
+
const reservedHeight = containerHeight - 80;
|
|
99590
|
+
_zoom = Number(Math.min(reservedWidth / imgWidth, reservedHeight / imgHeight).toFixed(2));
|
|
99591
|
+
} else {
|
|
99592
|
+
_zoom = 1;
|
|
99593
|
+
}
|
|
99594
|
+
if (currZoom !== _zoom) {
|
|
99595
|
+
onZoom(_zoom);
|
|
99596
|
+
}
|
|
99574
99597
|
}
|
|
99575
99598
|
};
|
|
99576
99599
|
this.handleRightClickImage = e => {
|
|
@@ -99585,38 +99608,6 @@ class PreviewImageFoundation extends foundation {
|
|
|
99585
99608
|
return true;
|
|
99586
99609
|
}
|
|
99587
99610
|
};
|
|
99588
|
-
// e: WheelEvent<HTMLImageElement>
|
|
99589
|
-
this.handleWheel = e => {
|
|
99590
|
-
this.onWheel(e);
|
|
99591
|
-
handlePrevent(e);
|
|
99592
|
-
};
|
|
99593
|
-
// e: WheelEvent<HTMLImageElement>
|
|
99594
|
-
this.onWheel = throttle_default()(e => {
|
|
99595
|
-
const {
|
|
99596
|
-
onZoom,
|
|
99597
|
-
zoomStep,
|
|
99598
|
-
maxZoom,
|
|
99599
|
-
minZoom
|
|
99600
|
-
} = this.getProps();
|
|
99601
|
-
const {
|
|
99602
|
-
currZoom
|
|
99603
|
-
} = this.getStates();
|
|
99604
|
-
let _zoom;
|
|
99605
|
-
if (e.deltaY < 0) {
|
|
99606
|
-
/* zoom in */
|
|
99607
|
-
if (currZoom + zoomStep <= maxZoom) {
|
|
99608
|
-
_zoom = Number((currZoom + zoomStep).toFixed(2));
|
|
99609
|
-
}
|
|
99610
|
-
} else if (e.deltaY > 0) {
|
|
99611
|
-
/* zoom out */
|
|
99612
|
-
if (currZoom - zoomStep >= minZoom) {
|
|
99613
|
-
_zoom = Number((currZoom - zoomStep).toFixed(2));
|
|
99614
|
-
}
|
|
99615
|
-
}
|
|
99616
|
-
if (!isUndefined_default()(_zoom)) {
|
|
99617
|
-
onZoom(_zoom);
|
|
99618
|
-
}
|
|
99619
|
-
}, 50);
|
|
99620
99611
|
this.calcCanDragDirection = () => {
|
|
99621
99612
|
const {
|
|
99622
99613
|
width,
|
|
@@ -99640,12 +99631,8 @@ class PreviewImageFoundation extends foundation {
|
|
|
99640
99631
|
canDragHorizontal
|
|
99641
99632
|
};
|
|
99642
99633
|
};
|
|
99643
|
-
this.
|
|
99634
|
+
this.calculatePreviewImage = (newZoom, e) => {
|
|
99644
99635
|
const imageDOM = this._adapter.getImage();
|
|
99645
|
-
const {
|
|
99646
|
-
originImageWidth,
|
|
99647
|
-
originImageHeight
|
|
99648
|
-
} = this._adapter.getOriginImageSize();
|
|
99649
99636
|
const {
|
|
99650
99637
|
canDragVertical,
|
|
99651
99638
|
canDragHorizontal
|
|
@@ -99655,8 +99642,8 @@ class PreviewImageFoundation extends foundation {
|
|
|
99655
99642
|
width: containerWidth,
|
|
99656
99643
|
height: containerHeight
|
|
99657
99644
|
} = this._getContainerBounds();
|
|
99658
|
-
const newWidth = Math.floor(originImageWidth * newZoom);
|
|
99659
|
-
const newHeight = Math.floor(originImageHeight * newZoom);
|
|
99645
|
+
const newWidth = Math.floor(this.originImageWidth * newZoom);
|
|
99646
|
+
const newHeight = Math.floor(this.originImageHeight * newZoom);
|
|
99660
99647
|
// debugger;
|
|
99661
99648
|
let _offset;
|
|
99662
99649
|
const horizontal = !this._isImageVertical();
|
|
@@ -99715,13 +99702,13 @@ class PreviewImageFoundation extends foundation {
|
|
|
99715
99702
|
width,
|
|
99716
99703
|
height
|
|
99717
99704
|
} = this.getStates();
|
|
99718
|
-
const startMouseMove = this._adapter.getMouseMove();
|
|
99719
|
-
const startMouseOffset = this._adapter.getMouseOffset();
|
|
99720
99705
|
const {
|
|
99721
99706
|
canDragVertical,
|
|
99722
99707
|
canDragHorizontal
|
|
99723
99708
|
} = this.calcCanDragDirection();
|
|
99724
|
-
|
|
99709
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
|
|
99710
|
+
const mouseLeftPress = e.buttons === 1;
|
|
99711
|
+
if (mouseLeftPress && (canDragVertical || canDragHorizontal)) {
|
|
99725
99712
|
const {
|
|
99726
99713
|
clientX,
|
|
99727
99714
|
clientY
|
|
@@ -99734,8 +99721,8 @@ class PreviewImageFoundation extends foundation {
|
|
|
99734
99721
|
left: extremeLeft,
|
|
99735
99722
|
top: extremeTop
|
|
99736
99723
|
} = this.calcExtremeBounds();
|
|
99737
|
-
let newX = canDragHorizontal ? clientX - containerLeft - startMouseOffset.x : offset.x;
|
|
99738
|
-
let newY = canDragVertical ? clientY - containerTop - startMouseOffset.y : offset.y;
|
|
99724
|
+
let newX = canDragHorizontal ? clientX - containerLeft - this.startMouseOffset.x : offset.x;
|
|
99725
|
+
let newY = canDragVertical ? clientY - containerTop - this.startMouseOffset.y : offset.y;
|
|
99739
99726
|
if (canDragHorizontal) {
|
|
99740
99727
|
newX = newX > 0 ? 0 : newX < extremeLeft ? extremeLeft : newX;
|
|
99741
99728
|
}
|
|
@@ -99754,11 +99741,7 @@ class PreviewImageFoundation extends foundation {
|
|
|
99754
99741
|
}
|
|
99755
99742
|
};
|
|
99756
99743
|
this.handleImageMouseDown = e => {
|
|
99757
|
-
this.
|
|
99758
|
-
this._adapter.setStartMouseMove(true);
|
|
99759
|
-
};
|
|
99760
|
-
this.handleImageMouseUp = () => {
|
|
99761
|
-
this._adapter.setStartMouseMove(false);
|
|
99744
|
+
this.startMouseOffset = this._getOffset(e);
|
|
99762
99745
|
};
|
|
99763
99746
|
}
|
|
99764
99747
|
}
|
|
@@ -99771,38 +99754,14 @@ class PreviewImageFoundation extends foundation {
|
|
|
99771
99754
|
|
|
99772
99755
|
const previewImage_prefixCls = image_constants_cssClasses.PREFIX;
|
|
99773
99756
|
const preViewImgPrefixCls = `${previewImage_prefixCls}-preview-image`;
|
|
99774
|
-
let originImageWidth = null;
|
|
99775
|
-
let originImageHeight = null;
|
|
99776
|
-
let startMouseMove = false;
|
|
99777
|
-
// startMouseOffset:The offset of the mouse relative to the left and top of the picture
|
|
99778
|
-
let startMouseOffset = {
|
|
99779
|
-
x: 0,
|
|
99780
|
-
y: 0
|
|
99781
|
-
};
|
|
99782
99757
|
class PreviewImage extends BaseComponent {
|
|
99783
99758
|
get adapter() {
|
|
99784
99759
|
return Object.assign(Object.assign({}, super.adapter), {
|
|
99785
|
-
getOriginImageSize: () => ({
|
|
99786
|
-
originImageWidth,
|
|
99787
|
-
originImageHeight
|
|
99788
|
-
}),
|
|
99789
|
-
setOriginImageSize: size => {
|
|
99790
|
-
originImageWidth = size.originImageWidth;
|
|
99791
|
-
originImageHeight = size.originImageHeight;
|
|
99792
|
-
},
|
|
99793
99760
|
getContainer: () => {
|
|
99794
99761
|
return this.containerRef.current;
|
|
99795
99762
|
},
|
|
99796
99763
|
getImage: () => {
|
|
99797
|
-
return this.imageRef;
|
|
99798
|
-
},
|
|
99799
|
-
getMouseMove: () => startMouseMove,
|
|
99800
|
-
setStartMouseMove: move => {
|
|
99801
|
-
startMouseMove = move;
|
|
99802
|
-
},
|
|
99803
|
-
getMouseOffset: () => startMouseOffset,
|
|
99804
|
-
setStartMouseOffset: offset => {
|
|
99805
|
-
startMouseOffset = offset;
|
|
99764
|
+
return this.imageRef.current;
|
|
99806
99765
|
},
|
|
99807
99766
|
setLoading: loading => {
|
|
99808
99767
|
this.setState({
|
|
@@ -99810,7 +99769,7 @@ class PreviewImage extends BaseComponent {
|
|
|
99810
99769
|
});
|
|
99811
99770
|
},
|
|
99812
99771
|
setImageCursor: canDrag => {
|
|
99813
|
-
this.imageRef.style.cursor = canDrag ? "grab" : "default";
|
|
99772
|
+
this.imageRef.current.style.cursor = canDrag ? "grab" : "default";
|
|
99814
99773
|
}
|
|
99815
99774
|
});
|
|
99816
99775
|
}
|
|
@@ -99819,52 +99778,22 @@ class PreviewImage extends BaseComponent {
|
|
|
99819
99778
|
this.onWindowResize = () => {
|
|
99820
99779
|
this.foundation.handleWindowResize();
|
|
99821
99780
|
};
|
|
99822
|
-
this.handleZoomChange = (newZoom, e) => {
|
|
99823
|
-
this.foundation.handleZoomChange(newZoom, e);
|
|
99824
|
-
};
|
|
99825
99781
|
// Determine the response method of right click according to the disableDownload parameter in props
|
|
99826
99782
|
this.handleRightClickImage = e => {
|
|
99827
99783
|
this.foundation.handleRightClickImage(e);
|
|
99828
99784
|
};
|
|
99829
|
-
this.handleWheel = e => {
|
|
99830
|
-
this.foundation.handleWheel(e);
|
|
99831
|
-
};
|
|
99832
99785
|
this.handleLoad = e => {
|
|
99833
99786
|
this.foundation.handleLoad(e);
|
|
99834
99787
|
};
|
|
99835
99788
|
this.handleError = e => {
|
|
99836
99789
|
this.foundation.handleError(e);
|
|
99837
99790
|
};
|
|
99838
|
-
this.resizeImage = () => {
|
|
99839
|
-
this.foundation.handleResizeImage();
|
|
99840
|
-
};
|
|
99841
99791
|
this.handleMoveImage = e => {
|
|
99842
99792
|
this.foundation.handleMoveImage(e);
|
|
99843
99793
|
};
|
|
99844
|
-
// 为什么通过ref注册wheel而不是使用onWheel事件?
|
|
99845
|
-
// 因为对于wheel事件,浏览器将 addEventListener 的 passive 默认值更改为 true。如此,事件监听器便不能取消事件,也不会在用户滚动页面时阻止页面呈现。
|
|
99846
|
-
// 这里我们需要保持页面不动,仅放大图片,因此此处需要将 passive 更改设置为 false。
|
|
99847
|
-
// Why register wheel via ref instead of using onWheel event?
|
|
99848
|
-
// Because for wheel events, the browser changes the passive default of addEventListener to true. This way, the event listener cannot cancel the event, nor prevent the page from rendering when the user scrolls.
|
|
99849
|
-
// Here we need to keep the page still and only zoom in on the image, so here we need to set the passive change to false.
|
|
99850
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#improving_scrolling_performance_with_passive_listeners。
|
|
99851
|
-
this.registryImageRef = ref => {
|
|
99852
|
-
if (this.imageRef) {
|
|
99853
|
-
this.imageRef.removeEventListener("wheel", this.handleWheel);
|
|
99854
|
-
}
|
|
99855
|
-
if (ref) {
|
|
99856
|
-
ref.addEventListener("wheel", this.handleWheel, {
|
|
99857
|
-
passive: false
|
|
99858
|
-
});
|
|
99859
|
-
}
|
|
99860
|
-
this.imageRef = ref;
|
|
99861
|
-
};
|
|
99862
99794
|
this.onImageMouseDown = e => {
|
|
99863
99795
|
this.foundation.handleImageMouseDown(e);
|
|
99864
99796
|
};
|
|
99865
|
-
this.onImageMouseUp = () => {
|
|
99866
|
-
this.foundation.handleImageMouseUp();
|
|
99867
|
-
};
|
|
99868
99797
|
this.state = {
|
|
99869
99798
|
width: 0,
|
|
99870
99799
|
height: 0,
|
|
@@ -99878,7 +99807,7 @@ class PreviewImage extends BaseComponent {
|
|
|
99878
99807
|
left: 0
|
|
99879
99808
|
};
|
|
99880
99809
|
this.containerRef = /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createRef();
|
|
99881
|
-
this.imageRef =
|
|
99810
|
+
this.imageRef = /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createRef();
|
|
99882
99811
|
this.foundation = new PreviewImageFoundation(this.adapter);
|
|
99883
99812
|
}
|
|
99884
99813
|
componentDidMount() {
|
|
@@ -99889,27 +99818,22 @@ class PreviewImage extends BaseComponent {
|
|
|
99889
99818
|
}
|
|
99890
99819
|
componentDidUpdate(prevProps, prevStates) {
|
|
99891
99820
|
// If src changes, start a new loading
|
|
99892
|
-
|
|
99821
|
+
const zoomChange = "zoom" in this.props && this.props.zoom !== this.state.currZoom;
|
|
99822
|
+
const srcChange = this.props.src && this.props.src !== prevProps.src;
|
|
99823
|
+
if (srcChange) {
|
|
99893
99824
|
this.foundation.setLoading(true);
|
|
99894
99825
|
}
|
|
99895
99826
|
// If the incoming zoom changes, other content changes are determined based on the new zoom value
|
|
99896
|
-
if (
|
|
99897
|
-
this.
|
|
99898
|
-
}
|
|
99899
|
-
// When the incoming ratio is changed, if it"s adaptation, then resizeImage is triggered to make the image adapt to the page
|
|
99900
|
-
// else if it"s adaptation is realSize, then onZoom(1) is called to make the image size the original size;
|
|
99901
|
-
if ("ratio" in this.props && this.props.ratio !== prevProps.ratio) {
|
|
99902
|
-
if (originImageWidth && originImageHeight) {
|
|
99903
|
-
if (this.props.ratio === "adaptation") {
|
|
99904
|
-
this.resizeImage();
|
|
99905
|
-
} else {
|
|
99906
|
-
this.props.onZoom(1);
|
|
99907
|
-
}
|
|
99908
|
-
}
|
|
99827
|
+
if (zoomChange) {
|
|
99828
|
+
this.foundation.calculatePreviewImage(this.props.zoom, null);
|
|
99909
99829
|
}
|
|
99910
|
-
|
|
99911
|
-
|
|
99912
|
-
|
|
99830
|
+
if (!zoomChange && !srcChange && prevProps) {
|
|
99831
|
+
if ("ratio" in this.props && this.props.ratio !== prevProps.ratio) {
|
|
99832
|
+
this.foundation.handleRatioChange();
|
|
99833
|
+
}
|
|
99834
|
+
if ("rotation" in this.props && this.props.rotation !== prevProps.rotation) {
|
|
99835
|
+
this.onWindowResize();
|
|
99836
|
+
}
|
|
99913
99837
|
}
|
|
99914
99838
|
}
|
|
99915
99839
|
render() {
|
|
@@ -99931,21 +99855,20 @@ class PreviewImage extends BaseComponent {
|
|
|
99931
99855
|
transform: `rotate(${-rotation}deg)`,
|
|
99932
99856
|
top,
|
|
99933
99857
|
left,
|
|
99934
|
-
width
|
|
99935
|
-
height
|
|
99858
|
+
width,
|
|
99859
|
+
height
|
|
99936
99860
|
};
|
|
99937
99861
|
return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
|
|
99938
99862
|
className: `${preViewImgPrefixCls}`,
|
|
99939
99863
|
ref: this.containerRef
|
|
99940
99864
|
}, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("img", {
|
|
99941
|
-
ref: this.
|
|
99865
|
+
ref: this.imageRef,
|
|
99942
99866
|
src: src,
|
|
99943
99867
|
alt: "previewImag",
|
|
99944
99868
|
className: `${preViewImgPrefixCls}-img`,
|
|
99945
99869
|
key: src,
|
|
99946
99870
|
onMouseMove: this.handleMoveImage,
|
|
99947
99871
|
onMouseDown: this.onImageMouseDown,
|
|
99948
|
-
onMouseUp: this.onImageMouseUp,
|
|
99949
99872
|
onContextMenu: this.handleRightClickImage,
|
|
99950
99873
|
onDragStart: e => e.preventDefault(),
|
|
99951
99874
|
onLoad: this.handleLoad,
|
|
@@ -99962,9 +99885,9 @@ PreviewImage.propTypes = {
|
|
|
99962
99885
|
src: (prop_types_default()).string,
|
|
99963
99886
|
rotation: (prop_types_default()).number,
|
|
99964
99887
|
style: (prop_types_default()).object,
|
|
99965
|
-
maxZoom:
|
|
99966
|
-
minZoom:
|
|
99967
|
-
zoomStep:
|
|
99888
|
+
// maxZoom: PropTypes.number,
|
|
99889
|
+
// minZoom: PropTypes.number,
|
|
99890
|
+
// zoomStep: PropTypes.number,
|
|
99968
99891
|
zoom: (prop_types_default()).number,
|
|
99969
99892
|
ratio: (prop_types_default()).string,
|
|
99970
99893
|
disableDownload: (prop_types_default()).bool,
|
|
@@ -99975,9 +99898,9 @@ PreviewImage.propTypes = {
|
|
|
99975
99898
|
onError: (prop_types_default()).func
|
|
99976
99899
|
};
|
|
99977
99900
|
PreviewImage.defaultProps = {
|
|
99978
|
-
maxZoom: 5,
|
|
99979
|
-
minZoom: 0.1,
|
|
99980
|
-
zoomStep: 0.1,
|
|
99901
|
+
// maxZoom: 5,
|
|
99902
|
+
// minZoom: 0.1,
|
|
99903
|
+
// zoomStep: 0.1,
|
|
99981
99904
|
zoom: undefined
|
|
99982
99905
|
};
|
|
99983
99906
|
;// CONCATENATED MODULE: ../semi-foundation/image/utils.ts
|
|
@@ -100072,40 +99995,91 @@ const getPreloadImagArr = (imgSrc, currentIndex, preLoadGap, infinite) => {
|
|
|
100072
99995
|
|
|
100073
99996
|
|
|
100074
99997
|
|
|
99998
|
+
|
|
99999
|
+
|
|
100000
|
+
|
|
100075
100001
|
const NOT_CLOSE_TARGETS = ["icon", "footer"];
|
|
100076
|
-
const STOP_CLOSE_TARGET = ["icon", "footer", "header"];
|
|
100002
|
+
const STOP_CLOSE_TARGET = (/* unused pure expression or super */ null && (["icon", "footer", "header"]));
|
|
100077
100003
|
class PreviewInnerFoundation extends foundation {
|
|
100078
100004
|
constructor(adapter) {
|
|
100079
100005
|
super(Object.assign({}, adapter));
|
|
100006
|
+
this._timer = null;
|
|
100007
|
+
this._startMouseDown = {
|
|
100008
|
+
x: 0,
|
|
100009
|
+
y: 0
|
|
100010
|
+
};
|
|
100080
100011
|
this.handleViewVisibleChange = () => {
|
|
100081
|
-
const nowTime = new Date().getTime();
|
|
100082
|
-
const mouseActiveTime = this._adapter.getMouseActiveTime();
|
|
100083
|
-
const stopTiming = this._adapter.getStopTiming();
|
|
100084
|
-
const {
|
|
100085
|
-
viewerVisibleDelay
|
|
100086
|
-
} = this.getProps();
|
|
100087
100012
|
const {
|
|
100088
100013
|
viewerVisible
|
|
100089
100014
|
} = this.getStates();
|
|
100090
|
-
if (
|
|
100091
|
-
|
|
100015
|
+
if (viewerVisible) {
|
|
100016
|
+
this.setState({
|
|
100092
100017
|
viewerVisible: false
|
|
100093
100018
|
});
|
|
100019
|
+
this.clearTimer();
|
|
100020
|
+
}
|
|
100021
|
+
};
|
|
100022
|
+
this.handleMouseMove = e => {
|
|
100023
|
+
this._persistEvent(e);
|
|
100024
|
+
this.mouseMoveHandler(e);
|
|
100025
|
+
};
|
|
100026
|
+
this.mouseMoveHandler = throttle_default()(e => {
|
|
100027
|
+
const {
|
|
100028
|
+
viewerVisible
|
|
100029
|
+
} = this.getStates();
|
|
100030
|
+
const isValidTarget = this._adapter.isValidTarget(e);
|
|
100031
|
+
if (isValidTarget) {
|
|
100032
|
+
if (!viewerVisible) {
|
|
100033
|
+
this.setState({
|
|
100034
|
+
viewerVisible: true
|
|
100035
|
+
});
|
|
100036
|
+
}
|
|
100037
|
+
this.updateTimer();
|
|
100038
|
+
} else {
|
|
100039
|
+
this.clearTimer();
|
|
100094
100040
|
}
|
|
100041
|
+
}, 50);
|
|
100042
|
+
this.updateTimer = () => {
|
|
100043
|
+
const {
|
|
100044
|
+
viewerVisibleDelay
|
|
100045
|
+
} = this.getProps();
|
|
100046
|
+
this.clearTimer();
|
|
100047
|
+
this._timer = setTimeout(this.handleViewVisibleChange, viewerVisibleDelay);
|
|
100095
100048
|
};
|
|
100096
|
-
this.
|
|
100097
|
-
|
|
100098
|
-
|
|
100099
|
-
this.
|
|
100100
|
-
} else if (isTarget && event === "out") {
|
|
100101
|
-
this._adapter.setStopTiming(false);
|
|
100049
|
+
this.clearTimer = () => {
|
|
100050
|
+
if (this._timer) {
|
|
100051
|
+
clearTimeout(this._timer);
|
|
100052
|
+
this._timer = null;
|
|
100102
100053
|
}
|
|
100103
100054
|
};
|
|
100104
|
-
this.
|
|
100105
|
-
this.
|
|
100106
|
-
|
|
100107
|
-
|
|
100108
|
-
|
|
100055
|
+
this.handleWheel = e => {
|
|
100056
|
+
this.onWheel(e);
|
|
100057
|
+
handlePrevent(e);
|
|
100058
|
+
};
|
|
100059
|
+
this.onWheel = e => {
|
|
100060
|
+
const {
|
|
100061
|
+
zoomStep,
|
|
100062
|
+
maxZoom,
|
|
100063
|
+
minZoom
|
|
100064
|
+
} = this.getProps();
|
|
100065
|
+
const {
|
|
100066
|
+
zoom: currZoom
|
|
100067
|
+
} = this.getStates();
|
|
100068
|
+
let _zoom;
|
|
100069
|
+
if (e.deltaY < 0) {
|
|
100070
|
+
/* zoom in */
|
|
100071
|
+
if (currZoom + zoomStep <= maxZoom) {
|
|
100072
|
+
_zoom = Number((currZoom + zoomStep).toFixed(2));
|
|
100073
|
+
}
|
|
100074
|
+
} else if (e.deltaY > 0) {
|
|
100075
|
+
/* zoom out */
|
|
100076
|
+
if (currZoom - zoomStep >= minZoom) {
|
|
100077
|
+
_zoom = Number((currZoom - zoomStep).toFixed(2));
|
|
100078
|
+
}
|
|
100079
|
+
}
|
|
100080
|
+
if (!isUndefined_default()(_zoom)) {
|
|
100081
|
+
this.handleZoomImage(_zoom);
|
|
100082
|
+
}
|
|
100109
100083
|
};
|
|
100110
100084
|
this.handleMouseUp = e => {
|
|
100111
100085
|
const {
|
|
@@ -100119,7 +100093,7 @@ class PreviewInnerFoundation extends foundation {
|
|
|
100119
100093
|
const {
|
|
100120
100094
|
x,
|
|
100121
100095
|
y
|
|
100122
|
-
} = this.
|
|
100096
|
+
} = this._startMouseDown;
|
|
100123
100097
|
// 对鼠标移动做容错处理,当 x 和 y 方向在 mouseUp 的时候移动距离都小于等于 5px 时候就可以关闭预览
|
|
100124
100098
|
// Error-tolerant processing of mouse movement, when the movement distance in the x and y directions is less than or equal to 5px in mouseUp, the preview can be closed
|
|
100125
100099
|
// 不做容错处理的话,直接用 clientX !== x || y !== clientY 做判断,鼠标在用户点击时候无意识的轻微移动无法关闭预览,不符合用户预期
|
|
@@ -100136,7 +100110,10 @@ class PreviewInnerFoundation extends foundation {
|
|
|
100136
100110
|
clientX,
|
|
100137
100111
|
clientY
|
|
100138
100112
|
} = e;
|
|
100139
|
-
this.
|
|
100113
|
+
this._startMouseDown = {
|
|
100114
|
+
x: clientX,
|
|
100115
|
+
y: clientY
|
|
100116
|
+
};
|
|
100140
100117
|
};
|
|
100141
100118
|
this.handleKeyDown = e => {
|
|
100142
100119
|
const {
|
|
@@ -100209,10 +100186,12 @@ class PreviewInnerFoundation extends foundation {
|
|
|
100209
100186
|
const {
|
|
100210
100187
|
zoom
|
|
100211
100188
|
} = this.getStates();
|
|
100212
|
-
|
|
100213
|
-
|
|
100214
|
-
|
|
100215
|
-
|
|
100189
|
+
if (zoom !== newZoom) {
|
|
100190
|
+
this._adapter.notifyZoom(newZoom, newZoom > zoom);
|
|
100191
|
+
this.setState({
|
|
100192
|
+
zoom: newZoom
|
|
100193
|
+
});
|
|
100194
|
+
}
|
|
100216
100195
|
};
|
|
100217
100196
|
// 当 visible 改变之后,预览组件完成首张图片加载后,启动预加载
|
|
100218
100197
|
// 如: 1,2,3,4,5,6,7,8张图片, 点击第 4 张图片,preLoadGap 为 2
|
|
@@ -100330,10 +100309,12 @@ class PreviewInnerFoundation extends foundation {
|
|
|
100330
100309
|
beforeShow() {
|
|
100331
100310
|
this._adapter.registerKeyDownListener();
|
|
100332
100311
|
this._adapter.disabledBodyScroll();
|
|
100312
|
+
this.updateTimer();
|
|
100333
100313
|
}
|
|
100334
100314
|
afterHide() {
|
|
100335
100315
|
this._adapter.unregisterKeyDownListener();
|
|
100336
100316
|
this._adapter.enabledBodyScroll();
|
|
100317
|
+
this.clearTimer();
|
|
100337
100318
|
}
|
|
100338
100319
|
}
|
|
100339
100320
|
;// CONCATENATED MODULE: ./image/previewInner.tsx
|
|
@@ -100353,14 +100334,6 @@ class PreviewInnerFoundation extends foundation {
|
|
|
100353
100334
|
|
|
100354
100335
|
|
|
100355
100336
|
const previewInner_prefixCls = image_constants_cssClasses.PREFIX;
|
|
100356
|
-
let startMouseDown = {
|
|
100357
|
-
x: 0,
|
|
100358
|
-
y: 0
|
|
100359
|
-
};
|
|
100360
|
-
let previewInner_mouseActiveTime = null;
|
|
100361
|
-
let stopTiming = false;
|
|
100362
|
-
let timer = null;
|
|
100363
|
-
// let bodyOverflowValue = document.body.style.overflow;
|
|
100364
100337
|
class PreviewInner extends BaseComponent {
|
|
100365
100338
|
get adapter() {
|
|
100366
100339
|
return Object.assign(Object.assign({}, super.adapter), {
|
|
@@ -100444,30 +100417,22 @@ class PreviewInner extends BaseComponent {
|
|
|
100444
100417
|
unregisterKeyDownListener: () => {
|
|
100445
100418
|
window && window.removeEventListener("keydown", this.handleKeyDown);
|
|
100446
100419
|
},
|
|
100447
|
-
getMouseActiveTime: () => {
|
|
100448
|
-
return previewInner_mouseActiveTime;
|
|
100449
|
-
},
|
|
100450
|
-
getStopTiming: () => {
|
|
100451
|
-
return stopTiming;
|
|
100452
|
-
},
|
|
100453
|
-
setStopTiming: value => {
|
|
100454
|
-
stopTiming = value;
|
|
100455
|
-
},
|
|
100456
|
-
getStartMouseDown: () => {
|
|
100457
|
-
return startMouseDown;
|
|
100458
|
-
},
|
|
100459
|
-
setStartMouseDown: (x, y) => {
|
|
100460
|
-
startMouseDown = {
|
|
100461
|
-
x,
|
|
100462
|
-
y
|
|
100463
|
-
};
|
|
100464
|
-
},
|
|
100465
|
-
setMouseActiveTime: time => {
|
|
100466
|
-
previewInner_mouseActiveTime = time;
|
|
100467
|
-
},
|
|
100468
100420
|
getSetDownloadFunc: () => {
|
|
100469
100421
|
var _a, _b;
|
|
100470
100422
|
return (_b = (_a = this.context) === null || _a === void 0 ? void 0 : _a.setDownloadName) !== null && _b !== void 0 ? _b : this.props.setDownloadName;
|
|
100423
|
+
},
|
|
100424
|
+
isValidTarget: e => {
|
|
100425
|
+
const headerDom = this.headerRef && this.headerRef.current;
|
|
100426
|
+
const footerDom = this.footerRef && this.footerRef.current;
|
|
100427
|
+
const leftIconDom = this.leftIconRef && this.leftIconRef.current;
|
|
100428
|
+
const rightIconDom = this.rightIconRef && this.rightIconRef.current;
|
|
100429
|
+
const target = e.target;
|
|
100430
|
+
if (headerDom && headerDom.contains(target) || footerDom && footerDom.contains(target) || leftIconDom && leftIconDom.contains(target) || rightIconDom && rightIconDom.contains(target)) {
|
|
100431
|
+
// Move in the operation area, return false
|
|
100432
|
+
return false;
|
|
100433
|
+
}
|
|
100434
|
+
// Move in the preview area except the operation area, return true
|
|
100435
|
+
return true;
|
|
100471
100436
|
}
|
|
100472
100437
|
});
|
|
100473
100438
|
}
|
|
@@ -100500,9 +100465,6 @@ class PreviewInner extends BaseComponent {
|
|
|
100500
100465
|
this.handleMouseMove = e => {
|
|
100501
100466
|
this.foundation.handleMouseMove(e);
|
|
100502
100467
|
};
|
|
100503
|
-
this.handleMouseEvent = (e, event) => {
|
|
100504
|
-
this.foundation.handleMouseMoveEvent(e, event);
|
|
100505
|
-
};
|
|
100506
100468
|
this.handleKeyDown = e => {
|
|
100507
100469
|
this.foundation.handleKeyDown(e);
|
|
100508
100470
|
};
|
|
@@ -100515,6 +100477,31 @@ class PreviewInner extends BaseComponent {
|
|
|
100515
100477
|
this.handleMouseDown = e => {
|
|
100516
100478
|
this.foundation.handleMouseDown(e);
|
|
100517
100479
|
};
|
|
100480
|
+
this.handleWheel = e => {
|
|
100481
|
+
this.foundation.handleWheel(e);
|
|
100482
|
+
};
|
|
100483
|
+
// 为什么通过 addEventListener 注册 wheel 事件而不是使用 onWheel 事件?
|
|
100484
|
+
// 因为 Passive Event Listeners(https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#improving_scrolling_performance_with_passive_listeners)
|
|
100485
|
+
// Passive Event Listeners 是一种优化技术,用于提高滚动性能。在默认情况下,浏览器会假设事件的监听器不会调用
|
|
100486
|
+
// preventDefault() 方法来阻止事件的默认行为,从而允许进行一些优化操作,例如滚动平滑。
|
|
100487
|
+
// 对于 Image 而言,如果使用触控板,双指朝不同方向分开放大图片,则需要 preventDefault 防止页面整体放大。
|
|
100488
|
+
// Why register wheel event through addEventListener instead of using onWheel event?
|
|
100489
|
+
// Because of Passive Event Listeners(an optimization technique used to improve scrolling performance. By default,
|
|
100490
|
+
// the browser will assume that event listeners will not call preventDefault() method to prevent the default behavior of the event,
|
|
100491
|
+
// allowing some optimization operations such as scroll smoothing.)
|
|
100492
|
+
// For Image, if we use the trackpad and spread your fingers in different directions to enlarge the image, we need to preventDefault
|
|
100493
|
+
// to prevent the page from being enlarged as a whole.
|
|
100494
|
+
this.registryImageWrapRef = ref => {
|
|
100495
|
+
if (this.imageWrapRef) {
|
|
100496
|
+
this.imageWrapRef.removeEventListener("wheel", this.handleWheel);
|
|
100497
|
+
}
|
|
100498
|
+
if (ref) {
|
|
100499
|
+
ref.addEventListener("wheel", this.handleWheel, {
|
|
100500
|
+
passive: false
|
|
100501
|
+
});
|
|
100502
|
+
}
|
|
100503
|
+
this.imageWrapRef = ref;
|
|
100504
|
+
};
|
|
100518
100505
|
this.state = {
|
|
100519
100506
|
imgSrc: [],
|
|
100520
100507
|
imgLoadStatus: new Map(),
|
|
@@ -100531,6 +100518,11 @@ class PreviewInner extends BaseComponent {
|
|
|
100531
100518
|
this.bodyOverflow = '';
|
|
100532
100519
|
this.originBodyWidth = '100%';
|
|
100533
100520
|
this.scrollBarWidth = 0;
|
|
100521
|
+
this.imageWrapRef = null;
|
|
100522
|
+
this.headerRef = /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createRef();
|
|
100523
|
+
this.footerRef = /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createRef();
|
|
100524
|
+
this.leftIconRef = /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createRef();
|
|
100525
|
+
this.rightIconRef = /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createRef();
|
|
100534
100526
|
}
|
|
100535
100527
|
static getDerivedStateFromProps(props, state) {
|
|
100536
100528
|
const willUpdateStates = {};
|
|
@@ -100546,6 +100538,9 @@ class PreviewInner extends BaseComponent {
|
|
|
100546
100538
|
willUpdateStates.visible = props.visible;
|
|
100547
100539
|
if (props.visible) {
|
|
100548
100540
|
willUpdateStates.preloadAfterVisibleChange = true;
|
|
100541
|
+
willUpdateStates.viewerVisible = true;
|
|
100542
|
+
willUpdateStates.rotation = 0;
|
|
100543
|
+
willUpdateStates.ratio = 'adaptation';
|
|
100549
100544
|
}
|
|
100550
100545
|
}
|
|
100551
100546
|
if ("currentIndex" in props && props.currentIndex !== state.currentIndex) {
|
|
@@ -100564,10 +100559,8 @@ class PreviewInner extends BaseComponent {
|
|
|
100564
100559
|
}
|
|
100565
100560
|
}
|
|
100566
100561
|
componentDidUpdate(prevProps, prevState) {
|
|
100567
|
-
if (
|
|
100568
|
-
|
|
100569
|
-
timer && clearInterval(timer);
|
|
100570
|
-
timer = setInterval(this.viewVisibleChange, 1000);
|
|
100562
|
+
if (prevProps.src !== this.props.src) {
|
|
100563
|
+
this.foundation.updateTimer();
|
|
100571
100564
|
}
|
|
100572
100565
|
// hide => show
|
|
100573
100566
|
if (!prevProps.visible && this.props.visible) {
|
|
@@ -100579,7 +100572,7 @@ class PreviewInner extends BaseComponent {
|
|
|
100579
100572
|
}
|
|
100580
100573
|
}
|
|
100581
100574
|
componentWillUnmount() {
|
|
100582
|
-
|
|
100575
|
+
this.foundation.clearTimer();
|
|
100583
100576
|
}
|
|
100584
100577
|
isInGroup() {
|
|
100585
100578
|
return Boolean(this.context && this.context.isGroup);
|
|
@@ -100644,10 +100637,10 @@ class PreviewInner extends BaseComponent {
|
|
|
100644
100637
|
style: style,
|
|
100645
100638
|
onMouseDown: this.handleMouseDown,
|
|
100646
100639
|
onMouseUp: this.handleMouseUp,
|
|
100647
|
-
|
|
100648
|
-
|
|
100649
|
-
onMouseOut: e => this.handleMouseEvent(e.nativeEvent, "out")
|
|
100640
|
+
ref: this.registryImageWrapRef,
|
|
100641
|
+
onMouseMove: this.handleMouseMove
|
|
100650
100642
|
}, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(previewHeader, {
|
|
100643
|
+
ref: this.headerRef,
|
|
100651
100644
|
className: classnames_default()(hideViewerCls),
|
|
100652
100645
|
onClose: this.handlePreviewClose,
|
|
100653
100646
|
renderHeader: renderHeader
|
|
@@ -100658,7 +100651,6 @@ class PreviewInner extends BaseComponent {
|
|
|
100658
100651
|
setRatio: this.handleAdjustRatio,
|
|
100659
100652
|
zoom: zoom,
|
|
100660
100653
|
ratio: ratio,
|
|
100661
|
-
zoomStep: zoomStep,
|
|
100662
100654
|
rotation: rotation,
|
|
100663
100655
|
crossOrigin: crossOrigin,
|
|
100664
100656
|
onError: this.onImageError,
|
|
@@ -100667,6 +100659,7 @@ class PreviewInner extends BaseComponent {
|
|
|
100667
100659
|
/*#__PURE__*/
|
|
100668
100660
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions
|
|
100669
100661
|
external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
|
|
100662
|
+
ref: this.leftIconRef,
|
|
100670
100663
|
className: classnames_default()(`${previewPrefixCls}-icon`, `${previewPrefixCls}-prev`, hideViewerCls),
|
|
100671
100664
|
onClick: () => this.handleSwitchImage("prev")
|
|
100672
100665
|
}, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(IconArrowLeft, {
|
|
@@ -100675,11 +100668,13 @@ class PreviewInner extends BaseComponent {
|
|
|
100675
100668
|
/*#__PURE__*/
|
|
100676
100669
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions
|
|
100677
100670
|
external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
|
|
100671
|
+
ref: this.rightIconRef,
|
|
100678
100672
|
className: classnames_default()(`${previewPrefixCls}-icon`, `${previewPrefixCls}-next`, hideViewerCls),
|
|
100679
100673
|
onClick: () => this.handleSwitchImage("next")
|
|
100680
100674
|
}, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(IconArrowRight, {
|
|
100681
100675
|
size: "large"
|
|
100682
100676
|
})), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(previewFooter_Footer, {
|
|
100677
|
+
forwardRef: this.footerRef,
|
|
100683
100678
|
className: hideViewerCls,
|
|
100684
100679
|
totalNum: total,
|
|
100685
100680
|
curPage: currentIndex + 1,
|
|
@@ -100737,6 +100732,8 @@ PreviewInner.propTypes = {
|
|
|
100737
100732
|
disableDownload: (prop_types_default()).bool,
|
|
100738
100733
|
viewerVisibleDelay: (prop_types_default()).number,
|
|
100739
100734
|
zIndex: (prop_types_default()).number,
|
|
100735
|
+
maxZoom: (prop_types_default()).number,
|
|
100736
|
+
minZoom: (prop_types_default()).number,
|
|
100740
100737
|
renderHeader: (prop_types_default()).func,
|
|
100741
100738
|
renderPreviewMenu: (prop_types_default()).func,
|
|
100742
100739
|
getPopupContainer: (prop_types_default()).func,
|
|
@@ -100761,7 +100758,9 @@ PreviewInner.defaultProps = {
|
|
|
100761
100758
|
preLoadGap: 2,
|
|
100762
100759
|
zIndex: 1000,
|
|
100763
100760
|
maskClosable: true,
|
|
100764
|
-
viewerVisibleDelay: 10000
|
|
100761
|
+
viewerVisibleDelay: 10000,
|
|
100762
|
+
maxZoom: 5,
|
|
100763
|
+
minZoom: 0.1
|
|
100765
100764
|
};
|
|
100766
100765
|
;// CONCATENATED MODULE: ../semi-foundation/image/imageFoundation.ts
|
|
100767
100766
|
|