vue-slide-toggle
Version:
Vue component for like jQuery slideUp / slideDown animations
8 lines (7 loc) • 1.53 kB
JavaScript
/*!
* vue-slide-toggle v1.1.1
* (c) 2018-present Nikita Nafranets <eddimensi@gmail.com>
* Released under the MIT License.
*/
var VueSlideToggle=function(n){"use strict";var e={name:"VueSlideToggle",props:{open:Boolean,duration:{type:Number,default:300},tag:{type:String,default:"div"}},data:function(){return{scrollHeight:0,doneOpenTransition:!1,innerOpen:this.open}},mounted:function(){window.addEventListener("resize",this.getHeight),this.getHeight()},updated:function(){this.getHeight()},destroyed:function(){window.removeEventListener("resize",this.getHeight)},watch:{open:function(n){var e=this;n?this.innerOpen=!0:(this.getHeight(),this.doneOpenTransition=!1,this.$nextTick().then(function(){e.innerOpen=!1}))}},computed:{style:function(){if(this.innerOpen&&this.doneOpenTransition)return null;var n=this.innerOpen?this.scrollHeight:0;return{overflow:"hidden",transitionProperty:"height",height:"".concat(n,"px"),transitionDuration:"".concat(this.duration,"ms")}}},methods:{getHeight:function(){var n=this.$refs.container;this.scrollHeight=n.scrollHeight},handleTransition:function(){this.innerOpen&&(this.doneOpenTransition=!0)}},render:function(n){return n(this.tag,{style:this.style,ref:"container",on:{transitionend:this.handleTransition}},this.$slots.default)}};var t={install:function n(t){n.installed||(n.installed=!0,t.component("VueSlideToggle",e))}},i=e,o=null;return"undefined"!=typeof window&&(o=window.Vue),o&&o.use(t),n.VueSlideToggle=i,n.default=t,n}({});
//# sourceMappingURL=vue-slide-toggle.iife.min.js.map