mirror of
https://github.com/simstudioai/sim.git
synced 2026-01-09 15:07:55 -05:00
34 lines
881 B
TypeScript
34 lines
881 B
TypeScript
'use client'
|
|
|
|
import { useEffect } from 'react'
|
|
|
|
export function ZoomPrevention() {
|
|
useEffect(() => {
|
|
const preventZoom = (e: KeyboardEvent | WheelEvent) => {
|
|
// Prevent zoom on ctrl/cmd + wheel
|
|
if (e instanceof WheelEvent && (e.ctrlKey || e.metaKey)) {
|
|
e.preventDefault()
|
|
}
|
|
|
|
// Prevent zoom on ctrl/cmd + plus/minus/zero
|
|
if (e instanceof KeyboardEvent && (e.ctrlKey || e.metaKey)) {
|
|
if (e.key === '=' || e.key === '-' || e.key === '0') {
|
|
e.preventDefault()
|
|
}
|
|
}
|
|
}
|
|
|
|
// Add event listeners
|
|
document.addEventListener('wheel', preventZoom, { passive: false })
|
|
document.addEventListener('keydown', preventZoom)
|
|
|
|
// Cleanup
|
|
return () => {
|
|
document.removeEventListener('wheel', preventZoom)
|
|
document.removeEventListener('keydown', preventZoom)
|
|
}
|
|
}, [])
|
|
|
|
return null
|
|
}
|