(function () { const EXTREME_ZOOM_MIN = 1e-4; const EXTREME_ZOOM_MAX = 1e4; function applyCustomZoomHandling(cy) { let zoomFramePending = false; if (!cy || typeof cy.zoom !== 'function') { console.warn('๐Ÿšซ ์œ ํšจํ•˜์ง€ ์•Š์€ Cytoscape ์ธ์Šคํ„ด์Šค์ž…๋‹ˆ๋‹ค.'); return; } cy.userZoomingEnabled(false); // Cytoscape ๊ธฐ๋ณธ ์คŒ ๋น„ํ™œ์„ฑํ™” const container = cy.container(); if (!container) { console.warn('๐Ÿšซ Cytoscape container๋ฅผ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.'); return; } container.addEventListener( 'wheel', (event) => { event.preventDefault(); if (zoomFramePending) return; zoomFramePending = true; requestAnimationFrame(() => { const currentZoom = cy.zoom(); const clampedDelta = Math.max(-100, Math.min(100, event.deltaY)); const zoomFactor = 1 + (clampedDelta > 0 ? -0.05 : 0.05); const nextZoom = currentZoom * zoomFactor; const isValid = isFinite(nextZoom) && nextZoom >= EXTREME_ZOOM_MIN && nextZoom <= EXTREME_ZOOM_MAX; if (isValid) { const rect = container.getBoundingClientRect(); const renderedPosition = { x: event.clientX - rect.left, y: event.clientY - rect.top }; cy.zoom({ level: nextZoom, renderedPosition }); } else { console.warn("๐Ÿšซ ํœ  ์คŒ ๋น„์ •์ƒ ๊ฐ’ ์ฐจ๋‹จ:", nextZoom); } zoomFramePending = false; }); }, { passive: false } ); } // โœ… ์ „์—ญ(window)์œผ๋กœ ํ•จ์ˆ˜ ๋“ฑ๋ก window.applyCustomZoomHandling = applyCustomZoomHandling; })();