// 放大
const handleZoomIn = (element) => {
if (!element) {
return
}
const img = viewImageContainerRef.current
const currentScale = img.style.transform ? parseFloat(img.style.transform.replace(/[^\d.]/g, '')) || 1 : 1
const newScale = currentScale * 1.2 > 5 ? 5 : currentScale * 1.2
img.style.transform = `scale(${newScale})`
}
// 缩小
const handleZoomOut = (element) => {
if (!element) {
return
}
const img = viewImageContainerRef.current
const currentScale = img.style.transform ? parseFloat(img.style.transform.replace(/[^\d.]/g, '')) || 1 : 1
const newScale = currentScale * 0.8 < 0.2 ? 0.2 : currentScale * 0.8
img.style.transform = `scale(${newScale})`
}