You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2 lines
3.6 KiB
2 lines
3.6 KiB
// https://d3js.org/d3-drag/ v1.2.3 Copyright 2018 Mike Bostock |
|
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("d3-selection"),require("d3-dispatch")):"function"==typeof define&&define.amd?define(["exports","d3-selection","d3-dispatch"],e):e(t.d3=t.d3||{},t.d3,t.d3)}(this,function(t,e,n){"use strict";function o(){e.event.stopImmediatePropagation()}function i(){e.event.preventDefault(),e.event.stopImmediatePropagation()}function r(t){var n=t.document.documentElement,o=e.select(t).on("dragstart.drag",i,!0);"onselectstart"in n?o.on("selectstart.drag",i,!0):(n.__noselect=n.style.MozUserSelect,n.style.MozUserSelect="none")}function c(t,n){var o=t.document.documentElement,r=e.select(t).on("dragstart.drag",null);n&&(r.on("click.drag",i,!0),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in o?r.on("selectstart.drag",null):(o.style.MozUserSelect=o.__noselect,delete o.__noselect)}function u(t){return function(){return t}}function s(t,e,n,o,i,r,c,u,s,a){this.target=t,this.type=e,this.subject=n,this.identifier=o,this.active=i,this.x=r,this.y=c,this.dx=u,this.dy=s,this._=a}function a(){return!e.event.button}function l(){return this.parentNode}function d(t){return null==t?{x:e.event.x,y:e.event.y}:t}function f(){return"ontouchstart"in this}s.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t},t.drag=function(){var t,h,p,v,g=a,m=l,y=d,b=f,_={},w=n.dispatch("start","drag","end"),x=0,T=0;function j(t){t.on("mousedown.drag",k).filter(b).on("touchstart.drag",q).on("touchmove.drag",z).on("touchend.drag touchcancel.drag",D).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function k(){if(!v&&g.apply(this,arguments)){var n=P("mouse",m.apply(this,arguments),e.mouse,this,arguments);n&&(e.select(e.event.view).on("mousemove.drag",E,!0).on("mouseup.drag",M,!0),r(e.event.view),o(),p=!1,t=e.event.clientX,h=e.event.clientY,n("start"))}}function E(){if(i(),!p){var n=e.event.clientX-t,o=e.event.clientY-h;p=n*n+o*o>T}_.mouse("drag")}function M(){e.select(e.event.view).on("mousemove.drag mouseup.drag",null),c(e.event.view,p),i(),_.mouse("end")}function q(){if(g.apply(this,arguments)){var t,n,i=e.event.changedTouches,r=m.apply(this,arguments),c=i.length;for(t=0;t<c;++t)(n=P(i[t].identifier,r,e.touch,this,arguments))&&(o(),n("start"))}}function z(){var t,n,o=e.event.changedTouches,r=o.length;for(t=0;t<r;++t)(n=_[o[t].identifier])&&(i(),n("drag"))}function D(){var t,n,i=e.event.changedTouches,r=i.length;for(v&&clearTimeout(v),v=setTimeout(function(){v=null},500),t=0;t<r;++t)(n=_[i[t].identifier])&&(o(),n("end"))}function P(t,n,o,i,r){var c,u,a,l=o(n,t),d=w.copy();if(e.customEvent(new s(j,"beforestart",c,t,x,l[0],l[1],0,0,d),function(){return null!=(e.event.subject=c=y.apply(i,r))&&(u=c.x-l[0]||0,a=c.y-l[1]||0,!0)}))return function f(h){var p,v=l;switch(h){case"start":_[t]=f,p=x++;break;case"end":delete _[t],--x;case"drag":l=o(n,t),p=x}e.customEvent(new s(j,h,c,t,p,l[0]+u,l[1]+a,l[0]-v[0],l[1]-v[1],d),d.apply,d,[h,i,r])}}return j.filter=function(t){return arguments.length?(g="function"==typeof t?t:u(!!t),j):g},j.container=function(t){return arguments.length?(m="function"==typeof t?t:u(t),j):m},j.subject=function(t){return arguments.length?(y="function"==typeof t?t:u(t),j):y},j.touchable=function(t){return arguments.length?(b="function"==typeof t?t:u(!!t),j):b},j.on=function(){var t=w.on.apply(w,arguments);return t===w?j:t},j.clickDistance=function(t){return arguments.length?(T=(t=+t)*t,j):Math.sqrt(T)},j},t.dragDisable=r,t.dragEnable=c,Object.defineProperty(t,"__esModule",{value:!0})});
|
|
|