UNPKG

drag-drop-polyfill

Version:

Polyfill for making HTML5 drag and drop possible in all browsers.

2 lines 2.54 kB
!function(a,b){"object"==typeof exports&&"undefined"!=typeof module?b(exports):"function"==typeof define&&define.amd?define(["exports"],b):b(a.DragDropPolyfill=a.DragDropPolyfill||{})}(this,function(a){"use strict";function b(a){return a===document.body||a===document.documentElement}function c(a,c){var d;if(b(a))d=0===c?a.clientLeft:a.clientTop;else{var e=a.getBoundingClientRect();d=0===c?e.left:e.top}return d}function d(a,c){var d;return d=b(a)?0===c?window.innerWidth:window.innerHeight:0===c?a.clientWidth:a.clientHeight}function e(a,c,d){var e=0===c?"scrollLeft":"scrollTop",f=b(a);return 2===arguments.length?f?document.body[e]||document.documentElement[e]:a[e]:void(f?(document.documentElement[e]+=d,document.body[e]+=d):a[e]+=d)}function f(a){var b=getComputedStyle(a);return a.scrollHeight>a.clientHeight&&("scroll"===b.overflowY||"auto"===b.overflowY)||a.scrollWidth>a.clientWidth&&("scroll"===b.overflowX||"auto"===b.overflowX)}function g(a){do{if(!a)return;if(f(a))return a;if(a===document.documentElement)return null}while(a=a.parentNode);return null}function h(a,b,c){return a<c?-1:b-a<c?1:0}function i(a,b,c,d){return a===-1?Math.abs(b-d):1===a?Math.abs(c-b-d):0}function j(a,b,c){var d=0===a?c.scrollX:c.scrollY;if(1===b){var e=0===a?c.scrollWidth-c.width:c.scrollHeight-c.height;return d>=e}return b!==-1||d<=0}function k(a,b,c,d){p=b,s=d,q!==c&&(q=c,r=g(q));var e=n(p,r,t.threshold,u,v);e?l():o&&(window.cancelAnimationFrame(o),o=null)}function l(){o||(o=window.requestAnimationFrame(m))}function m(){var a=0,c=0,d=b(r);0!==u.horizontal&&(a=Math.round(t.velocityFn(v.x,t.threshold)*u.horizontal),e(r,0,a)),0!==u.vertical&&(c=Math.round(t.velocityFn(v.y,t.threshold)*u.vertical),e(r,1,c)),d?s(a,c):s(0,0),o=null,n(p,r,t.threshold,u,v)&&l()}function n(a,b,f,g,k){if(!a||!b)return!1;var l={x:c(b,0),y:c(b,1),width:d(b,0),height:d(b,1),scrollX:e(b,0),scrollY:e(b,1),scrollWidth:b.scrollWidth,scrollHeight:b.scrollHeight},m={x:a.x-l.x,y:a.y-l.y};return g.horizontal=h(m.x,l.width,f),g.vertical=h(m.y,l.height,f),g.horizontal&&j(0,g.horizontal,l)?g.horizontal=0:g.horizontal&&(k.x=i(g.horizontal,m.x,l.width,f)),g.vertical&&j(1,g.vertical,l)?g.vertical=0:g.vertical&&(k.y=i(g.vertical,m.y,l.height,f)),!(!g.horizontal&&!g.vertical)}var o,p,q,r,s,t={threshold:75,velocityFn:function(a,b){var c=a/b,d=c*c*c;return d*b}},u={horizontal:0,vertical:0},v={x:0,y:0},w=k;a.scrollBehaviourDragImageTranslateOverride=w,Object.defineProperty(a,"__esModule",{value:!0})}); //# sourceMappingURL=drag-drop-polyfill-scroll-behaviour.min.js.map