Something went wrong. Try again.
Mirror — see github.com/blacksky-algorithms/blacksky.community
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930import {Platform} from 'react-native'
const onMouseUp = (e: React.MouseEvent & {target: HTMLElement}) => { // Only handle whenever it is the middle button if (e.button !== 1 || e.target.closest('a') || e.target.tagName === 'A') { return }
e.target.dispatchEvent( new MouseEvent('click', {metaKey: true, bubbles: true}), )}
const onMouseDown = (e: React.MouseEvent) => { // Prevents the middle click scroll from enabling if (e.button !== 1) return e.preventDefault()}
export function WebAuxClickWrapper({children}: React.PropsWithChildren<{}>) { if (Platform.OS !== 'web') return children
return ( // @ts-expect-error web only <div onMouseDown={onMouseDown} onMouseUp={onMouseUp}> {children} </div> )}