Created
October 15, 2018 23:39
-
-
Save JamieCurnow/97fe81e1320ed837b836bb7b09f15870 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default { | |
data () { | |
return { | |
// we'll use this to enable gestures on our sideDrawer. | |
gesturesEnabled: false | |
} | |
}, | |
computed: { | |
// drawerElement points to the drawer node using vue $refs | |
drawerElement () { return (this.$refs && this.$refs.drawer) || null }, | |
// drawer is responsible for getting and setting the sideDrawer property in vuex state. | |
drawer: { | |
get () { return this.$store.getters.sideDrawer }, | |
set (v) { return this.$store.commit('setSideDrawer', v) } | |
} | |
}, | |
watch: { | |
// we watch the drawer prop for changes and open/close the sideDrawer accordingly | |
drawer (v) { | |
if (this.drawerElement) { | |
return v ? | |
this.drawerElement.nativeView.showDrawer() : | |
this.drawerElement.nativeView.closeDrawer() | |
} | |
} | |
}, | |
methods: { | |
// some helpful methods for opening and closing the drawer from the vue instance. | |
openDrawer () { | |
this.drawer = true | |
}, | |
closeDrawer () { | |
this.drawer = false | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment