图像画廊可以在悬停图像上缩放吗?

时间:2018-12-26 03:27:00

标签: javascript reactjs

我想提供产品详细信息,使每个图像都可以在悬停时放大。 我使用图书馆:

  

“ react-image-gallery”:“ ^ 0.8.12”,“ react-image-magnify”:“ ^ 2.7.4”,   “ react”:“ ^ 16.6.3”,

但是当我尝试它时,由于包装程序已溢出:隐藏,因此未显示图像缩放结果。

enter image description here

我看过文档。并且有几个选项,即通过使用renderItems,renderCustomControls。但是我有点困惑

这是我的代码:

this.state = {
    image: [
        {
            original: "https://res.cloudinary.com/hammerstout/image/upload/v1545650387/SWEATSHIRT/STENCIL1.jpg",
            thumbnail: "https://res.cloudinary.com/hammerstout/image/upload/v1545650387/SWEATSHIRT/STENCIL1.jpg",
            thumbnailTitle: 'tes',
            renderItem: this.renderImage
        },

        {
            original: "https://res.cloudinary.com/hammerstout/image/upload/v1545650387/SWEATSHIRT/STENCIL2.jpg",
            thumbnail: "https://res.cloudinary.com/hammerstout/image/upload/v1545650387/SWEATSHIRT/STENCIL2.jpg",
            thumbnailTitle: 'tes',
            renderItem: this.renderImage
        },
        {
            original: "https://res.cloudinary.com/hammerstout/image/upload/v1545650387/SWEATSHIRT/STENCIL3.jpg",
            thumbnail: "https://res.cloudinary.com/hammerstout/image/upload/v1545650387/SWEATSHIRT/STENCIL3.jpg",
            thumbnailTitle: 'tes',
            renderItem: this.renderImage
        }

    ],


    renderImage=(item) => {

        const { styleImage } = this.state;
        return (

            <figure onMouseMove={this.handleMouseMove} style={this.state.styleImage}>
                <img src={item.original} />
            </figure>

        )


    }
      render() {

        const { image } = this.state;
        const { classes } = this.props;
        return (<Grid container direction="row">
            <Grid item md={6}>
                <ImageGallery
                    items={image}
                    thumbnailPosition="left"
                    showNav={false}
                    showPlayButton={false}
                    lazyLoad={true} />
            </Grid>

            {this.state.imageZoomContainer}

        </Grid>

        )
    }
}

我想要这样的结果,否则某些东西可以缩放图像

result

0 个答案:

没有答案