8,554
edits
No edit summary |
No edit summary |
||
Line 5: | Line 5: | ||
let currentZoomLevel = 0; | let currentZoomLevel = 0; | ||
zoomBtn.addEventListener('click', function() { | if (zoomBtn && image) { | ||
zoomBtn.addEventListener('click', function() { | |||
currentZoomLevel = (currentZoomLevel + 1) % zoomLevels.length; | |||
image.style.transform = `scale(${zoomLevels[currentZoomLevel]})`; | |||
zoomBtn.textContent = `Zoom ${Math.round((zoomLevels[currentZoomLevel] - 1) * 100)}%`; | |||
}); | |||
} | |||
}); | }); | ||