diff --git a/dist/omg.js b/dist/omg.js index b49a210..a7a8ecb 100644 --- a/dist/omg.js +++ b/dist/omg.js @@ -1,5 +1,5 @@ /*! - * omg.js v4.0.0-beta.0 + * omg.js v4.0.0 * Author: PengJiyuan */ (function (global, factory) { @@ -69,7 +69,7 @@ } })(); -var version = "4.0.0-beta.0"; +var version = "4.0.0"; function getPos(e, element, touchend) { var ev = e || window.event; diff --git a/dist/omg.min.js b/dist/omg.min.js index eb8c4bd..b5a482e 100644 --- a/dist/omg.min.js +++ b/dist/omg.min.js @@ -1,5 +1,5 @@ /*! - * omg.js v4.0.0-beta.0 + * omg.js v4.0.0 * Author: PengJiyuan */ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.omg=t()}(this,function(){"use strict";!function(){for(var e=["ms","moz","webkit","o"],s=0,t=0;t=t._.minDeviceScale?t._.scale-.01:t._.minDeviceScale:e.deltaY&&e.deltaY<0&&(t._.scale=t._.scale+.01<=t._.maxDeviceScale?t._.scale+.01:t._.maxDeviceScale),t._.redraw()},this._=e,this.triggeredMouseDown=!1,this.triggeredMouseMove=!1}return b(i,[{key:"getPos",value:function(e){return s(e,this._.element)}},{key:"triggerEvents",value:function(){var t=this;if(this._.objects.filter(function(e){return!e.hide}).some(function(e){return e.events&&u(e.events)||e.enableDrag})||this._.enableGlobalTranslate||this._.enableGlobalScale){var e=this._.objects.some(function(e){return e.events&&e.events.some(function(e){return~t._.eventTypes.indexOf(e.eventType)})})||this._.globalMousemove;e&&!this.triggeredMouseMove&&(this.bindMouseMove(),this.triggeredMouseMove=!0),!e&&this.triggeredMouseMove&&(this.unBindMouseMove(),this.triggeredMouseMove=!1),this.triggeredMouseDown||(f(this._.element,"mousedown",this.mouseDown.bind(this)),this.triggeredMouseDown=!0),this._.enableGlobalScale?this.bindMouseWheel():this.unBindMouseWheel()}}},{key:"bindMouseWheel",value:function(){f(this._.element,"wheel",this.mouseWheel)}},{key:"unBindMouseWheel",value:function(){v(this._.element,"wheel",this.mouseWheel)}},{key:"bindMouseMove",value:function(){f(this._.element,"mousemove",this.mouseEnterOrMove.bind(this))}},{key:"unBindMouseMove",value:function(){v(this._.element,"mousemove",this.mouseEnterOrMove.bind(this))}},{key:"mouseEnterOrMove",value:function(e){var t,i=this,n=i.getPos(e).x,s=i.getPos(e).y;i._.globalMousemove&&i._.globalMousemove(e),t=i._.objects.some(function(e){return e.isDragging});var a=i._._objects.filter(function(e){return e.isPointInner(n,s)&&!e.hide});if(t){a&&1this.duration?this.duration:this.elapsed,this.to)this.keys[e]=this.from[e]+(this.to[e]-this.from[e])*C[this.easing](this.elapsed/this.duration);this.started||(this.onStart&&this.onStart(this.keys),this.started=!0),this.onUpdate(this.keys)}else this.finished||(this.finished=!0,this.onFinish&&this.onFinish(this.keys))}}]),u}(),L=function(e,t){var i=window.devicePixelRatio||1,n=null;return e.forEach(function(e){n=e.getContext("2d"),e.style.position=t.position,e.style.width=t.width+"px",e.style.height=t.height+"px",e.width=t.width*i,e.height=t.height*i,n.scale(i,i)}),e},W=function(e,t,i,n,s,a,o){if(0===s)return!1;var r=s,h=0;if(t+rt!=i[a][1]>t&&e<(i[a][0]-i[s][0])*(t-i[s][1])/(i[a][1]-i[s][1])+i[s][0]&&(n=!n);return n}(l,u,this.scaled_matrix);case"line":for(var b=this.scaled_matrix,p=b.length,y=0;ye.length-3){var h=e.length-1;o=e[h][0]-(e[h][0]-e[h-1][0])*n,r=e[h][1]-(e[h][1]-e[h-1][1])*n}else o=e[t+1][0]-(e[t+2][0]-e[t][0])*n,r=e[t+1][1]-(e[t+2][1]-e[t][1])*n;return{pA:{x:s,y:a},pB:{x:o,y:r}}},r=0;r=t._.minDeviceScale?t._.scale-.01:t._.minDeviceScale:e.deltaY&&e.deltaY<0&&(t._.scale=t._.scale+.01<=t._.maxDeviceScale?t._.scale+.01:t._.maxDeviceScale),t._.redraw()},this._=e,this.triggeredMouseDown=!1,this.triggeredMouseMove=!1}return b(i,[{key:"getPos",value:function(e){return s(e,this._.element)}},{key:"triggerEvents",value:function(){var t=this;if(this._.objects.filter(function(e){return!e.hide}).some(function(e){return e.events&&u(e.events)||e.enableDrag})||this._.enableGlobalTranslate||this._.enableGlobalScale){var e=this._.objects.some(function(e){return e.events&&e.events.some(function(e){return~t._.eventTypes.indexOf(e.eventType)})})||this._.globalMousemove;e&&!this.triggeredMouseMove&&(this.bindMouseMove(),this.triggeredMouseMove=!0),!e&&this.triggeredMouseMove&&(this.unBindMouseMove(),this.triggeredMouseMove=!1),this.triggeredMouseDown||(f(this._.element,"mousedown",this.mouseDown.bind(this)),this.triggeredMouseDown=!0),this._.enableGlobalScale?this.bindMouseWheel():this.unBindMouseWheel()}}},{key:"bindMouseWheel",value:function(){f(this._.element,"wheel",this.mouseWheel)}},{key:"unBindMouseWheel",value:function(){v(this._.element,"wheel",this.mouseWheel)}},{key:"bindMouseMove",value:function(){f(this._.element,"mousemove",this.mouseEnterOrMove.bind(this))}},{key:"unBindMouseMove",value:function(){v(this._.element,"mousemove",this.mouseEnterOrMove.bind(this))}},{key:"mouseEnterOrMove",value:function(e){var t,i=this,n=i.getPos(e).x,s=i.getPos(e).y;i._.globalMousemove&&i._.globalMousemove(e),t=i._.objects.some(function(e){return e.isDragging});var a=i._._objects.filter(function(e){return e.isPointInner(n,s)&&!e.hide});if(t){a&&1this.duration?this.duration:this.elapsed,this.to)this.keys[e]=this.from[e]+(this.to[e]-this.from[e])*C[this.easing](this.elapsed/this.duration);this.started||(this.onStart&&this.onStart(this.keys),this.started=!0),this.onUpdate(this.keys)}else this.finished||(this.finished=!0,this.onFinish&&this.onFinish(this.keys))}}]),u}(),L=function(e,t){var i=window.devicePixelRatio||1,n=null;return e.forEach(function(e){n=e.getContext("2d"),e.style.position=t.position,e.style.width=t.width+"px",e.style.height=t.height+"px",e.width=t.width*i,e.height=t.height*i,n.scale(i,i)}),e},W=function(e,t,i,n,s,a,o){if(0===s)return!1;var r=s,h=0;if(t+rt!=i[a][1]>t&&e<(i[a][0]-i[s][0])*(t-i[s][1])/(i[a][1]-i[s][1])+i[s][0]&&(n=!n);return n}(l,u,this.scaled_matrix);case"line":for(var b=this.scaled_matrix,p=b.length,y=0;ye.length-3){var h=e.length-1;o=e[h][0]-(e[h][0]-e[h-1][0])*n,r=e[h][1]-(e[h][1]-e[h-1][1])*n}else o=e[t+1][0]-(e[t+2][0]-e[t][0])*n,r=e[t+1][1]-(e[t+2][1]-e[t][1])*n;return{pA:{x:s,y:a},pB:{x:o,y:r}}},r=0;r=t._.minDeviceScale?t._.scale-.01:t._.minDeviceScale:e.deltaY&&e.deltaY<0&&(t._.scale=t._.scale+.01<=t._.maxDeviceScale?t._.scale+.01:t._.maxDeviceScale),t._.redraw()},this._=e,this.triggeredMouseDown=!1,this.triggeredMouseMove=!1}return b(i,[{key:"getPos",value:function(e){return s(e,this._.element)}},{key:"triggerEvents",value:function(){var t=this;if(this._.objects.filter(function(e){return!e.hide}).some(function(e){return e.events&&u(e.events)||e.enableDrag})||this._.enableGlobalTranslate||this._.enableGlobalScale){var e=this._.objects.some(function(e){return e.events&&e.events.some(function(e){return~t._.eventTypes.indexOf(e.eventType)})})||this._.globalMousemove;e&&!this.triggeredMouseMove&&(this.bindMouseMove(),this.triggeredMouseMove=!0),!e&&this.triggeredMouseMove&&(this.unBindMouseMove(),this.triggeredMouseMove=!1),this.triggeredMouseDown||(f(this._.element,"mousedown",this.mouseDown.bind(this)),this.triggeredMouseDown=!0),this._.enableGlobalScale?this.bindMouseWheel():this.unBindMouseWheel()}}},{key:"bindMouseWheel",value:function(){f(this._.element,"wheel",this.mouseWheel)}},{key:"unBindMouseWheel",value:function(){v(this._.element,"wheel",this.mouseWheel)}},{key:"bindMouseMove",value:function(){f(this._.element,"mousemove",this.mouseEnterOrMove.bind(this))}},{key:"unBindMouseMove",value:function(){v(this._.element,"mousemove",this.mouseEnterOrMove.bind(this))}},{key:"mouseEnterOrMove",value:function(e){var t,i=this,n=i.getPos(e).x,s=i.getPos(e).y;i._.globalMousemove&&i._.globalMousemove(e),t=i._.objects.some(function(e){return e.isDragging});var a=i._._objects.filter(function(e){return e.isPointInner(n,s)&&!e.hide});if(t){a&&1this.duration?this.duration:this.elapsed,this.to)this.keys[e]=this.from[e]+(this.to[e]-this.from[e])*C[this.easing](this.elapsed/this.duration);this.started||(this.onStart&&this.onStart(this.keys),this.started=!0),this.onUpdate(this.keys)}else this.finished||(this.finished=!0,this.onFinish&&this.onFinish(this.keys))}}]),u}(),L=function(e,t){var i=window.devicePixelRatio||1,n=null;return e.forEach(function(e){n=e.getContext("2d"),e.style.position=t.position,e.style.width=t.width+"px",e.style.height=t.height+"px",e.width=t.width*i,e.height=t.height*i,n.scale(i,i)}),e},W=function(e,t,i,n,s,a,o){if(0===s)return!1;var r=s,h=0;if(t+rt!=i[a][1]>t&&e<(i[a][0]-i[s][0])*(t-i[s][1])/(i[a][1]-i[s][1])+i[s][0]&&(n=!n);return n}(l,u,this.scaled_matrix);case"line":for(var b=this.scaled_matrix,p=b.length,y=0;ye.length-3){var h=e.length-1;o=e[h][0]-(e[h][0]-e[h-1][0])*n,r=e[h][1]-(e[h][1]-e[h-1][1])*n}else o=e[t+1][0]-(e[t+2][0]-e[t][0])*n,r=e[t+1][1]-(e[t+2][1]-e[t][1])*n;return{pA:{x:s,y:a},pB:{x:o,y:r}}},r=0;r=t._.minDeviceScale?t._.scale-.01:t._.minDeviceScale:e.deltaY&&e.deltaY<0&&(t._.scale=t._.scale+.01<=t._.maxDeviceScale?t._.scale+.01:t._.maxDeviceScale),t._.redraw()},this._=e,this.triggeredMouseDown=!1,this.triggeredMouseMove=!1}return b(i,[{key:"getPos",value:function(e){return s(e,this._.element)}},{key:"triggerEvents",value:function(){var t=this;if(this._.objects.filter(function(e){return!e.hide}).some(function(e){return e.events&&u(e.events)||e.enableDrag})||this._.enableGlobalTranslate||this._.enableGlobalScale){var e=this._.objects.some(function(e){return e.events&&e.events.some(function(e){return~t._.eventTypes.indexOf(e.eventType)})})||this._.globalMousemove;e&&!this.triggeredMouseMove&&(this.bindMouseMove(),this.triggeredMouseMove=!0),!e&&this.triggeredMouseMove&&(this.unBindMouseMove(),this.triggeredMouseMove=!1),this.triggeredMouseDown||(f(this._.element,"mousedown",this.mouseDown.bind(this)),this.triggeredMouseDown=!0),this._.enableGlobalScale?this.bindMouseWheel():this.unBindMouseWheel()}}},{key:"bindMouseWheel",value:function(){f(this._.element,"wheel",this.mouseWheel)}},{key:"unBindMouseWheel",value:function(){v(this._.element,"wheel",this.mouseWheel)}},{key:"bindMouseMove",value:function(){f(this._.element,"mousemove",this.mouseEnterOrMove.bind(this))}},{key:"unBindMouseMove",value:function(){v(this._.element,"mousemove",this.mouseEnterOrMove.bind(this))}},{key:"mouseEnterOrMove",value:function(e){var t,i=this,n=i.getPos(e).x,s=i.getPos(e).y;i._.globalMousemove&&i._.globalMousemove(e),t=i._.objects.some(function(e){return e.isDragging});var a=i._._objects.filter(function(e){return e.isPointInner(n,s)&&!e.hide});if(t){a&&1this.duration?this.duration:this.elapsed,this.to)this.keys[e]=this.from[e]+(this.to[e]-this.from[e])*C[this.easing](this.elapsed/this.duration);this.started||(this.onStart&&this.onStart(this.keys),this.started=!0),this.onUpdate(this.keys)}else this.finished||(this.finished=!0,this.onFinish&&this.onFinish(this.keys))}}]),u}(),L=function(e,t){var i=window.devicePixelRatio||1,n=null;return e.forEach(function(e){n=e.getContext("2d"),e.style.position=t.position,e.style.width=t.width+"px",e.style.height=t.height+"px",e.width=t.width*i,e.height=t.height*i,n.scale(i,i)}),e},W=function(e,t,i,n,s,a,o){if(0===s)return!1;var r=s,h=0;if(t+rt!=i[a][1]>t&&e<(i[a][0]-i[s][0])*(t-i[s][1])/(i[a][1]-i[s][1])+i[s][0]&&(n=!n);return n}(l,u,this.scaled_matrix);case"line":for(var b=this.scaled_matrix,p=b.length,y=0;ye.length-3){var h=e.length-1;o=e[h][0]-(e[h][0]-e[h-1][0])*n,r=e[h][1]-(e[h][1]-e[h-1][1])*n}else o=e[t+1][0]-(e[t+2][0]-e[t][0])*n,r=e[t+1][1]-(e[t+2][1]-e[t][1])*n;return{pA:{x:s,y:a},pB:{x:o,y:r}}},r=0;r