Web: Component: fixed footer style, added closure on the area outside the image

This commit is contained in:
Dmitry Sychugov 2022-11-25 19:09:35 +05:00
parent 061927fefa
commit a1ecd48a5e
3 changed files with 16 additions and 2 deletions

View File

@ -109,7 +109,7 @@ const StyledViewer = styled(ViewerBase)`
left: 0; left: 0;
z-index: 307; z-index: 307;
height: 48px; height: 48px;
background: rgba(0, 0, 0, 0.5); background: #333;
text-align: center; text-align: center;
} }

View File

@ -49,6 +49,7 @@ const ViewerBase = (props) => {
mobileDetails, mobileDetails,
onNextClick, onNextClick,
onPrevClick, onPrevClick,
onMaskClick,
} = props; } = props;
const initialState = { const initialState = {
@ -626,6 +627,7 @@ const ViewerBase = (props) => {
top={state.top} top={state.top}
left={state.left} left={state.left}
rotate={state.rotate} rotate={state.rotate}
onMaskClick={onMaskClick}
onChangeImgState={handleChangeImgState} onChangeImgState={handleChangeImgState}
onResize={handleResize} onResize={handleResize}
zIndex={zIndex + 5} zIndex={zIndex + 5}

View File

@ -5,6 +5,7 @@ import { useSwipeable } from "react-swipeable";
export default function ViewerImage(props) { export default function ViewerImage(props) {
const isMouseDown = React.useRef(false); const isMouseDown = React.useRef(false);
const imgRef = React.useRef(null);
const prePosition = React.useRef({ const prePosition = React.useRef({
x: 0, x: 0,
y: 0, y: 0,
@ -102,6 +103,11 @@ export default function ViewerImage(props) {
isMouseDown.current = false; isMouseDown.current = false;
} }
function onClose(e) {
if (e.target === imgRef.current) return;
props.onMaskClick();
}
function bindWindowResizeEvent(remove) { function bindWindowResizeEvent(remove) {
let funcName = "addEventListener"; let funcName = "addEventListener";
if (remove) { if (remove) {
@ -148,6 +154,7 @@ translateX(${props.left !== null ? props.left + "px" : "auto"}) translateY(${
className={imgClass} className={imgClass}
src={props.imgSrc} src={props.imgSrc}
style={imgStyle} style={imgStyle}
ref={imgRef}
onMouseDown={handleMouseDown} onMouseDown={handleMouseDown}
/> />
); );
@ -168,7 +175,12 @@ translateX(${props.left !== null ? props.left + "px" : "auto"}) translateY(${
} }
return ( return (
<div className={`${props.prefixCls}-canvas`} style={style} {...handlers}> <div
className={`${props.prefixCls}-canvas`}
onClick={onClose}
style={style}
{...handlers}
>
{imgNode} {imgNode}
</div> </div>
); );