Current Path : C:/Users/Mahmood/Desktop/moodle/lib/amd/build/ |
Current File : C:/Users/Mahmood/Desktop/moodle/lib/amd/build/dragdrop.min.js |
define ("core/dragdrop",["jquery","core/autoscroll"],function(a,b){var c={eventCaptureOptions:{passive:!1,capture:!0},dragProxy:null,onMove:null,onDrop:null,initialPosition:null,initialX:null,initialY:null,touching:null,prepare:function prepare(a){a.preventDefault();var b;if("touchstart"===a.type){b=null===c.touching&&0<a.changedTouches.length}else{b=1===a.which}if(b){var d=c.getEventXY(a);d.start=!0;return d}else{return{start:!1}}},start:function start(a,d,e,f){var g=c.getEventXY(a);c.initialX=g.x;c.initialY=g.y;c.initialPosition=d.offset();c.dragProxy=d;c.onMove=e;c.onDrop=f;switch(a.type){case"mousedown":c.addEventSpecial("mousemove",c.mouseMove);c.addEventSpecial("mouseup",c.mouseUp);break;case"touchstart":c.addEventSpecial("touchend",c.touchEnd);c.addEventSpecial("touchcancel",c.touchEnd);c.addEventSpecial("touchmove",c.touchMove);c.touching=a.changedTouches[0].identifier;break;default:throw new Error("Unexpected event type: "+a.type);}b.start(c.scroll)},addEventSpecial:function addEventSpecial(a,b){try{window.addEventListener(a,b,c.eventCaptureOptions)}catch(d){c.eventCaptureOptions=!0;window.addEventListener(a,b,c.eventCaptureOptions)}},getEventXY:function getEventXY(a){switch(a.type){case"touchstart":return{x:a.changedTouches[0].pageX,y:a.changedTouches[0].pageY};case"mousedown":return{x:a.pageX,y:a.pageY};default:throw new Error("Unexpected event type: "+a.type);}},touchMove:function touchMove(a){a.preventDefault();for(var b=0;b<a.changedTouches.length;b++){if(a.changedTouches[b].identifier===c.touching){c.handleMove(a.changedTouches[b].pageX,a.changedTouches[b].pageY)}}},mouseMove:function mouseMove(a){c.handleMove(a.pageX,a.pageY)},handleMove:function handleMove(b,d){var e=c.dragProxy.offset(),f=e.top-parseInt(c.dragProxy.css("top")),g=e.left-parseInt(c.dragProxy.css("left")),h=a(document).height()-c.dragProxy.outerHeight()-f,i=a(document).width()-c.dragProxy.outerWidth()-g,j=c.initialPosition,k={top:Math.max(-f,Math.min(h,j.top+(d-c.initialY)-f)),left:Math.max(-g,Math.min(i,j.left+(b-c.initialX)-g))};c.dragProxy.css(k);c.onMove(b,d,c.dragProxy)},touchEnd:function touchEnd(a){a.preventDefault();for(var b=0;b<a.changedTouches.length;b++){if(a.changedTouches[b].identifier===c.touching){c.handleEnd(a.changedTouches[b].pageX,a.changedTouches[b].pageY)}}},mouseUp:function mouseUp(a){c.handleEnd(a.pageX,a.pageY)},handleEnd:function handleEnd(a,d){if(null!==c.touching){window.removeEventListener("touchend",c.touchEnd,c.eventCaptureOptions);window.removeEventListener("touchcancel",c.touchEnd,c.eventCaptureOptions);window.removeEventListener("touchmove",c.touchMove,c.eventCaptureOptions);c.touching=null}else{window.removeEventListener("mousemove",c.mouseMove,c.eventCaptureOptions);window.removeEventListener("mouseup",c.mouseUp,c.eventCaptureOptions)}b.stop();c.onDrop(a,d,c.dragProxy)},scroll:function scroll(b){var d=a(document).height()-c.dragProxy.outerHeight(),e=c.dragProxy.offset();e.top=Math.min(d,e.top+b);c.dragProxy.css(e)}};return{prepare:c.prepare,start:c.start}}); //# sourceMappingURL=dragdrop.min.js.map