From 0a5c0869cf80e66f0791c4951d25e2df02da9cce Mon Sep 17 00:00:00 2001 From: profi248 Date: Sat, 2 Jan 2021 13:34:42 +0100 Subject: [PATCH] Make adding fields to tasks more intuitive - briefly flash the background of (most) fields that have just been added - scroll the newly added field into viewport if not visible already --- src/styles/components/task.scss | 13 ++++++++++++ src/views/tasks/TaskDetailView.vue | 34 ++++++++++++++++++++++-------- 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/src/styles/components/task.scss b/src/styles/components/task.scss index 2ece6e716..628bb036e 100644 --- a/src/styles/components/task.scss +++ b/src/styles/components/task.scss @@ -254,3 +254,16 @@ .link-share-container .task-view { background-color: transparent; } + +.flash-background { + animation: flash-background 0.75s ease 1; +} + +@keyframes flash-background { + 0% { + background: lighten($primary, 30); + } + 100% { + background: transparent; + } +} \ No newline at end of file diff --git a/src/views/tasks/TaskDetailView.vue b/src/views/tasks/TaskDetailView.vue index b97ce3cee..528dd7fae 100644 --- a/src/views/tasks/TaskDetailView.vue +++ b/src/views/tasks/TaskDetailView.vue @@ -28,7 +28,7 @@ v-model="task.assignees" /> -
+
@@ -40,7 +40,7 @@ ref="priority" v-model="task.priority"/>
-
+
@@ -61,7 +61,7 @@
-
+
@@ -73,7 +73,7 @@ ref="percentDone" v-model="task.percentDone"/>
-
+
@@ -94,7 +94,7 @@
-
+
@@ -115,7 +115,7 @@
-
+
@@ -127,7 +127,7 @@ ref="reminders" v-model="task.reminderDates"/>
-
+
@@ -139,7 +139,7 @@ ref="repeatAfter" v-model="task"/>
-
+
@@ -546,7 +546,23 @@ export default { this.activeFields[fieldName] = true this.$nextTick(() => { if (this.$refs[fieldName]) { - this.$refs[fieldName].$el.focus() + this.$refs[fieldName].$el.focus(); + + // animate background flash with CSS animations (if the field's parent has a ref) + if (typeof this.$refs[fieldName + "Parent"] !== 'undefined') + this.$refs[fieldName + "Parent"].classList.add('flash-background'); + + // remove animation class after animation finishes + setTimeout(() => { + if (typeof this.$refs[fieldName + "Parent"] !== 'undefined') + this.$refs[fieldName + "Parent"].classList.remove('flash-background'); + }, 750); + + // scroll the field to the center of the screen if not in viewport already + const boundingRect = this.$refs[fieldName].$el.getBoundingClientRect(); + + if (boundingRect.top > (window.scrollY + window.innerHeight) || boundingRect.top < window.scrollY) + this.$refs[fieldName].$el.scrollIntoView({behavior: "smooth", block: "center", inline: "nearest"}); } }) },