-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
1 lines (1 loc) · 2.72 KB
/
index.js
1
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.VueOffcanvas=e():t.VueOffcanvas=e()}(this,function(){return function(t){function e(i){if(n[i])return n[i].exports;var o=n[i]={exports:{},id:i,loaded:!1};return t[i].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){var i,o;i=n(1);var s=n(2);o=i=i||{},"object"!=typeof i.default&&"function"!=typeof i.default||(o=i=i.default),"function"==typeof o&&(o=o.options),o.render=s.render,o.staticRenderFns=s.staticRenderFns,t.exports=i},function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default={data:function(){return{visible:!1}},props:{value:{type:Boolean},align:{type:String,default:"left"},width:{type:Number,default:270},duration:{type:Number,default:.2},effect:{type:String,default:"linear"},overflowHidden:{default:!0},closeOnExternalClick:{type:Boolean,default:!0},closeOnEsc:{type:Boolean,default:!0}},watch:{value:function(t){var e=this;setTimeout(function(){return e.toggle(t)})},duration:function(){this.setupBody({})},effect:function(){this.setupBody({})}},computed:{hor:function(){return"right"===this.align?{right:0}:{left:0}},widthCustom:function(){return"right"===this.align?this.width:-this.width}},methods:{setupBody:function(t){var e=t.duration,n=void 0===e?this.duration:e,i=t.effect,o=void 0===i?this.effect:i,s="";switch(o){case"bounce":s="cubic-bezier(0, 1.1, 0.8, 1.1)";break;default:s=this.effect}document.body.style.transition="transform "+n+"s "+s,this.overflowHidden&&(document.body.style.overflowX="hidden")},clickOutside:function(t){!this.$el.contains(t.target)&&this.visible&&this.toggle(!1)},esc:function(t){27===t.keyCode&&this.toggle(!1)},toggle:function(t){var e=this;t?(document.body.style.transform="translateX("+-this.widthCustom+"px)",this.visible=!0):(this.$emit("input",!1),document.body.style.transform="translateX(0)",setTimeout(function(){return e.visible=!1},1e3*this.duration))}},created:function(){var t=this;this.setupBody({}),this.closeOnExternalClick&&setTimeout(function(){return document.addEventListener("click",t.clickOutside)}),this.closeOnEsc&&setTimeout(function(){return document.addEventListener("keydown",t.esc)})},beforeDestroy:function(){this.closeOnExternalClick&&document.removeEventListener("click",this.clickOutside),this.closeOnEsc&&document.removeEventListener("keydown",this.esc)}}},function(module,exports){module.exports={render:function(){with(this)return _c("div",{style:[hor,{width:width+"px",transform:"translateX("+widthCustom+"px)"}],attrs:{style:"position: fixed; top: 0; bottom: 0; height: 100vh;"}},[visible?_t("default"):_e()])},staticRenderFns:[]}}])});