GA for zoom

This commit is contained in:
CPunisher 2020-07-01 23:48:43 +08:00
parent 81aaf64738
commit 9220aafacf
2 changed files with 7 additions and 5 deletions

View File

@ -104,9 +104,8 @@ const PartMore = () => {
const Gallery = ({ contents }) => { const Gallery = ({ contents }) => {
const zoom = mediumZoom(); const zoom = mediumZoom();
zoom.on('open', event => {handleZoom(event.target.src)})
const zoomRef = React.useRef(zoom); const zoomRef = React.useRef(zoom);
return ( return (
contents.map((url, index) => ( contents.map((url, index) => (
<LazyLoad key={'lazy_gallery_' + index} offsetVertical={200}> <LazyLoad key={'lazy_gallery_' + index} offsetVertical={200}>

View File

@ -1,13 +1,16 @@
import React from 'react'; 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) { function attachZoom(image) {
zoomRef.current.attach(image); zoomRef.current.attach(image);
} }
return <img ref={attachZoom} {...props} /> return <img ref={attachZoom} {...other} />
}; };
export default ImageZoom; export default ImageZoom;