aboutsummaryrefslogtreecommitdiff
path: root/src/components/side_drawer/side_drawer.js
diff options
context:
space:
mode:
authorshpuld <shp@cock.li>2018-12-23 19:50:19 +0200
committershpuld <shp@cock.li>2018-12-23 19:50:19 +0200
commite46b560ead02ab5d9df8edbb997c56b835aa21d4 (patch)
tree5dc1fb27ff7f41639316de370b80d2e229049465 /src/components/side_drawer/side_drawer.js
parentf72b1d048e636c0637dfb1469c32875bcacce61f (diff)
move closing logic to drawer, add swipe to close
Diffstat (limited to 'src/components/side_drawer/side_drawer.js')
-rw-r--r--src/components/side_drawer/side_drawer.js32
1 files changed, 25 insertions, 7 deletions
diff --git a/src/components/side_drawer/side_drawer.js b/src/components/side_drawer/side_drawer.js
index 6541077b..2064dfa5 100644
--- a/src/components/side_drawer/side_drawer.js
+++ b/src/components/side_drawer/side_drawer.js
@@ -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()
+ }
}
}
}