From 9220aafacfdbe57cc490e97b63586a1332ee48aa Mon Sep 17 00:00:00 2001 From: CPunisher <1343316114@qq.com> Date: Wed, 1 Jul 2020 23:48:43 +0800 Subject: [PATCH] GA for zoom --- src/components/app/PartMore.js | 3 +-- src/containers/app/ImageZoom.js | 9 ++++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/components/app/PartMore.js b/src/components/app/PartMore.js index 7d3b995..74912a6 100644 --- a/src/components/app/PartMore.js +++ b/src/components/app/PartMore.js @@ -104,9 +104,8 @@ const PartMore = () => { const Gallery = ({ contents }) => { const zoom = mediumZoom(); - zoom.on('open', event => {handleZoom(event.target.src)}) - const zoomRef = React.useRef(zoom); + return ( contents.map((url, index) => ( diff --git a/src/containers/app/ImageZoom.js b/src/containers/app/ImageZoom.js index 89c28e5..1a119e3 100644 --- a/src/containers/app/ImageZoom.js +++ b/src/containers/app/ImageZoom.js @@ -1,13 +1,16 @@ import React from 'react'; +import {handleZoom} from "../../utils/gaHelper"; + +const ImageZoom = ({ zoom, ...other }) => { + const zoomRef = React.useRef(zoom.clone(other)); + zoomRef.current.on('open', event => {handleZoom(event.target.src)}) -const ImageZoom = (props) => { - const zoomRef = React.useRef(props.zoom.clone(props)); function attachZoom(image) { zoomRef.current.attach(image); } - return + return }; export default ImageZoom;