mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-03 12:38:53 +08:00
fix: 修复 imageGallery 开启 showToolbar 功能后导致页面不可滚动的问题 (#6108)
This commit is contained in:
parent
ba4d1ecc04
commit
000d05aa56
@ -134,6 +134,7 @@ export default {
|
|||||||
title: '233',
|
title: '233',
|
||||||
imageCaption: 'jfe fjkda fejfkda fejk fdajf dajfe jfkda',
|
imageCaption: 'jfe fjkda fejfkda fejk fdajf dajfe jfkda',
|
||||||
enlargeAble: true,
|
enlargeAble: true,
|
||||||
|
showToolbar: true,
|
||||||
originalSrc: '${image}'
|
originalSrc: '${image}'
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -144,6 +145,7 @@ export default {
|
|||||||
thumbMode: 'cover',
|
thumbMode: 'cover',
|
||||||
thumbRatio: '4:3',
|
thumbRatio: '4:3',
|
||||||
enlargeAble: true,
|
enlargeAble: true,
|
||||||
|
showToolbar: true,
|
||||||
originalSrc: '${src}' // 注意这个取变量是想对数组成员取的。
|
originalSrc: '${src}' // 注意这个取变量是想对数组成员取的。
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -90,16 +90,21 @@ export class ImageGallery extends React.Component<
|
|||||||
actions: ImageGallery.defaultProps.actions
|
actions: ImageGallery.defaultProps.actions
|
||||||
};
|
};
|
||||||
|
|
||||||
componentDidMount() {
|
galleryMain?: HTMLDivElement;
|
||||||
window.addEventListener('wheel', this.onWheelScroll.bind(this), {
|
@autobind
|
||||||
passive: false
|
galleryMainRef(ref: HTMLDivElement) {
|
||||||
});
|
if (ref) {
|
||||||
}
|
ref.addEventListener('wheel', this.onWheelScroll, {
|
||||||
|
passive: false
|
||||||
componentWillUnmount() {
|
});
|
||||||
window.removeEventListener('wheel', this.onWheelScroll);
|
} else {
|
||||||
|
this.galleryMain?.removeEventListener('wheel', this.onWheelScroll);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.galleryMain = ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@autobind
|
||||||
onWheelScroll(event: WheelEvent) {
|
onWheelScroll(event: WheelEvent) {
|
||||||
const showToolbar = this.state?.showToolbar;
|
const showToolbar = this.state?.showToolbar;
|
||||||
|
|
||||||
@ -290,7 +295,10 @@ export class ImageGallery extends React.Component<
|
|||||||
<div className={cx('ImageGallery-title')}>
|
<div className={cx('ImageGallery-title')}>
|
||||||
{items[index].title}
|
{items[index].title}
|
||||||
</div>
|
</div>
|
||||||
<div className={cx('ImageGallery-main')}>
|
<div
|
||||||
|
className={cx('ImageGallery-main')}
|
||||||
|
ref={this.galleryMainRef}
|
||||||
|
>
|
||||||
<img
|
<img
|
||||||
src={items[index].originalSrc}
|
src={items[index].originalSrc}
|
||||||
style={{transform: `scale(${scale}) rotate(${rotate}deg)`}}
|
style={{transform: `scale(${scale}) rotate(${rotate}deg)`}}
|
||||||
|
Loading…
Reference in New Issue
Block a user