@douyinfe/semi-ui 2.49.0 → 2.50.0-alpha.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/css/semi.css +1 -1
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +276 -263
- 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/anchor/index.d.ts +1 -1
- package/lib/cjs/autoComplete/index.d.ts +1 -1
- package/lib/cjs/button/Button.d.ts +1 -1
- package/lib/cjs/button/index.d.ts +1 -1
- package/lib/cjs/carousel/index.d.ts +1 -1
- package/lib/cjs/datePicker/datePicker.d.ts +1 -1
- package/lib/cjs/dropdown/index.d.ts +1 -1
- package/lib/cjs/form/baseForm.d.ts +1 -1
- package/lib/cjs/form/field.d.ts +1 -1
- package/lib/cjs/image/interface.d.ts +3 -3
- package/lib/cjs/image/previewFooter.js +8 -5
- package/lib/cjs/image/previewHeader.d.ts +2 -2
- package/lib/cjs/image/previewHeader.js +8 -9
- package/lib/cjs/image/previewImage.d.ts +12 -1
- package/lib/cjs/image/previewImage.js +83 -23
- package/lib/cjs/image/previewInner.d.ts +2 -11
- package/lib/cjs/image/previewInner.js +42 -60
- package/lib/cjs/modal/confirm.d.ts +17 -17
- package/lib/cjs/popover/index.d.ts +1 -1
- package/lib/cjs/select/index.d.ts +1 -1
- package/lib/cjs/table/ColumnSorter.d.ts +3 -1
- package/lib/cjs/table/ColumnSorter.js +26 -15
- package/lib/cjs/table/Table.d.ts +1 -1
- package/lib/cjs/table/Table.js +1 -0
- package/lib/cjs/table/interface.d.ts +4 -0
- package/lib/cjs/timePicker/TimePicker.d.ts +2 -2
- package/lib/cjs/timePicker/TimeShape.d.ts +1 -1
- package/lib/cjs/timePicker/index.d.ts +2 -2
- package/lib/cjs/tooltip/index.d.ts +1 -1
- package/lib/cjs/typography/base.d.ts +1 -1
- package/lib/cjs/typography/numeral.d.ts +1 -1
- package/lib/cjs/typography/paragraph.d.ts +1 -1
- package/lib/cjs/typography/text.d.ts +1 -1
- package/lib/cjs/typography/title.d.ts +1 -1
- package/lib/es/anchor/index.d.ts +1 -1
- package/lib/es/autoComplete/index.d.ts +1 -1
- package/lib/es/button/Button.d.ts +1 -1
- package/lib/es/button/index.d.ts +1 -1
- package/lib/es/carousel/index.d.ts +1 -1
- package/lib/es/datePicker/datePicker.d.ts +1 -1
- package/lib/es/dropdown/index.d.ts +1 -1
- package/lib/es/form/baseForm.d.ts +1 -1
- package/lib/es/form/field.d.ts +1 -1
- package/lib/es/image/interface.d.ts +3 -3
- package/lib/es/image/previewFooter.js +8 -5
- package/lib/es/image/previewHeader.d.ts +2 -2
- package/lib/es/image/previewHeader.js +3 -4
- package/lib/es/image/previewImage.d.ts +12 -1
- package/lib/es/image/previewImage.js +83 -23
- package/lib/es/image/previewInner.d.ts +2 -11
- package/lib/es/image/previewInner.js +42 -60
- package/lib/es/modal/confirm.d.ts +17 -17
- package/lib/es/popover/index.d.ts +1 -1
- package/lib/es/select/index.d.ts +1 -1
- package/lib/es/table/ColumnSorter.d.ts +3 -1
- package/lib/es/table/ColumnSorter.js +26 -15
- package/lib/es/table/Table.d.ts +1 -1
- package/lib/es/table/Table.js +1 -0
- package/lib/es/table/interface.d.ts +4 -0
- package/lib/es/timePicker/TimePicker.d.ts +2 -2
- package/lib/es/timePicker/TimeShape.d.ts +1 -1
- package/lib/es/timePicker/index.d.ts +2 -2
- package/lib/es/tooltip/index.d.ts +1 -1
- package/lib/es/typography/base.d.ts +1 -1
- package/lib/es/typography/numeral.d.ts +1 -1
- package/lib/es/typography/paragraph.d.ts +1 -1
- package/lib/es/typography/text.d.ts +1 -1
- package/lib/es/typography/title.d.ts +1 -1
- package/package.json +8 -8
package/dist/umd/semi-ui.js
CHANGED
|
@@ -69381,7 +69381,6 @@ class SelectFoundation extends foundation {
|
|
|
69381
69381
|
this.close(e);
|
|
69382
69382
|
this._notifyBlur(e);
|
|
69383
69383
|
this._adapter.updateFocusState(false);
|
|
69384
|
-
this._adapter.unregisterClickOutsideHandler();
|
|
69385
69384
|
});
|
|
69386
69385
|
}
|
|
69387
69386
|
toggle2SearchInput(isShow) {
|
|
@@ -69399,6 +69398,7 @@ class SelectFoundation extends foundation {
|
|
|
69399
69398
|
this._adapter.setIsFocusInContainer(false);
|
|
69400
69399
|
// this.unBindKeyBoardEvent();
|
|
69401
69400
|
// this._notifyBlur(e);
|
|
69401
|
+
this._adapter.unregisterClickOutsideHandler();
|
|
69402
69402
|
// this._adapter.updateFocusState(false);
|
|
69403
69403
|
const isFilterable = this._isFilterable();
|
|
69404
69404
|
if (isFilterable) {
|
|
@@ -79986,7 +79986,8 @@ class ColumnSorter extends external_root_React_commonjs2_react_commonjs_react_am
|
|
|
79986
79986
|
onClick,
|
|
79987
79987
|
sortOrder,
|
|
79988
79988
|
style,
|
|
79989
|
-
title
|
|
79989
|
+
title,
|
|
79990
|
+
sortIcon
|
|
79990
79991
|
} = this.props;
|
|
79991
79992
|
const iconBtnSize = 'default';
|
|
79992
79993
|
const upCls = classnames_default()(`${prefixCls}-column-sorter-up`, {
|
|
@@ -80003,25 +80004,34 @@ class ColumnSorter extends external_root_React_commonjs2_react_commonjs_react_am
|
|
|
80003
80004
|
'aria-label': `Current sort order is ${sortOrder ? `${sortOrder}ing` : 'none'}`,
|
|
80004
80005
|
'aria-roledescription': 'Sort data with this column'
|
|
80005
80006
|
};
|
|
80007
|
+
const renderSortIcon = () => {
|
|
80008
|
+
if (typeof sortIcon === 'function') {
|
|
80009
|
+
return sortIcon({
|
|
80010
|
+
sortOrder
|
|
80011
|
+
});
|
|
80012
|
+
} else {
|
|
80013
|
+
return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
|
|
80014
|
+
style: style,
|
|
80015
|
+
className: `${prefixCls}-column-sorter`
|
|
80016
|
+
}, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("span", {
|
|
80017
|
+
className: `${upCls}`
|
|
80018
|
+
}, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(IconCaretup, {
|
|
80019
|
+
size: iconBtnSize
|
|
80020
|
+
})), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("span", {
|
|
80021
|
+
className: `${downCls}`
|
|
80022
|
+
}, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(IconCaretdown, {
|
|
80023
|
+
size: iconBtnSize
|
|
80024
|
+
})));
|
|
80025
|
+
}
|
|
80026
|
+
};
|
|
80006
80027
|
return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", Object.assign({
|
|
80007
|
-
role:
|
|
80028
|
+
role: "button"
|
|
80008
80029
|
}, ariaProps, {
|
|
80009
80030
|
tabIndex: -1,
|
|
80010
80031
|
className: `${prefixCls}-column-sorter-wrapper`,
|
|
80011
80032
|
onClick: onClick,
|
|
80012
80033
|
onKeyPress: e => utils_isEnterPress(e) && onClick(e)
|
|
80013
|
-
}), title,
|
|
80014
|
-
style: style,
|
|
80015
|
-
className: `${prefixCls}-column-sorter`
|
|
80016
|
-
}, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("span", {
|
|
80017
|
-
className: `${upCls}`
|
|
80018
|
-
}, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(IconCaretup, {
|
|
80019
|
-
size: iconBtnSize
|
|
80020
|
-
})), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("span", {
|
|
80021
|
-
className: `${downCls}`
|
|
80022
|
-
}, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(IconCaretdown, {
|
|
80023
|
-
size: iconBtnSize
|
|
80024
|
-
}))));
|
|
80034
|
+
}), title, renderSortIcon());
|
|
80025
80035
|
}
|
|
80026
80036
|
}
|
|
80027
80037
|
ColumnSorter.propTypes = {
|
|
@@ -80029,7 +80039,8 @@ ColumnSorter.propTypes = {
|
|
|
80029
80039
|
style: (prop_types_default()).object,
|
|
80030
80040
|
onClick: (prop_types_default()).func,
|
|
80031
80041
|
prefixCls: (prop_types_default()).string,
|
|
80032
|
-
sortOrder: prop_types_default().oneOfType([(prop_types_default()).string, (prop_types_default()).bool])
|
|
80042
|
+
sortOrder: prop_types_default().oneOfType([(prop_types_default()).string, (prop_types_default()).bool]),
|
|
80043
|
+
sortIcon: (prop_types_default()).func
|
|
80033
80044
|
};
|
|
80034
80045
|
ColumnSorter.defaultProps = {
|
|
80035
80046
|
prefixCls: table_constants_cssClasses.PREFIX,
|
|
@@ -83317,6 +83328,7 @@ class Table extends BaseComponent {
|
|
|
83317
83328
|
const sorter = /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(ColumnSorter, {
|
|
83318
83329
|
key: table_constants_strings.DEFAULT_KEY_COLUMN_SORTER,
|
|
83319
83330
|
sortOrder: sortOrder,
|
|
83331
|
+
sortIcon: column.sortIcon,
|
|
83320
83332
|
onClick: e => _this2.foundation.handleSort(column, e),
|
|
83321
83333
|
title: TitleNode
|
|
83322
83334
|
});
|
|
@@ -98950,14 +98962,14 @@ const PreviewContext = /*#__PURE__*/(0,external_root_React_commonjs2_react_commo
|
|
|
98950
98962
|
|
|
98951
98963
|
|
|
98952
98964
|
const previewHeader_prefixCls = `${image_constants_cssClasses.PREFIX}-preview-header`;
|
|
98953
|
-
const previewHeader_Header =
|
|
98965
|
+
const previewHeader_Header = _ref => {
|
|
98954
98966
|
let {
|
|
98955
98967
|
onClose,
|
|
98956
98968
|
titleStyle,
|
|
98957
98969
|
className,
|
|
98958
98970
|
renderHeader
|
|
98959
98971
|
} = _ref;
|
|
98960
|
-
return /*#__PURE__*/
|
|
98972
|
+
return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_.createElement(PreviewContext.Consumer, null, _ref2 => {
|
|
98961
98973
|
let {
|
|
98962
98974
|
currentIndex,
|
|
98963
98975
|
titles
|
|
@@ -98966,18 +98978,17 @@ const previewHeader_Header = /*#__PURE__*/(0,external_root_React_commonjs2_react
|
|
|
98966
98978
|
if (titles && typeof currentIndex === "number") {
|
|
98967
98979
|
title = titles[currentIndex];
|
|
98968
98980
|
}
|
|
98969
|
-
return /*#__PURE__*/
|
|
98970
|
-
ref: ref,
|
|
98981
|
+
return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_.createElement("section", {
|
|
98971
98982
|
className: classnames_default()(previewHeader_prefixCls, className)
|
|
98972
|
-
}, /*#__PURE__*/
|
|
98983
|
+
}, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_.createElement("section", {
|
|
98973
98984
|
className: `${previewHeader_prefixCls}-title`,
|
|
98974
98985
|
style: titleStyle
|
|
98975
|
-
}, renderHeader ? renderHeader(title) : title), /*#__PURE__*/
|
|
98986
|
+
}, renderHeader ? renderHeader(title) : title), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_.createElement("section", {
|
|
98976
98987
|
className: `${previewHeader_prefixCls}-close`,
|
|
98977
98988
|
onMouseUp: onClose
|
|
98978
|
-
}, /*#__PURE__*/
|
|
98989
|
+
}, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_.createElement(IconClose, null)));
|
|
98979
98990
|
});
|
|
98980
|
-
}
|
|
98991
|
+
};
|
|
98981
98992
|
/* harmony default export */ const previewHeader = (previewHeader_Header);
|
|
98982
98993
|
;// CONCATENATED MODULE: ../semi-icons/lib/es/icons/IconMinus.js
|
|
98983
98994
|
|
|
@@ -99133,6 +99144,7 @@ class PreviewFooterFoundation extends foundation {
|
|
|
99133
99144
|
} else {
|
|
99134
99145
|
onZoomOut(Number((value / 100).toFixed(2)));
|
|
99135
99146
|
}
|
|
99147
|
+
this._adapter.setStartMouseOffset(value);
|
|
99136
99148
|
};
|
|
99137
99149
|
this.handleRatioClick = () => {
|
|
99138
99150
|
const {
|
|
@@ -99165,9 +99177,14 @@ class PreviewFooterFoundation extends foundation {
|
|
|
99165
99177
|
|
|
99166
99178
|
const previewFooter_prefixCls = image_constants_cssClasses.PREFIX;
|
|
99167
99179
|
const footerPrefixCls = `${image_constants_cssClasses.PREFIX}-preview-footer`;
|
|
99180
|
+
let mouseActiveTime = 0;
|
|
99168
99181
|
class previewFooter_Footer extends BaseComponent {
|
|
99169
99182
|
get adapter() {
|
|
99170
|
-
return Object.assign({}, super.adapter)
|
|
99183
|
+
return Object.assign(Object.assign({}, super.adapter), {
|
|
99184
|
+
setStartMouseOffset: time => {
|
|
99185
|
+
mouseActiveTime = time;
|
|
99186
|
+
}
|
|
99187
|
+
});
|
|
99171
99188
|
}
|
|
99172
99189
|
constructor(props) {
|
|
99173
99190
|
super(props);
|
|
@@ -99407,15 +99424,13 @@ class previewFooter_Footer extends BaseComponent {
|
|
|
99407
99424
|
render() {
|
|
99408
99425
|
const {
|
|
99409
99426
|
className,
|
|
99410
|
-
renderPreviewMenu
|
|
99411
|
-
forwardRef
|
|
99427
|
+
renderPreviewMenu
|
|
99412
99428
|
} = this.props;
|
|
99413
99429
|
const menuCls = classnames_default()(footerPrefixCls, `${footerPrefixCls}-wrapper`, className, {
|
|
99414
99430
|
[`${footerPrefixCls}-content`]: !Boolean(renderPreviewMenu)
|
|
99415
99431
|
});
|
|
99416
99432
|
return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("section", {
|
|
99417
|
-
className: menuCls
|
|
99418
|
-
ref: forwardRef
|
|
99433
|
+
className: menuCls
|
|
99419
99434
|
}, renderPreviewMenu ? this.customRenderViewMenu() : this.getFooterMenu());
|
|
99420
99435
|
}
|
|
99421
99436
|
}
|
|
@@ -99454,6 +99469,9 @@ previewFooter_Footer.defaultProps = {
|
|
|
99454
99469
|
};
|
|
99455
99470
|
;// CONCATENATED MODULE: ../semi-foundation/image/previewImageFoundation.ts
|
|
99456
99471
|
|
|
99472
|
+
|
|
99473
|
+
|
|
99474
|
+
|
|
99457
99475
|
const DefaultDOMRect = {
|
|
99458
99476
|
bottom: 0,
|
|
99459
99477
|
height: 0,
|
|
@@ -99468,12 +99486,6 @@ const DefaultDOMRect = {
|
|
|
99468
99486
|
class PreviewImageFoundation extends foundation {
|
|
99469
99487
|
constructor(adapter) {
|
|
99470
99488
|
super(Object.assign({}, adapter));
|
|
99471
|
-
this.startMouseOffset = {
|
|
99472
|
-
x: 0,
|
|
99473
|
-
y: 0
|
|
99474
|
-
};
|
|
99475
|
-
this.originImageWidth = null;
|
|
99476
|
-
this.originImageHeight = null;
|
|
99477
99489
|
this._isImageVertical = () => this.getProp("rotation") % 180 !== 0;
|
|
99478
99490
|
this._getImageBounds = () => {
|
|
99479
99491
|
const imageDOM = this._adapter.getImage();
|
|
@@ -99503,18 +99515,32 @@ class PreviewImageFoundation extends foundation {
|
|
|
99503
99515
|
this._adapter.setLoading(loading);
|
|
99504
99516
|
};
|
|
99505
99517
|
this.handleWindowResize = () => {
|
|
99506
|
-
|
|
99507
|
-
|
|
99518
|
+
const {
|
|
99519
|
+
ratio,
|
|
99520
|
+
setRatio
|
|
99521
|
+
} = this.getProps();
|
|
99522
|
+
const {
|
|
99523
|
+
originImageWidth,
|
|
99524
|
+
originImageHeight
|
|
99525
|
+
} = this._adapter.getOriginImageSize();
|
|
99526
|
+
if (originImageWidth && originImageHeight) {
|
|
99527
|
+
if (ratio !== "adaptation") {
|
|
99528
|
+
setRatio("adaptation");
|
|
99529
|
+
} else {
|
|
99530
|
+
this.handleResizeImage();
|
|
99531
|
+
}
|
|
99508
99532
|
}
|
|
99509
99533
|
};
|
|
99510
99534
|
this.handleLoad = e => {
|
|
99511
99535
|
if (e.target) {
|
|
99512
99536
|
const {
|
|
99513
|
-
|
|
99514
|
-
|
|
99537
|
+
width: w,
|
|
99538
|
+
height: h
|
|
99515
99539
|
} = e.target;
|
|
99516
|
-
this.
|
|
99517
|
-
|
|
99540
|
+
this._adapter.setOriginImageSize({
|
|
99541
|
+
originImageWidth: w,
|
|
99542
|
+
originImageHeight: h
|
|
99543
|
+
});
|
|
99518
99544
|
this.setState({
|
|
99519
99545
|
loading: false
|
|
99520
99546
|
});
|
|
@@ -99539,14 +99565,13 @@ class PreviewImageFoundation extends foundation {
|
|
|
99539
99565
|
this.handleResizeImage = () => {
|
|
99540
99566
|
const horizontal = !this._isImageVertical();
|
|
99541
99567
|
const {
|
|
99542
|
-
|
|
99543
|
-
|
|
99544
|
-
|
|
99545
|
-
const
|
|
99568
|
+
originImageWidth,
|
|
99569
|
+
originImageHeight
|
|
99570
|
+
} = this._adapter.getOriginImageSize();
|
|
99571
|
+
const imgWidth = horizontal ? originImageWidth : originImageHeight;
|
|
99572
|
+
const imgHeight = horizontal ? originImageHeight : originImageWidth;
|
|
99546
99573
|
const {
|
|
99547
|
-
onZoom
|
|
99548
|
-
setRatio,
|
|
99549
|
-
ratio
|
|
99574
|
+
onZoom
|
|
99550
99575
|
} = this.getProps();
|
|
99551
99576
|
const containerDOM = this._adapter.getContainer();
|
|
99552
99577
|
if (containerDOM) {
|
|
@@ -99556,44 +99581,8 @@ class PreviewImageFoundation extends foundation {
|
|
|
99556
99581
|
} = this._getContainerBounds();
|
|
99557
99582
|
const reservedWidth = containerWidth - 80;
|
|
99558
99583
|
const reservedHeight = containerHeight - 80;
|
|
99559
|
-
|
|
99560
|
-
|
|
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
|
-
}
|
|
99584
|
+
const _zoom = Number(Math.min(reservedWidth / imgWidth, reservedHeight / imgHeight).toFixed(2));
|
|
99585
|
+
onZoom(_zoom);
|
|
99597
99586
|
}
|
|
99598
99587
|
};
|
|
99599
99588
|
this.handleRightClickImage = e => {
|
|
@@ -99608,6 +99597,38 @@ class PreviewImageFoundation extends foundation {
|
|
|
99608
99597
|
return true;
|
|
99609
99598
|
}
|
|
99610
99599
|
};
|
|
99600
|
+
// e: WheelEvent<HTMLImageElement>
|
|
99601
|
+
this.handleWheel = e => {
|
|
99602
|
+
this.onWheel(e);
|
|
99603
|
+
handlePrevent(e);
|
|
99604
|
+
};
|
|
99605
|
+
// e: WheelEvent<HTMLImageElement>
|
|
99606
|
+
this.onWheel = throttle_default()(e => {
|
|
99607
|
+
const {
|
|
99608
|
+
onZoom,
|
|
99609
|
+
zoomStep,
|
|
99610
|
+
maxZoom,
|
|
99611
|
+
minZoom
|
|
99612
|
+
} = this.getProps();
|
|
99613
|
+
const {
|
|
99614
|
+
currZoom
|
|
99615
|
+
} = this.getStates();
|
|
99616
|
+
let _zoom;
|
|
99617
|
+
if (e.deltaY < 0) {
|
|
99618
|
+
/* zoom in */
|
|
99619
|
+
if (currZoom + zoomStep <= maxZoom) {
|
|
99620
|
+
_zoom = Number((currZoom + zoomStep).toFixed(2));
|
|
99621
|
+
}
|
|
99622
|
+
} else if (e.deltaY > 0) {
|
|
99623
|
+
/* zoom out */
|
|
99624
|
+
if (currZoom - zoomStep >= minZoom) {
|
|
99625
|
+
_zoom = Number((currZoom - zoomStep).toFixed(2));
|
|
99626
|
+
}
|
|
99627
|
+
}
|
|
99628
|
+
if (!isUndefined_default()(_zoom)) {
|
|
99629
|
+
onZoom(_zoom);
|
|
99630
|
+
}
|
|
99631
|
+
}, 50);
|
|
99611
99632
|
this.calcCanDragDirection = () => {
|
|
99612
99633
|
const {
|
|
99613
99634
|
width,
|
|
@@ -99631,8 +99652,12 @@ class PreviewImageFoundation extends foundation {
|
|
|
99631
99652
|
canDragHorizontal
|
|
99632
99653
|
};
|
|
99633
99654
|
};
|
|
99634
|
-
this.
|
|
99655
|
+
this.handleZoomChange = (newZoom, e) => {
|
|
99635
99656
|
const imageDOM = this._adapter.getImage();
|
|
99657
|
+
const {
|
|
99658
|
+
originImageWidth,
|
|
99659
|
+
originImageHeight
|
|
99660
|
+
} = this._adapter.getOriginImageSize();
|
|
99636
99661
|
const {
|
|
99637
99662
|
canDragVertical,
|
|
99638
99663
|
canDragHorizontal
|
|
@@ -99642,8 +99667,8 @@ class PreviewImageFoundation extends foundation {
|
|
|
99642
99667
|
width: containerWidth,
|
|
99643
99668
|
height: containerHeight
|
|
99644
99669
|
} = this._getContainerBounds();
|
|
99645
|
-
const newWidth = Math.floor(
|
|
99646
|
-
const newHeight = Math.floor(
|
|
99670
|
+
const newWidth = Math.floor(originImageWidth * newZoom);
|
|
99671
|
+
const newHeight = Math.floor(originImageHeight * newZoom);
|
|
99647
99672
|
// debugger;
|
|
99648
99673
|
let _offset;
|
|
99649
99674
|
const horizontal = !this._isImageVertical();
|
|
@@ -99702,13 +99727,13 @@ class PreviewImageFoundation extends foundation {
|
|
|
99702
99727
|
width,
|
|
99703
99728
|
height
|
|
99704
99729
|
} = this.getStates();
|
|
99730
|
+
const startMouseMove = this._adapter.getMouseMove();
|
|
99731
|
+
const startMouseOffset = this._adapter.getMouseOffset();
|
|
99705
99732
|
const {
|
|
99706
99733
|
canDragVertical,
|
|
99707
99734
|
canDragHorizontal
|
|
99708
99735
|
} = this.calcCanDragDirection();
|
|
99709
|
-
|
|
99710
|
-
const mouseLeftPress = e.buttons === 1;
|
|
99711
|
-
if (mouseLeftPress && (canDragVertical || canDragHorizontal)) {
|
|
99736
|
+
if (startMouseMove && (canDragVertical || canDragHorizontal)) {
|
|
99712
99737
|
const {
|
|
99713
99738
|
clientX,
|
|
99714
99739
|
clientY
|
|
@@ -99721,8 +99746,8 @@ class PreviewImageFoundation extends foundation {
|
|
|
99721
99746
|
left: extremeLeft,
|
|
99722
99747
|
top: extremeTop
|
|
99723
99748
|
} = this.calcExtremeBounds();
|
|
99724
|
-
let newX = canDragHorizontal ? clientX - containerLeft -
|
|
99725
|
-
let newY = canDragVertical ? clientY - containerTop -
|
|
99749
|
+
let newX = canDragHorizontal ? clientX - containerLeft - startMouseOffset.x : offset.x;
|
|
99750
|
+
let newY = canDragVertical ? clientY - containerTop - startMouseOffset.y : offset.y;
|
|
99726
99751
|
if (canDragHorizontal) {
|
|
99727
99752
|
newX = newX > 0 ? 0 : newX < extremeLeft ? extremeLeft : newX;
|
|
99728
99753
|
}
|
|
@@ -99741,7 +99766,11 @@ class PreviewImageFoundation extends foundation {
|
|
|
99741
99766
|
}
|
|
99742
99767
|
};
|
|
99743
99768
|
this.handleImageMouseDown = e => {
|
|
99744
|
-
this.
|
|
99769
|
+
this._adapter.setStartMouseOffset(this._getOffset(e));
|
|
99770
|
+
this._adapter.setStartMouseMove(true);
|
|
99771
|
+
};
|
|
99772
|
+
this.handleImageMouseUp = () => {
|
|
99773
|
+
this._adapter.setStartMouseMove(false);
|
|
99745
99774
|
};
|
|
99746
99775
|
}
|
|
99747
99776
|
}
|
|
@@ -99754,14 +99783,38 @@ class PreviewImageFoundation extends foundation {
|
|
|
99754
99783
|
|
|
99755
99784
|
const previewImage_prefixCls = image_constants_cssClasses.PREFIX;
|
|
99756
99785
|
const preViewImgPrefixCls = `${previewImage_prefixCls}-preview-image`;
|
|
99786
|
+
let originImageWidth = null;
|
|
99787
|
+
let originImageHeight = null;
|
|
99788
|
+
let startMouseMove = false;
|
|
99789
|
+
// startMouseOffset:The offset of the mouse relative to the left and top of the picture
|
|
99790
|
+
let startMouseOffset = {
|
|
99791
|
+
x: 0,
|
|
99792
|
+
y: 0
|
|
99793
|
+
};
|
|
99757
99794
|
class PreviewImage extends BaseComponent {
|
|
99758
99795
|
get adapter() {
|
|
99759
99796
|
return Object.assign(Object.assign({}, super.adapter), {
|
|
99797
|
+
getOriginImageSize: () => ({
|
|
99798
|
+
originImageWidth,
|
|
99799
|
+
originImageHeight
|
|
99800
|
+
}),
|
|
99801
|
+
setOriginImageSize: size => {
|
|
99802
|
+
originImageWidth = size.originImageWidth;
|
|
99803
|
+
originImageHeight = size.originImageHeight;
|
|
99804
|
+
},
|
|
99760
99805
|
getContainer: () => {
|
|
99761
99806
|
return this.containerRef.current;
|
|
99762
99807
|
},
|
|
99763
99808
|
getImage: () => {
|
|
99764
|
-
return this.imageRef
|
|
99809
|
+
return this.imageRef;
|
|
99810
|
+
},
|
|
99811
|
+
getMouseMove: () => startMouseMove,
|
|
99812
|
+
setStartMouseMove: move => {
|
|
99813
|
+
startMouseMove = move;
|
|
99814
|
+
},
|
|
99815
|
+
getMouseOffset: () => startMouseOffset,
|
|
99816
|
+
setStartMouseOffset: offset => {
|
|
99817
|
+
startMouseOffset = offset;
|
|
99765
99818
|
},
|
|
99766
99819
|
setLoading: loading => {
|
|
99767
99820
|
this.setState({
|
|
@@ -99769,7 +99822,7 @@ class PreviewImage extends BaseComponent {
|
|
|
99769
99822
|
});
|
|
99770
99823
|
},
|
|
99771
99824
|
setImageCursor: canDrag => {
|
|
99772
|
-
this.imageRef.
|
|
99825
|
+
this.imageRef.style.cursor = canDrag ? "grab" : "default";
|
|
99773
99826
|
}
|
|
99774
99827
|
});
|
|
99775
99828
|
}
|
|
@@ -99778,22 +99831,52 @@ class PreviewImage extends BaseComponent {
|
|
|
99778
99831
|
this.onWindowResize = () => {
|
|
99779
99832
|
this.foundation.handleWindowResize();
|
|
99780
99833
|
};
|
|
99834
|
+
this.handleZoomChange = (newZoom, e) => {
|
|
99835
|
+
this.foundation.handleZoomChange(newZoom, e);
|
|
99836
|
+
};
|
|
99781
99837
|
// Determine the response method of right click according to the disableDownload parameter in props
|
|
99782
99838
|
this.handleRightClickImage = e => {
|
|
99783
99839
|
this.foundation.handleRightClickImage(e);
|
|
99784
99840
|
};
|
|
99841
|
+
this.handleWheel = e => {
|
|
99842
|
+
this.foundation.handleWheel(e);
|
|
99843
|
+
};
|
|
99785
99844
|
this.handleLoad = e => {
|
|
99786
99845
|
this.foundation.handleLoad(e);
|
|
99787
99846
|
};
|
|
99788
99847
|
this.handleError = e => {
|
|
99789
99848
|
this.foundation.handleError(e);
|
|
99790
99849
|
};
|
|
99850
|
+
this.resizeImage = () => {
|
|
99851
|
+
this.foundation.handleResizeImage();
|
|
99852
|
+
};
|
|
99791
99853
|
this.handleMoveImage = e => {
|
|
99792
99854
|
this.foundation.handleMoveImage(e);
|
|
99793
99855
|
};
|
|
99856
|
+
// 为什么通过ref注册wheel而不是使用onWheel事件?
|
|
99857
|
+
// 因为对于wheel事件,浏览器将 addEventListener 的 passive 默认值更改为 true。如此,事件监听器便不能取消事件,也不会在用户滚动页面时阻止页面呈现。
|
|
99858
|
+
// 这里我们需要保持页面不动,仅放大图片,因此此处需要将 passive 更改设置为 false。
|
|
99859
|
+
// Why register wheel via ref instead of using onWheel event?
|
|
99860
|
+
// 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.
|
|
99861
|
+
// 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.
|
|
99862
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#improving_scrolling_performance_with_passive_listeners。
|
|
99863
|
+
this.registryImageRef = ref => {
|
|
99864
|
+
if (this.imageRef) {
|
|
99865
|
+
this.imageRef.removeEventListener("wheel", this.handleWheel);
|
|
99866
|
+
}
|
|
99867
|
+
if (ref) {
|
|
99868
|
+
ref.addEventListener("wheel", this.handleWheel, {
|
|
99869
|
+
passive: false
|
|
99870
|
+
});
|
|
99871
|
+
}
|
|
99872
|
+
this.imageRef = ref;
|
|
99873
|
+
};
|
|
99794
99874
|
this.onImageMouseDown = e => {
|
|
99795
99875
|
this.foundation.handleImageMouseDown(e);
|
|
99796
99876
|
};
|
|
99877
|
+
this.onImageMouseUp = () => {
|
|
99878
|
+
this.foundation.handleImageMouseUp();
|
|
99879
|
+
};
|
|
99797
99880
|
this.state = {
|
|
99798
99881
|
width: 0,
|
|
99799
99882
|
height: 0,
|
|
@@ -99807,7 +99890,7 @@ class PreviewImage extends BaseComponent {
|
|
|
99807
99890
|
left: 0
|
|
99808
99891
|
};
|
|
99809
99892
|
this.containerRef = /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createRef();
|
|
99810
|
-
this.imageRef =
|
|
99893
|
+
this.imageRef = null;
|
|
99811
99894
|
this.foundation = new PreviewImageFoundation(this.adapter);
|
|
99812
99895
|
}
|
|
99813
99896
|
componentDidMount() {
|
|
@@ -99818,23 +99901,28 @@ class PreviewImage extends BaseComponent {
|
|
|
99818
99901
|
}
|
|
99819
99902
|
componentDidUpdate(prevProps, prevStates) {
|
|
99820
99903
|
// If src changes, start a new loading
|
|
99821
|
-
|
|
99822
|
-
const srcChange = this.props.src && this.props.src !== prevProps.src;
|
|
99823
|
-
if (srcChange) {
|
|
99904
|
+
if (this.props.src && this.props.src !== prevProps.src) {
|
|
99824
99905
|
this.foundation.setLoading(true);
|
|
99825
99906
|
}
|
|
99826
99907
|
// If the incoming zoom changes, other content changes are determined based on the new zoom value
|
|
99827
|
-
if (
|
|
99828
|
-
this.
|
|
99829
|
-
}
|
|
99830
|
-
if
|
|
99831
|
-
|
|
99832
|
-
|
|
99833
|
-
|
|
99834
|
-
|
|
99835
|
-
|
|
99908
|
+
if ("zoom" in this.props && this.props.zoom !== prevStates.currZoom) {
|
|
99909
|
+
this.handleZoomChange(this.props.zoom, null);
|
|
99910
|
+
}
|
|
99911
|
+
// When the incoming ratio is changed, if it"s adaptation, then resizeImage is triggered to make the image adapt to the page
|
|
99912
|
+
// else if it"s adaptation is realSize, then onZoom(1) is called to make the image size the original size;
|
|
99913
|
+
if ("ratio" in this.props && this.props.ratio !== prevProps.ratio) {
|
|
99914
|
+
if (originImageWidth && originImageHeight) {
|
|
99915
|
+
if (this.props.ratio === "adaptation") {
|
|
99916
|
+
this.resizeImage();
|
|
99917
|
+
} else {
|
|
99918
|
+
this.props.onZoom(1);
|
|
99919
|
+
}
|
|
99836
99920
|
}
|
|
99837
99921
|
}
|
|
99922
|
+
// When the incoming rotation angle of the image changes, it needs to be resized to make the image fit on the page
|
|
99923
|
+
if ("rotation" in this.props && this.props.rotation !== prevProps.rotation) {
|
|
99924
|
+
this.onWindowResize();
|
|
99925
|
+
}
|
|
99838
99926
|
}
|
|
99839
99927
|
render() {
|
|
99840
99928
|
const {
|
|
@@ -99855,20 +99943,21 @@ class PreviewImage extends BaseComponent {
|
|
|
99855
99943
|
transform: `rotate(${-rotation}deg)`,
|
|
99856
99944
|
top,
|
|
99857
99945
|
left,
|
|
99858
|
-
width
|
|
99859
|
-
height
|
|
99946
|
+
width: loading ? "auto" : `${width}px`,
|
|
99947
|
+
height: loading ? "auto" : `${height}px`
|
|
99860
99948
|
};
|
|
99861
99949
|
return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
|
|
99862
99950
|
className: `${preViewImgPrefixCls}`,
|
|
99863
99951
|
ref: this.containerRef
|
|
99864
99952
|
}, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("img", {
|
|
99865
|
-
ref: this.
|
|
99953
|
+
ref: this.registryImageRef,
|
|
99866
99954
|
src: src,
|
|
99867
99955
|
alt: "previewImag",
|
|
99868
99956
|
className: `${preViewImgPrefixCls}-img`,
|
|
99869
99957
|
key: src,
|
|
99870
99958
|
onMouseMove: this.handleMoveImage,
|
|
99871
99959
|
onMouseDown: this.onImageMouseDown,
|
|
99960
|
+
onMouseUp: this.onImageMouseUp,
|
|
99872
99961
|
onContextMenu: this.handleRightClickImage,
|
|
99873
99962
|
onDragStart: e => e.preventDefault(),
|
|
99874
99963
|
onLoad: this.handleLoad,
|
|
@@ -99885,9 +99974,9 @@ PreviewImage.propTypes = {
|
|
|
99885
99974
|
src: (prop_types_default()).string,
|
|
99886
99975
|
rotation: (prop_types_default()).number,
|
|
99887
99976
|
style: (prop_types_default()).object,
|
|
99888
|
-
|
|
99889
|
-
|
|
99890
|
-
|
|
99977
|
+
maxZoom: (prop_types_default()).number,
|
|
99978
|
+
minZoom: (prop_types_default()).number,
|
|
99979
|
+
zoomStep: (prop_types_default()).number,
|
|
99891
99980
|
zoom: (prop_types_default()).number,
|
|
99892
99981
|
ratio: (prop_types_default()).string,
|
|
99893
99982
|
disableDownload: (prop_types_default()).bool,
|
|
@@ -99898,9 +99987,9 @@ PreviewImage.propTypes = {
|
|
|
99898
99987
|
onError: (prop_types_default()).func
|
|
99899
99988
|
};
|
|
99900
99989
|
PreviewImage.defaultProps = {
|
|
99901
|
-
|
|
99902
|
-
|
|
99903
|
-
|
|
99990
|
+
maxZoom: 5,
|
|
99991
|
+
minZoom: 0.1,
|
|
99992
|
+
zoomStep: 0.1,
|
|
99904
99993
|
zoom: undefined
|
|
99905
99994
|
};
|
|
99906
99995
|
;// CONCATENATED MODULE: ../semi-foundation/image/utils.ts
|
|
@@ -99995,91 +100084,40 @@ const getPreloadImagArr = (imgSrc, currentIndex, preLoadGap, infinite) => {
|
|
|
99995
100084
|
|
|
99996
100085
|
|
|
99997
100086
|
|
|
99998
|
-
|
|
99999
|
-
|
|
100000
|
-
|
|
100001
100087
|
const NOT_CLOSE_TARGETS = ["icon", "footer"];
|
|
100002
|
-
const STOP_CLOSE_TARGET =
|
|
100088
|
+
const STOP_CLOSE_TARGET = ["icon", "footer", "header"];
|
|
100003
100089
|
class PreviewInnerFoundation extends foundation {
|
|
100004
100090
|
constructor(adapter) {
|
|
100005
100091
|
super(Object.assign({}, adapter));
|
|
100006
|
-
this._timer = null;
|
|
100007
|
-
this._startMouseDown = {
|
|
100008
|
-
x: 0,
|
|
100009
|
-
y: 0
|
|
100010
|
-
};
|
|
100011
100092
|
this.handleViewVisibleChange = () => {
|
|
100093
|
+
const nowTime = new Date().getTime();
|
|
100094
|
+
const mouseActiveTime = this._adapter.getMouseActiveTime();
|
|
100095
|
+
const stopTiming = this._adapter.getStopTiming();
|
|
100096
|
+
const {
|
|
100097
|
+
viewerVisibleDelay
|
|
100098
|
+
} = this.getProps();
|
|
100012
100099
|
const {
|
|
100013
100100
|
viewerVisible
|
|
100014
100101
|
} = this.getStates();
|
|
100015
|
-
if (
|
|
100016
|
-
this.setState({
|
|
100102
|
+
if (nowTime - mouseActiveTime > viewerVisibleDelay && !stopTiming) {
|
|
100103
|
+
viewerVisible && this.setState({
|
|
100017
100104
|
viewerVisible: false
|
|
100018
100105
|
});
|
|
100019
|
-
this.clearTimer();
|
|
100020
100106
|
}
|
|
100021
100107
|
};
|
|
100022
|
-
this.
|
|
100023
|
-
|
|
100024
|
-
|
|
100025
|
-
|
|
100026
|
-
|
|
100027
|
-
|
|
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();
|
|
100040
|
-
}
|
|
100041
|
-
}, 50);
|
|
100042
|
-
this.updateTimer = () => {
|
|
100043
|
-
const {
|
|
100044
|
-
viewerVisibleDelay
|
|
100045
|
-
} = this.getProps();
|
|
100046
|
-
this.clearTimer();
|
|
100047
|
-
this._timer = setTimeout(this.handleViewVisibleChange, viewerVisibleDelay);
|
|
100048
|
-
};
|
|
100049
|
-
this.clearTimer = () => {
|
|
100050
|
-
if (this._timer) {
|
|
100051
|
-
clearTimeout(this._timer);
|
|
100052
|
-
this._timer = null;
|
|
100108
|
+
this.handleMouseMoveEvent = (e, event) => {
|
|
100109
|
+
const isTarget = isTargetEmit(e, STOP_CLOSE_TARGET);
|
|
100110
|
+
if (isTarget && event === "over") {
|
|
100111
|
+
this._adapter.setStopTiming(true);
|
|
100112
|
+
} else if (isTarget && event === "out") {
|
|
100113
|
+
this._adapter.setStopTiming(false);
|
|
100053
100114
|
}
|
|
100054
100115
|
};
|
|
100055
|
-
this.
|
|
100056
|
-
this.
|
|
100057
|
-
|
|
100058
|
-
|
|
100059
|
-
|
|
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
|
-
}
|
|
100116
|
+
this.handleMouseMove = e => {
|
|
100117
|
+
this._adapter.setMouseActiveTime(new Date().getTime());
|
|
100118
|
+
this.setState({
|
|
100119
|
+
viewerVisible: true
|
|
100120
|
+
});
|
|
100083
100121
|
};
|
|
100084
100122
|
this.handleMouseUp = e => {
|
|
100085
100123
|
const {
|
|
@@ -100093,7 +100131,7 @@ class PreviewInnerFoundation extends foundation {
|
|
|
100093
100131
|
const {
|
|
100094
100132
|
x,
|
|
100095
100133
|
y
|
|
100096
|
-
} = this.
|
|
100134
|
+
} = this._adapter.getStartMouseDown();
|
|
100097
100135
|
// 对鼠标移动做容错处理,当 x 和 y 方向在 mouseUp 的时候移动距离都小于等于 5px 时候就可以关闭预览
|
|
100098
100136
|
// 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
|
|
100099
100137
|
// 不做容错处理的话,直接用 clientX !== x || y !== clientY 做判断,鼠标在用户点击时候无意识的轻微移动无法关闭预览,不符合用户预期
|
|
@@ -100110,10 +100148,7 @@ class PreviewInnerFoundation extends foundation {
|
|
|
100110
100148
|
clientX,
|
|
100111
100149
|
clientY
|
|
100112
100150
|
} = e;
|
|
100113
|
-
this.
|
|
100114
|
-
x: clientX,
|
|
100115
|
-
y: clientY
|
|
100116
|
-
};
|
|
100151
|
+
this._adapter.setStartMouseDown(clientX, clientY);
|
|
100117
100152
|
};
|
|
100118
100153
|
this.handleKeyDown = e => {
|
|
100119
100154
|
const {
|
|
@@ -100186,12 +100221,10 @@ class PreviewInnerFoundation extends foundation {
|
|
|
100186
100221
|
const {
|
|
100187
100222
|
zoom
|
|
100188
100223
|
} = this.getStates();
|
|
100189
|
-
|
|
100190
|
-
|
|
100191
|
-
|
|
100192
|
-
|
|
100193
|
-
});
|
|
100194
|
-
}
|
|
100224
|
+
this._adapter.notifyZoom(newZoom, newZoom > zoom);
|
|
100225
|
+
this.setState({
|
|
100226
|
+
zoom: newZoom
|
|
100227
|
+
});
|
|
100195
100228
|
};
|
|
100196
100229
|
// 当 visible 改变之后,预览组件完成首张图片加载后,启动预加载
|
|
100197
100230
|
// 如: 1,2,3,4,5,6,7,8张图片, 点击第 4 张图片,preLoadGap 为 2
|
|
@@ -100309,12 +100342,10 @@ class PreviewInnerFoundation extends foundation {
|
|
|
100309
100342
|
beforeShow() {
|
|
100310
100343
|
this._adapter.registerKeyDownListener();
|
|
100311
100344
|
this._adapter.disabledBodyScroll();
|
|
100312
|
-
this.updateTimer();
|
|
100313
100345
|
}
|
|
100314
100346
|
afterHide() {
|
|
100315
100347
|
this._adapter.unregisterKeyDownListener();
|
|
100316
100348
|
this._adapter.enabledBodyScroll();
|
|
100317
|
-
this.clearTimer();
|
|
100318
100349
|
}
|
|
100319
100350
|
}
|
|
100320
100351
|
;// CONCATENATED MODULE: ./image/previewInner.tsx
|
|
@@ -100334,6 +100365,14 @@ class PreviewInnerFoundation extends foundation {
|
|
|
100334
100365
|
|
|
100335
100366
|
|
|
100336
100367
|
const previewInner_prefixCls = image_constants_cssClasses.PREFIX;
|
|
100368
|
+
let startMouseDown = {
|
|
100369
|
+
x: 0,
|
|
100370
|
+
y: 0
|
|
100371
|
+
};
|
|
100372
|
+
let previewInner_mouseActiveTime = null;
|
|
100373
|
+
let stopTiming = false;
|
|
100374
|
+
let timer = null;
|
|
100375
|
+
// let bodyOverflowValue = document.body.style.overflow;
|
|
100337
100376
|
class PreviewInner extends BaseComponent {
|
|
100338
100377
|
get adapter() {
|
|
100339
100378
|
return Object.assign(Object.assign({}, super.adapter), {
|
|
@@ -100417,22 +100456,30 @@ class PreviewInner extends BaseComponent {
|
|
|
100417
100456
|
unregisterKeyDownListener: () => {
|
|
100418
100457
|
window && window.removeEventListener("keydown", this.handleKeyDown);
|
|
100419
100458
|
},
|
|
100459
|
+
getMouseActiveTime: () => {
|
|
100460
|
+
return previewInner_mouseActiveTime;
|
|
100461
|
+
},
|
|
100462
|
+
getStopTiming: () => {
|
|
100463
|
+
return stopTiming;
|
|
100464
|
+
},
|
|
100465
|
+
setStopTiming: value => {
|
|
100466
|
+
stopTiming = value;
|
|
100467
|
+
},
|
|
100468
|
+
getStartMouseDown: () => {
|
|
100469
|
+
return startMouseDown;
|
|
100470
|
+
},
|
|
100471
|
+
setStartMouseDown: (x, y) => {
|
|
100472
|
+
startMouseDown = {
|
|
100473
|
+
x,
|
|
100474
|
+
y
|
|
100475
|
+
};
|
|
100476
|
+
},
|
|
100477
|
+
setMouseActiveTime: time => {
|
|
100478
|
+
previewInner_mouseActiveTime = time;
|
|
100479
|
+
},
|
|
100420
100480
|
getSetDownloadFunc: () => {
|
|
100421
100481
|
var _a, _b;
|
|
100422
100482
|
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;
|
|
100436
100483
|
}
|
|
100437
100484
|
});
|
|
100438
100485
|
}
|
|
@@ -100465,6 +100512,9 @@ class PreviewInner extends BaseComponent {
|
|
|
100465
100512
|
this.handleMouseMove = e => {
|
|
100466
100513
|
this.foundation.handleMouseMove(e);
|
|
100467
100514
|
};
|
|
100515
|
+
this.handleMouseEvent = (e, event) => {
|
|
100516
|
+
this.foundation.handleMouseMoveEvent(e, event);
|
|
100517
|
+
};
|
|
100468
100518
|
this.handleKeyDown = e => {
|
|
100469
100519
|
this.foundation.handleKeyDown(e);
|
|
100470
100520
|
};
|
|
@@ -100477,31 +100527,6 @@ class PreviewInner extends BaseComponent {
|
|
|
100477
100527
|
this.handleMouseDown = e => {
|
|
100478
100528
|
this.foundation.handleMouseDown(e);
|
|
100479
100529
|
};
|
|
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
|
-
};
|
|
100505
100530
|
this.state = {
|
|
100506
100531
|
imgSrc: [],
|
|
100507
100532
|
imgLoadStatus: new Map(),
|
|
@@ -100518,11 +100543,6 @@ class PreviewInner extends BaseComponent {
|
|
|
100518
100543
|
this.bodyOverflow = '';
|
|
100519
100544
|
this.originBodyWidth = '100%';
|
|
100520
100545
|
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();
|
|
100526
100546
|
}
|
|
100527
100547
|
static getDerivedStateFromProps(props, state) {
|
|
100528
100548
|
const willUpdateStates = {};
|
|
@@ -100538,9 +100558,6 @@ class PreviewInner extends BaseComponent {
|
|
|
100538
100558
|
willUpdateStates.visible = props.visible;
|
|
100539
100559
|
if (props.visible) {
|
|
100540
100560
|
willUpdateStates.preloadAfterVisibleChange = true;
|
|
100541
|
-
willUpdateStates.viewerVisible = true;
|
|
100542
|
-
willUpdateStates.rotation = 0;
|
|
100543
|
-
willUpdateStates.ratio = 'adaptation';
|
|
100544
100561
|
}
|
|
100545
100562
|
}
|
|
100546
100563
|
if ("currentIndex" in props && props.currentIndex !== state.currentIndex) {
|
|
@@ -100559,8 +100576,10 @@ class PreviewInner extends BaseComponent {
|
|
|
100559
100576
|
}
|
|
100560
100577
|
}
|
|
100561
100578
|
componentDidUpdate(prevProps, prevState) {
|
|
100562
|
-
if (
|
|
100563
|
-
|
|
100579
|
+
if (prevState.visible !== this.props.visible && this.props.visible) {
|
|
100580
|
+
previewInner_mouseActiveTime = new Date().getTime();
|
|
100581
|
+
timer && clearInterval(timer);
|
|
100582
|
+
timer = setInterval(this.viewVisibleChange, 1000);
|
|
100564
100583
|
}
|
|
100565
100584
|
// hide => show
|
|
100566
100585
|
if (!prevProps.visible && this.props.visible) {
|
|
@@ -100572,7 +100591,7 @@ class PreviewInner extends BaseComponent {
|
|
|
100572
100591
|
}
|
|
100573
100592
|
}
|
|
100574
100593
|
componentWillUnmount() {
|
|
100575
|
-
|
|
100594
|
+
timer && clearInterval(timer);
|
|
100576
100595
|
}
|
|
100577
100596
|
isInGroup() {
|
|
100578
100597
|
return Boolean(this.context && this.context.isGroup);
|
|
@@ -100637,10 +100656,10 @@ class PreviewInner extends BaseComponent {
|
|
|
100637
100656
|
style: style,
|
|
100638
100657
|
onMouseDown: this.handleMouseDown,
|
|
100639
100658
|
onMouseUp: this.handleMouseUp,
|
|
100640
|
-
|
|
100641
|
-
|
|
100659
|
+
onMouseMove: this.handleMouseMove,
|
|
100660
|
+
onMouseOver: e => this.handleMouseEvent(e.nativeEvent, "over"),
|
|
100661
|
+
onMouseOut: e => this.handleMouseEvent(e.nativeEvent, "out")
|
|
100642
100662
|
}, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(previewHeader, {
|
|
100643
|
-
ref: this.headerRef,
|
|
100644
100663
|
className: classnames_default()(hideViewerCls),
|
|
100645
100664
|
onClose: this.handlePreviewClose,
|
|
100646
100665
|
renderHeader: renderHeader
|
|
@@ -100651,6 +100670,7 @@ class PreviewInner extends BaseComponent {
|
|
|
100651
100670
|
setRatio: this.handleAdjustRatio,
|
|
100652
100671
|
zoom: zoom,
|
|
100653
100672
|
ratio: ratio,
|
|
100673
|
+
zoomStep: zoomStep,
|
|
100654
100674
|
rotation: rotation,
|
|
100655
100675
|
crossOrigin: crossOrigin,
|
|
100656
100676
|
onError: this.onImageError,
|
|
@@ -100659,7 +100679,6 @@ class PreviewInner extends BaseComponent {
|
|
|
100659
100679
|
/*#__PURE__*/
|
|
100660
100680
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions
|
|
100661
100681
|
external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
|
|
100662
|
-
ref: this.leftIconRef,
|
|
100663
100682
|
className: classnames_default()(`${previewPrefixCls}-icon`, `${previewPrefixCls}-prev`, hideViewerCls),
|
|
100664
100683
|
onClick: () => this.handleSwitchImage("prev")
|
|
100665
100684
|
}, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(IconArrowLeft, {
|
|
@@ -100668,13 +100687,11 @@ class PreviewInner extends BaseComponent {
|
|
|
100668
100687
|
/*#__PURE__*/
|
|
100669
100688
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions
|
|
100670
100689
|
external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
|
|
100671
|
-
ref: this.rightIconRef,
|
|
100672
100690
|
className: classnames_default()(`${previewPrefixCls}-icon`, `${previewPrefixCls}-next`, hideViewerCls),
|
|
100673
100691
|
onClick: () => this.handleSwitchImage("next")
|
|
100674
100692
|
}, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(IconArrowRight, {
|
|
100675
100693
|
size: "large"
|
|
100676
100694
|
})), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(previewFooter_Footer, {
|
|
100677
|
-
forwardRef: this.footerRef,
|
|
100678
100695
|
className: hideViewerCls,
|
|
100679
100696
|
totalNum: total,
|
|
100680
100697
|
curPage: currentIndex + 1,
|
|
@@ -100732,8 +100749,6 @@ PreviewInner.propTypes = {
|
|
|
100732
100749
|
disableDownload: (prop_types_default()).bool,
|
|
100733
100750
|
viewerVisibleDelay: (prop_types_default()).number,
|
|
100734
100751
|
zIndex: (prop_types_default()).number,
|
|
100735
|
-
maxZoom: (prop_types_default()).number,
|
|
100736
|
-
minZoom: (prop_types_default()).number,
|
|
100737
100752
|
renderHeader: (prop_types_default()).func,
|
|
100738
100753
|
renderPreviewMenu: (prop_types_default()).func,
|
|
100739
100754
|
getPopupContainer: (prop_types_default()).func,
|
|
@@ -100758,9 +100773,7 @@ PreviewInner.defaultProps = {
|
|
|
100758
100773
|
preLoadGap: 2,
|
|
100759
100774
|
zIndex: 1000,
|
|
100760
100775
|
maskClosable: true,
|
|
100761
|
-
viewerVisibleDelay: 10000
|
|
100762
|
-
maxZoom: 5,
|
|
100763
|
-
minZoom: 0.1
|
|
100776
|
+
viewerVisibleDelay: 10000
|
|
100764
100777
|
};
|
|
100765
100778
|
;// CONCATENATED MODULE: ../semi-foundation/image/imageFoundation.ts
|
|
100766
100779
|
|