图片放大后点击隐藏

This commit is contained in:
caishi 2020-08-31 16:31:00 +08:00
parent 81f9e9728e
commit 8be0341137
3 changed files with 12 additions and 7 deletions

View File

@ -1,10 +1,9 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import ReactDOM from 'react-dom' import ReactDOM from 'react-dom'
import { Button, Icon } from 'antd'; import { Button, Icon } from 'antd';
import './TaskResultLayer.css' import './TaskResultLayer.css';
class ImageLayer extends Component { class ImageLayer extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
@ -21,13 +20,13 @@ class ImageLayer extends Component {
}); });
} }
render() { render() {
let { showImage, imageSrc, } = this.props; let { showImage, imageSrc, } = this.props;
return ReactDOM.createPortal( return ReactDOM.createPortal(
<div> <div>
{showImage ? {showImage ?
<div className="taskResultLayer"> <div className="taskResultLayer">
<div className="closePanel" onClick={() => this.props.onImageLayerClose()}></div>
<div className={"ImageLayerbutton mt20"}> <div className={"ImageLayerbutton mt20"}>
<Button <Button
className={"fr"} className={"fr"}
@ -53,8 +52,6 @@ class ImageLayer extends Component {
<div className="passContent" style={{ transform: this.state.transStyle }}> <div className="passContent" style={{ transform: this.state.transStyle }}>
<img src={imageSrc} className="passImg" unselectable="on" alt="" /> <img src={imageSrc} className="passImg" unselectable="on" alt="" />
</div> </div>
</div> </div>
: :
<div></div> <div></div>

View File

@ -16,7 +16,6 @@ export function ImageLayerOfCommentHOC(options = {}) {
} }
onDelegateClick = (event) => { onDelegateClick = (event) => {
console.log("imgclick",event);
const imageSrc = event.target.src || event.target.getAttribute('src') || event.target.getAttribute('href') const imageSrc = event.target.src || event.target.getAttribute('src') || event.target.getAttribute('href')
// 判断imageSrc是否是图片 // 判断imageSrc是否是图片
const fileName = event.target.innerHTML.trim() const fileName = event.target.innerHTML.trim()

View File

@ -40,8 +40,17 @@
justify-content: center; justify-content: center;
align-items: center; align-items: center;
display: -webkit-flex; display: -webkit-flex;
height: 90%; height: 100%;
text-align: center; text-align: center;
position: absolute;
width:100%;
z-index: 4;
}
.closePanel{
position: absolute;
width: 100%;
height: 100%;
z-index: 5;
} }
.passImg{ .passImg{
max-width: 86%; max-width: 86%;