Skip to content

Instantly share code, notes, and snippets.

@ramsaylanier
Created November 22, 2017 00:21
Show Gist options
  • Save ramsaylanier/6c6c7278591dd51961143064b878a80c to your computer and use it in GitHub Desktop.
Save ramsaylanier/6c6c7278591dd51961143064b878a80c to your computer and use it in GitHub Desktop.
<template>
<div :class="$style.sidebar">
<component :is="component"/>
</div>
</template>
<script>
import {TweenMax, Power4} from 'gsap'
export default {
name: 'sidebar',
mounted () {
TweenMax.set(this.$el, {
x: this.$el.offsetWidth
})
},
computed: {
open () {
return this.$store.state.ui.sidebarOpen
},
component () {
return this.$store.state.ui.sidebarComponent
}
},
watch: {
open: function (open) {
const dX = open ? 0 : this.$el.offsetWidth
TweenMax.to(this.$el, 0.6, {
x: dX,
ease: Power4.easeOut
})
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment