move closing logic to drawer, add swipe to close
This commit is contained in:
parent
f72b1d048e
commit
e46b560ead
5 changed files with 78 additions and 62 deletions
|
@ -1,23 +1,41 @@
|
|||
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', 'closed', 'clickoutside', 'logout' ],
|
||||
props: [ 'activatePanel', 'logout' ],
|
||||
data: () => ({
|
||||
closed: true,
|
||||
touchX: 0
|
||||
}),
|
||||
components: { UserCardContent },
|
||||
computed: {
|
||||
currentUser () {
|
||||
return this.$store.state.users.currentUser
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
toggleDrawer () {
|
||||
this.closed = !this.closed
|
||||
},
|
||||
gotoPanel (panel) {
|
||||
this.activatePanel(panel)
|
||||
this.clickoutside && this.clickoutside()
|
||||
},
|
||||
clickedOutside () {
|
||||
if (typeof this.clickoutside === 'function') {
|
||||
this.clickoutside()
|
||||
}
|
||||
this.toggleDrawer()
|
||||
},
|
||||
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()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue