- 后端
- HTML5
Made with ❤️ by 紫升
HTML5 后台不支持触摸事件。因此,它无法在平板电脑和移动设备上运行。您可以使用 react-dnd-touch-backend 来处理触摸设备。
npm install react-dnd-touch-backend
import { TouchBackend } from 'react-dnd-touch-backend'import { DndProvider } from 'react-dnd'class YourApp {<DndProvider backend={TouchBackend} options={opts}>{/* Your application */}</DndProvider>}
// allow vertical scrollingconst options = {scrollAngleRanges: [{ start: 30, end: 150 },{ start: 210, end: 330 }]}// allow horizontal scrollingconst options = {scrollAngleRanges: [{ start: 300 }, { end: 60 }, { start: 120, end: 240 }]}
const hasNative =document && (document.elementsFromPoint || document.msElementsFromPoint)function getDropTargetElementsAtPoint(x, y, dropTargets) {return dropTargets.filter((t) => {const rect = t.getBoundingClientRect()return (x >= rect.left && x <= rect.right && y <= rect.bottom && y >= rect.top)})}// use custom function only if elementsFromPoint is not supportedconst backendOptions = {getDropTargetElementsAtPoint: !hasNative && getDropTargetElementsAtPoint};<DndProvider backend={TouchBackend} options={backendOptions}>/* your react application */</DndProvider>