From 0a86d39ba9cf48fc0b4fb6d91b0d5eff404b2a66 Mon Sep 17 00:00:00 2001 From: shpuld Date: Thu, 14 Mar 2019 20:40:56 +0200 Subject: remove notifications from sidebar, make notifications appear on login only --- src/components/side_drawer/side_drawer.vue | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src/components/side_drawer') diff --git a/src/components/side_drawer/side_drawer.vue b/src/components/side_drawer/side_drawer.vue index 95ee21b4..27db12d7 100644 --- a/src/components/side_drawer/side_drawer.vue +++ b/src/components/side_drawer/side_drawer.vue @@ -20,11 +20,6 @@ {{ $t("login.login") }} -
  • - - {{ $t("notifications.notifications") }} {{ unseenNotificationsCount > 0 ? `(${unseenNotificationsCount})` : '' }} - -
  • {{ $t("nav.dms") }} -- cgit v1.2.3-70-g09d2 From e23c19468a4436454161fd315c6bfb79aef1b15d Mon Sep 17 00:00:00 2001 From: shpuld Date: Mon, 25 Mar 2019 22:44:58 +0200 Subject: somewhat functioning gesture service --- src/components/side_drawer/side_drawer.js | 21 ++++---- src/services/gesture_service/gesture_service.js | 71 +++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 11 deletions(-) (limited to 'src/components/side_drawer') diff --git a/src/components/side_drawer/side_drawer.js b/src/components/side_drawer/side_drawer.js index ad3738d1..76c64fe0 100644 --- a/src/components/side_drawer/side_drawer.js +++ b/src/components/side_drawer/side_drawer.js @@ -1,17 +1,18 @@ 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 () { + const cb = () => this.toggleDrawer() + this.closeGesture = GestureService.swipeGesture(GestureService.DIRECTION_LEFT, cb) + console.log(this.closeGesture) + }, components: { UserCard }, computed: { currentUser () { @@ -46,13 +47,11 @@ const SideDrawer = { this.toggleDrawer() }, touchStart (e) { - this.touchCoord = touchEventCoord(e) + console.log(this) + 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/services/gesture_service/gesture_service.js b/src/services/gesture_service/gesture_service.js index e69de29b..2e39003c 100644 --- a/src/services/gesture_service/gesture_service.js +++ b/src/services/gesture_service/gesture_service.js @@ -0,0 +1,71 @@ + +const DIRECTION_LEFT = [-1, 0] +const DIRECTION_RIGHT = [1, 0] +const DIRECTION_UP = [0, -1] +const DIRECTION_DOWN = [0, 1] + +const deltaCoord = (oldCoord, newCoord) => [newCoord[0] - oldCoord[0], newCoord[1] - oldCoord[1]] + +const touchEventCoord = e => ([e.touches[0].screenX, e.touches[0].screenY]) + +const vectorLength = v => Math.sqrt(v[0] * v[0] + v[1] * v[1]) + +const perpendicular = v => [v[1], v[0]] + +const dotProduct = (v1, v2) => v1[0] * v2[0] + v1[1] * v2[1] + +const vectorFlatten = (v1, v2) => [v1[0] * v2[0], v1[1] * v2[1]] + +// direction: either use the constants above or an arbitrary 2d vector. +// threshold: how many Px to move from touch origin before checking if the +// callback should be called. +// divergentTolerance: a scalr for much of divergent direction we tolerate when +// above threshold. for example, with 1.0 we only call the callback if +// divergent component of delta is < 1.0 * direction component of delta. +const swipeGesture = (direction, onSwipe, threshold = 30, perpendicularTolerance = 1.0) => { + return { + direction, + onSwipe, + threshold, + perpendicularTolerance, + _startPos: [0, 0], + _swiping: false + } +} + +const beginSwipe = (event, gesture) => { + gesture._startPos = touchEventCoord(event) + gesture._swiping = true +} + +const updateSwipe = (event, gesture) => { + if (!gesture._swiping) return + // movement too small + const delta = deltaCoord(gesture._startPos, touchEventCoord(event)) + if (vectorLength(delta) < gesture.threshold) return + // movement is opposite from direction + if (dotProduct(delta, gesture.direction) < 0) return + // movement perpendicular to direction is too much + const towardsDir = vectorFlatten(gesture.direction, delta) + const perpendicularDir = perpendicular(gesture.direction) + const towardsPerpendicular = vectorFlatten(perpendicularDir, delta) + if ( + vectorLength(towardsDir) < + gesture.perpendicularTolerance * vectorLength(towardsPerpendicular) + ) return + + gesture.onSwipe() + gesture._swiping = false +} + +const GestureService = { + DIRECTION_LEFT, + DIRECTION_RIGHT, + DIRECTION_UP, + DIRECTION_DOWN, + swipeGesture, + beginSwipe, + updateSwipe +} + +export default GestureService -- cgit v1.2.3-70-g09d2 From 0eff4bd0acf709901b29877f7fc65f7a6241e058 Mon Sep 17 00:00:00 2001 From: shpuld Date: Wed, 27 Mar 2019 22:44:25 +0200 Subject: make side drawer use gesture service and fix its animations --- src/components/side_drawer/side_drawer.js | 5 +---- src/components/side_drawer/side_drawer.vue | 24 +++++++++++++++++++++--- 2 files changed, 22 insertions(+), 7 deletions(-) (limited to 'src/components/side_drawer') diff --git a/src/components/side_drawer/side_drawer.js b/src/components/side_drawer/side_drawer.js index 76c64fe0..567d2e5e 100644 --- a/src/components/side_drawer/side_drawer.js +++ b/src/components/side_drawer/side_drawer.js @@ -9,9 +9,7 @@ const SideDrawer = { closeGesture: undefined }), created () { - const cb = () => this.toggleDrawer() - this.closeGesture = GestureService.swipeGesture(GestureService.DIRECTION_LEFT, cb) - console.log(this.closeGesture) + this.closeGesture = GestureService.swipeGesture(GestureService.DIRECTION_LEFT, this.toggleDrawer) }, components: { UserCard }, computed: { @@ -47,7 +45,6 @@ const SideDrawer = { this.toggleDrawer() }, touchStart (e) { - console.log(this) GestureService.beginSwipe(e, this.closeGesture) }, touchMove (e) { diff --git a/src/components/side_drawer/side_drawer.vue b/src/components/side_drawer/side_drawer.vue index 95ee21b4..e5046496 100644 --- a/src/components/side_drawer/side_drawer.vue +++ b/src/components/side_drawer/side_drawer.vue @@ -2,6 +2,7 @@
    +
    Date: Wed, 15 May 2019 20:44:35 +0300 Subject: Cleanup, little documentation, localization --- src/boot/routes.js | 2 +- src/components/interactions/interactions.vue | 6 +++--- src/components/nav_panel/nav_panel.vue | 2 +- src/components/notifications/notifications.js | 12 +++++++++--- src/components/notifications/notifications.scss | 6 ++++-- src/components/notifications/notifications.vue | 6 ++++-- src/components/side_drawer/side_drawer.vue | 5 +++++ src/i18n/en.json | 6 ++++++ src/i18n/ru.json | 6 ++++++ 9 files changed, 39 insertions(+), 12 deletions(-) (limited to 'src/components/side_drawer') diff --git a/src/boot/routes.js b/src/boot/routes.js index 508c76df..1a179099 100644 --- a/src/boot/routes.js +++ b/src/boot/routes.js @@ -34,7 +34,7 @@ export default (store) => { { name: 'tag-timeline', path: '/tag/:tag', component: TagTimeline }, { name: 'conversation', path: '/notice/:id', component: ConversationPage, meta: { dontScroll: true } }, { name: 'external-user-profile', path: '/users/:id', component: UserProfile }, - { name: 'mentions', path: '/users/:username/interactions', component: Interactions }, + { name: 'interactions', path: '/users/:username/interactions', component: Interactions }, { name: 'dms', path: '/users/:username/dms', component: DMs }, { name: 'settings', path: '/settings', component: Settings }, { name: 'registration', path: '/registration', component: Registration }, diff --git a/src/components/interactions/interactions.vue b/src/components/interactions/interactions.vue index 751e5d40..5a204ca7 100644 --- a/src/components/interactions/interactions.vue +++ b/src/components/interactions/interactions.vue @@ -9,9 +9,9 @@ ref="tabSwitcher" :onSwitch="onModeSwitch" > - - - + + +
  • - + {{ $t("nav.interactions") }}
  • diff --git a/src/components/notifications/notifications.js b/src/components/notifications/notifications.js index acc31986..3a6e3b94 100644 --- a/src/components/notifications/notifications.js +++ b/src/components/notifications/notifications.js @@ -7,9 +7,15 @@ import { } from '../../services/notification_utils/notification_utils.js' const Notifications = { - props: [ - 'noHeading', 'minimalMode', 'filterMode' - ], + props: { + // Disables display of panel header + noHeading: Boolean, + // Disables panel styles, unread mark, potentially other notification-related actions + // meant for "Interactions" timeline + minimalMode: Boolean, + // Custom filter mode, an array of strings, possible values 'mention', 'repeat', 'like', 'follow', used to override global filter for use in "Interactions" timeline + filterMode: Array + }, data () { return { bottomedOut: false diff --git a/src/components/notifications/notifications.scss b/src/components/notifications/notifications.scss index c0b458cc..622d12f4 100644 --- a/src/components/notifications/notifications.scss +++ b/src/components/notifications/notifications.scss @@ -1,8 +1,10 @@ @import '../../_variables.scss'; .notifications { - // a bit of a hack to allow scrolling below notifications - padding-bottom: 15em; + &:not(.minimal) { + // a bit of a hack to allow scrolling below notifications + padding-bottom: 15em; + } .loadmore-error { color: $fallback--text; diff --git a/src/components/notifications/notifications.vue b/src/components/notifications/notifications.vue index 3c3ae191..c71499b2 100644 --- a/src/components/notifications/notifications.vue +++ b/src/components/notifications/notifications.vue @@ -1,5 +1,5 @@