aboutsummaryrefslogtreecommitdiff
path: root/src/components/side_drawer
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/side_drawer')
-rw-r--r--src/components/side_drawer/side_drawer.js22
-rw-r--r--src/components/side_drawer/side_drawer.vue48
2 files changed, 35 insertions, 35 deletions
diff --git a/src/components/side_drawer/side_drawer.js b/src/components/side_drawer/side_drawer.js
index b5c49059..567d2e5e 100644
--- a/src/components/side_drawer/side_drawer.js
+++ b/src/components/side_drawer/side_drawer.js
@@ -1,18 +1,17 @@
-import UserCardContent from '../user_card_content/user_card_content.vue'
+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
}),
- components: { UserCardContent },
+ created () {
+ this.closeGesture = GestureService.swipeGesture(GestureService.DIRECTION_LEFT, this.toggleDrawer)
+ },
+ components: { UserCard },
computed: {
currentUser () {
return this.$store.state.users.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)
}
}
}
diff --git a/src/components/side_drawer/side_drawer.vue b/src/components/side_drawer/side_drawer.vue
index 6996380d..e5046496 100644
--- a/src/components/side_drawer/side_drawer.vue
+++ b/src/components/side_drawer/side_drawer.vue
@@ -2,25 +2,21 @@
<div class="side-drawer-container"
:class="{ 'side-drawer-container-closed': closed, 'side-drawer-container-open': !closed }"
>
+ <div class="side-drawer-darken" :class="{ 'side-drawer-darken-closed': closed}" />
<div class="side-drawer"
:class="{'side-drawer-closed': closed}"
@touchstart="touchStart"
@touchmove="touchMove"
>
<div class="side-drawer-heading" @click="toggleDrawer">
- <user-card-content :user="currentUser" :switcher="false" :hideBio="true" v-if="currentUser"/>
+ <UserCard :user="currentUser" :hideBio="true" v-if="currentUser"/>
<div class="side-drawer-logo-wrapper" v-else>
<img :src="logo"/>
<span>{{sitename}}</span>
</div>
</div>
<ul>
- <li v-if="currentUser" @click="toggleDrawer">
- <router-link :to="{ name: 'new-status', params: { username: currentUser.screen_name } }">
- {{ $t("post_status.new_status") }}
- </router-link>
- </li>
- <li v-else @click="toggleDrawer">
+ <li v-if="!currentUser" @click="toggleDrawer">
<router-link :to="{ name: 'login' }">
{{ $t("login.login") }}
</router-link>
@@ -116,17 +112,33 @@
height: 100%;
display: flex;
align-items: stretch;
+ transition-duration: 0s;
+ transition-property: transform;
}
.side-drawer-container-open {
- transition-delay: 0.0s;
- transition-property: left;
+ transform: translate(0%);
}
.side-drawer-container-closed {
- left: -100%;
- transition-delay: 0.5s;
- transition-property: left;
+ transition-delay: 0.35s;
+ transform: translate(-100%);
+}
+
+.side-drawer-darken {
+ top: 0;
+ left: 0;
+ width: 100vw;
+ height: 100vh;
+ position: fixed;
+ z-index: -1;
+ transition: 0.35s;
+ transition-property: background-color;
+ background-color: rgba(0, 0, 0, 0.5);
+}
+
+.side-drawer-darken-closed {
+ background-color: rgba(0, 0, 0, 0);
}
.side-drawer-click-outside {
@@ -135,8 +147,9 @@
.side-drawer {
overflow-x: hidden;
- transition: 0.35s;
transition-timing-function: cubic-bezier(0, 1, 0.5, 1);
+ transition: 0.35s;
+ transition-property: transform;
margin: 0 0 0 -100px;
padding: 0 0 1em 100px;
width: 80%;
@@ -181,15 +194,6 @@
display: flex;
padding: 0;
margin: 0;
-
- .profile-panel-background {
- border-radius: 0;
- .panel-heading {
- background: transparent;
- flex-direction: column;
- align-items: stretch;
- }
- }
}
.side-drawer ul {