pleroma-fe/src/components/side_drawer/side_drawer.js

44 lines
892 B
JavaScript
Raw Normal View History

import UserCardContent from '../user_card_content/user_card_content.vue'
const deltaX = (oldX, newX) => newX - oldX
const touchEventX = e => e.touches[0].screenX
const SideDrawer = {
props: [ 'activatePanel', 'logout' ],
data: () => ({
closed: true,
touchX: 0
}),
components: { UserCardContent },
computed: {
currentUser () {
return this.$store.state.users.currentUser
2018-12-21 07:20:04 +11:00
}
},
methods: {
toggleDrawer () {
this.closed = !this.closed
},
2018-12-21 07:20:04 +11:00
gotoPanel (panel) {
this.activatePanel(panel)
this.toggleDrawer()
2018-12-23 02:32:07 +11:00
},
doLogout () {
this.logout()
this.gotoPanel('timeline')
},
touchStart (e) {
this.touchX = touchEventX(e)
},
touchMove (e) {
const delta = deltaX(this.touchX, touchEventX(e))
if (delta < -30) {
this.toggleDrawer()
}
}
}
}
export default SideDrawer