vue-interactjs
Version:
interactjs component for Vue
6 lines • 3.33 kB
JavaScript
/*!
* vue-interactjs v0.1.10
* (c) 2021 yoroshikudozo
* Released under the MIT License.
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("vue"),require("interactjs")):"function"==typeof define&&define.amd?define(["vue","interactjs"],e):(t=t||self,t.VueInteractjs=e(t.Vue,t.interact))}(this,function(t,e){"use strict";function n(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function i(e){return t.extend({name:"Interact",props:{draggable:{type:Boolean,required:!1},dragOption:{type:Object,default:function(){return{}}},resizable:{type:Boolean,required:!1},resizeOption:{type:Object,default:function(){return{}}},droppable:{type:Boolean,required:!1},dropOption:{type:Object,default:function(){return{}}},gesturable:{type:Boolean,required:!1},gestureOption:{type:Object,default:function(){return{}}},tag:{type:String,default:"div"}},data:function(){return n({},g,null)},computed:{interactInstance:{cache:!1,set:function(t){this[g]=t},get:function(){return this[g]}}},watch:{draggable:function(){this.reset()},resizable:function(){this.reset()},gesturable:function(){this.reset()},droppable:function(){this.reset()}},mounted:function(){this.init()},destroyed:function(){this.destroy()},methods:{init:function(){this.interactInstance||this.initInteract(),this.draggable&&this.initDrag(),this.resizable&&this.initResize(),this.droppable&&this.initDrop(),this.gesturable&&this.initGesture()},initInteract:function(){this.interactInstance=e(this.$el),d(this.interactInstance,this.$emit.bind(this)),this.$emit("ready",this.interactInstance)},initDrag:function(){var t;null===(t=this.interactInstance)||void 0===t||t.draggable(this.dragOption),l(this.interactInstance,this.$emit.bind(this))},initResize:function(){var t;null===(t=this.interactInstance)||void 0===t||t.resizable(this.resizeOption),f(this.interactInstance,this.$emit.bind(this))},initDrop:function(){var t;null===(t=this.interactInstance)||void 0===t||t.dropzone(this.dropOption),h(this.interactInstance,this.$emit.bind(this))},initGesture:function(){var t;null===(t=this.interactInstance)||void 0===t||t.gesturable(this.gestureOption),p(this.interactInstance,this.$emit.bind(this))},reset:function(){this.destroy(),this.init()},destroy:function(){var t;null===(t=this.interactInstance)||void 0===t||t.unset(),this.interactInstance=null}},render:function(t){return t(this.tag,{staticClass:"interact"},this.$slots.default)}})}t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t,e=e&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e;var r=["dragstart","dragmove","draginertiastart","dragend"],a=["resizestart","resizemove","resizeinertiastart","resizeend"],s=["dropactivate","dropdeactivate","dragenter","dragleave","dropmove","drop"],o=["gesturestart","gesturemove","gestureend"],c=["down","move","up","cancel","tap","doubletap","hold"],u=function(t){return function(e,n){t.forEach(function(t){e.on(t,function(){for(var e=arguments.length,i=new Array(e),r=0;r<e;r++)i[r]=arguments[r];n.apply(void 0,[t].concat(i))})})}},d=u(c),l=u(r),h=u(s),f=u(a),p=u(o),g="InteractInstance",b=function(t){var n=i(e);t.component("Interact",n)},v={install:b,version:"0.1.10"};return"undefined"!=typeof window&&window.Vue&&window.Vue.use(v),v});