UNPKG

dockview-core

Version:

Zero dependency layout manager supporting tabs, groups, grids and splitviews for vanilla TypeScript

40 lines (39 loc) 1.9 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.resolveDndCapabilities = resolveDndCapabilities; function resolveDndCapabilities(options) { if (options.disableDnd) { return { html5: false, pointer: false, pointerHandlesMouse: false }; } switch (options.dndStrategy) { case 'pointer': return { html5: false, pointer: true, pointerHandlesMouse: true }; case 'html5': return { html5: true, pointer: false, pointerHandlesMouse: false }; case 'auto': case undefined: default: // On touch-primary devices (phones / basic tablets) HTML5 DnD's // native long-press intercepts the gesture before our pointer // backend can react — Android Chrome launches a system drag with // its half-transparent thumbnail, and the long-press context menu // never opens. Disable HTML5 there so the pointer backend owns // every gesture. Hybrid devices (touchscreen laptops, Surface, // iPad with mouse) keep both backends — mouse uses HTML5, touch // falls back to whichever backend the underlying element wired. return isCoarsePrimaryInput() ? { html5: false, pointer: true, pointerHandlesMouse: true } : { html5: true, pointer: true, pointerHandlesMouse: false }; } } function isCoarsePrimaryInput() { if (typeof window === 'undefined' || !window.matchMedia) { return false; } // Coarse pointer without any fine pointer = phone-class device. A laptop // touchscreen reports both, and we want HTML5 to remain available there // because a real mouse is also plugged in. var coarse = window.matchMedia('(pointer: coarse)').matches; var fine = window.matchMedia('(pointer: fine)').matches; return coarse && !fine; }