slickgrid
Version:
A lightning fast JavaScript grid/spreadsheet
9 lines • 3.79 kB
JavaScript
/**
* SlickGrid v3.0.2
* (c) 2009-present Michael Leibman
* homepage: http://github.com/mleibman/slickgrid
* license: MIT
* date: 2022-11-14
* file: ./slick.interactions.js
*/
jQuery.extend(!0,window,{Slick:{Draggable:function(r){let{containerElement:e,onDragInit:a,onDragStart:n,onDrag:o,onDragEnd:d}=r,i,s,u,l,c,m;if(!(e=e||document)||"function"!=typeof e.addEventListener)throw new Error("[Slick.Draggable] You did not provide a valid container html element that will be used for dragging.");let v={dragSource:e,dragHandle:null};function h(e,t,n){"function"==typeof e&&e(t,n)}function t(e){i=e.target;var t,n=e.touches?e.touches[0]:e,o=n["target"];(!r.allowDragFrom||r.allowDragFrom&&i.matches(r.allowDragFrom))&&(v.dragHandle=i,t={left:window.pageXOffset||document.documentElement.scrollLeft||0,top:window.pageYOffset||document.documentElement.scrollTop||0},s=t.left+n.clientX,u=t.top+n.clientY,l=n.clientX-n.clientX,c=n.clientY-n.clientY,v=Object.assign(v,{deltaX:l,deltaY:c,startX:s,startY:u,target:o}),h(a,e,v),document.addEventListener("mousemove",E),document.addEventListener("touchmove",E),document.addEventListener("mouseup",f),document.addEventListener("touchend",f),document.addEventListener("touchcancel",f))}function E(e){var t=e.touches?e.touches[0]:e,t=(l=t.clientX-s,c=t.clientY-u,t)["target"];m||(v=Object.assign(v,{deltaX:l,deltaY:c,startX:s,startY:u,target:t}),h(n,e,v),m=!0),v=Object.assign(v,{deltaX:l,deltaY:c,startX:s,startY:u,target:t}),h(o,e,v)}function f(e){var t=e["target"];v=Object.assign(v,{target:t}),h(d,e,v),document.removeEventListener("mousemove",E),document.removeEventListener("touchmove",E),document.removeEventListener("mouseup",f),document.removeEventListener("touchend",f),document.removeEventListener("touchcancel",f),m=!1}return e&&(e.addEventListener("mousedown",t),e.addEventListener("touchstart",t)),{destroy:function(){e&&(e.removeEventListener("mousedown",t),e.removeEventListener("touchstart",t))}}},MouseWheel:function(e){let{element:t,onMouseWheel:a}=e;function n(e){var t=e||window.event;let n=0,o=0,r=0;t.wheelDelta&&(n=t.wheelDelta/120),t.detail&&(n=-t.detail/3),r=n,void 0!==t.axis&&t.axis===t.HORIZONTAL_AXIS&&(r=0,o=-1*n),void 0!==t.wheelDeltaY&&(r=t.wheelDeltaY/120),void 0!==t.wheelDeltaX&&(o=-1*t.wheelDeltaX/120),"function"==typeof a&&a(e,n,o,r)}return t.addEventListener("wheel",n,!1),t.addEventListener("mousewheel",n,!1),{destroy:function(){t.removeEventListener("wheel",n,!1),t.removeEventListener("mousewheel",n,!1)}}},Resizable:function(e){const{resizeableElement:n,resizeableHandleElement:o,onResizeStart:t,onResize:r,onResizeEnd:a}=e;if(o&&"function"==typeof o.addEventListener)return o.addEventListener("mousedown",i),o.addEventListener("touchstart",i),{destroy:function(){o&&"function"==typeof o.removeEventListener&&(o.removeEventListener("mousedown",i),o.removeEventListener("touchstart",i))}};throw new Error("[Slick.Resizable] You did not provide a valid html element that will be used for the handle to resize.");function d(e,t){"function"==typeof e&&e(t,{resizeableElement:n,resizeableHandleElement:o})}function i(e){e.preventDefault();e=e.touches?e.changedTouches[0]:e;d(t,e),document.addEventListener("mousemove",s),document.addEventListener("mouseup",u),document.addEventListener("touchmove",s),document.addEventListener("touchend",u)}function s(e){e.preventDefault&&"touchmove"!==e.type&&e.preventDefault();e=e.touches?e.changedTouches[0]:e;"function"==typeof r&&(r(e,{resizeableElement:n,resizeableHandleElement:o}),r(e,{resizeableElement:n,resizeableHandleElement:o}))}function u(e){e=e.touches?e.changedTouches[0]:e;d(a,e),document.removeEventListener("mousemove",s),document.removeEventListener("mouseup",u),document.removeEventListener("touchmove",s),document.removeEventListener("touchend",u)}}}});