[feat] better polyfill detection
This commit is contained in:
22
src/main.ts
22
src/main.ts
@@ -5,14 +5,22 @@ import { loadData } from "./ts/globalApi";
|
||||
import { ReadableStream, WritableStream, TransformStream } from "web-streams-polyfill/ponyfill/es2018";
|
||||
import { Buffer as BufferPolyfill } from 'buffer'
|
||||
import { initHotkey } from "./ts/hotkey";
|
||||
import {polyfill as dragDropPolyfil} from "mobile-drag-drop";
|
||||
import {scrollBehaviourDragImageTranslateOverride} from "mobile-drag-drop/scroll-behaviour";
|
||||
|
||||
dragDropPolyfil({
|
||||
// use this to make use of the scroll behaviour
|
||||
dragImageTranslateOverride: scrollBehaviourDragImageTranslateOverride,
|
||||
holdToDrag: 400
|
||||
});
|
||||
const testDom = document.createElement('div');
|
||||
const supports = ('draggable' in testDom) || ('ondragstart' in testDom && 'ondrop' in testDom);
|
||||
const isIos = navigator.userAgent ? (!!navigator.userAgent.match('iPhone OS') || !!navigator.userAgent.match('iPad')) : false
|
||||
testDom.remove()
|
||||
|
||||
if((!supports) || isIos){
|
||||
const dragDrop = await import("mobile-drag-drop")
|
||||
const dragDropBehavior = await import("mobile-drag-drop/scroll-behaviour")
|
||||
|
||||
dragDrop.polyfill({
|
||||
// use this to make use of the scroll behaviour
|
||||
dragImageTranslateOverride: dragDropBehavior.scrollBehaviourDragImageTranslateOverride,
|
||||
holdToDrag: 400
|
||||
});
|
||||
}
|
||||
|
||||
//Polyfills
|
||||
declare var Buffer: typeof BufferPolyfill;
|
||||
|
||||
Reference in New Issue
Block a user