[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 { ReadableStream, WritableStream, TransformStream } from "web-streams-polyfill/ponyfill/es2018";
|
||||||
import { Buffer as BufferPolyfill } from 'buffer'
|
import { Buffer as BufferPolyfill } from 'buffer'
|
||||||
import { initHotkey } from "./ts/hotkey";
|
import { initHotkey } from "./ts/hotkey";
|
||||||
import {polyfill as dragDropPolyfil} from "mobile-drag-drop";
|
|
||||||
import {scrollBehaviourDragImageTranslateOverride} from "mobile-drag-drop/scroll-behaviour";
|
|
||||||
|
|
||||||
dragDropPolyfil({
|
const testDom = document.createElement('div');
|
||||||
// use this to make use of the scroll behaviour
|
const supports = ('draggable' in testDom) || ('ondragstart' in testDom && 'ondrop' in testDom);
|
||||||
dragImageTranslateOverride: scrollBehaviourDragImageTranslateOverride,
|
const isIos = navigator.userAgent ? (!!navigator.userAgent.match('iPhone OS') || !!navigator.userAgent.match('iPad')) : false
|
||||||
holdToDrag: 400
|
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
|
//Polyfills
|
||||||
declare var Buffer: typeof BufferPolyfill;
|
declare var Buffer: typeof BufferPolyfill;
|
||||||
|
|||||||
Reference in New Issue
Block a user