diff options
| author | Shpuld Shpludson <shp@cock.li> | 2019-03-28 20:20:16 +0000 |
|---|---|---|
| committer | Shpuld Shpludson <shp@cock.li> | 2019-03-28 20:20:16 +0000 |
| commit | c829b1a5f4a013882ba298b0f95ec0f8b3ed3758 (patch) | |
| tree | 04f51eb60eac1df3fb29edf0baad9ce2538547f4 /src/components/side_drawer/side_drawer.js | |
| parent | ee9aa400019a22951cfc51fd2d6a06c24697a6ba (diff) | |
| parent | 1e2c304f76e8c94aa90ce3ad6e9c6b8ee10deb6b (diff) | |
Merge branch 'feat/gesture-service' into 'develop'
Add a gesture service for easier touch gestures
See merge request pleroma/pleroma-fe!714
Diffstat (limited to 'src/components/side_drawer/side_drawer.js')
| -rw-r--r-- | src/components/side_drawer/side_drawer.js | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/components/side_drawer/side_drawer.js b/src/components/side_drawer/side_drawer.js index ad3738d1..567d2e5e 100644 --- a/src/components/side_drawer/side_drawer.js +++ b/src/components/side_drawer/side_drawer.js @@ -1,17 +1,16 @@ import UserCard from '../user_card/user_card.vue' import { unseenNotificationsFromStore } from '../../services/notification_utils/notification_utils' - -// TODO: separate touch gesture stuff into their own utils if more components want them -const deltaCoord = (oldCoord, newCoord) => [newCoord[0] - oldCoord[0], newCoord[1] - oldCoord[1]] - -const touchEventCoord = e => ([e.touches[0].screenX, e.touches[0].screenY]) +import GestureService from '../../services/gesture_service/gesture_service' const SideDrawer = { props: [ 'logout' ], data: () => ({ closed: true, - touchCoord: [0, 0] + closeGesture: undefined }), + created () { + this.closeGesture = GestureService.swipeGesture(GestureService.DIRECTION_LEFT, this.toggleDrawer) + }, components: { UserCard }, computed: { currentUser () { @@ -46,13 +45,10 @@ const SideDrawer = { this.toggleDrawer() }, touchStart (e) { - this.touchCoord = touchEventCoord(e) + GestureService.beginSwipe(e, this.closeGesture) }, touchMove (e) { - const delta = deltaCoord(this.touchCoord, touchEventCoord(e)) - if (delta[0] < -30 && Math.abs(delta[1]) < Math.abs(delta[0]) && !this.closed) { - this.toggleDrawer() - } + GestureService.updateSwipe(e, this.closeGesture) } } } |
