From 0a3a3d0e2d8428b61ef1510eb850ff8ec41fb615 Mon Sep 17 00:00:00 2001 From: xieyuhang Date: Wed, 3 Jun 2020 12:26:23 +0800 Subject: [PATCH 1/5] feat: add tagviews drag sort --- src/layout/components/TagsView/ScrollPane.vue | 9 +-- src/layout/components/TagsView/index.vue | 66 +++++++++++-------- src/store/modules/tagsView.js | 6 ++ 3 files changed, 50 insertions(+), 31 deletions(-) diff --git a/src/layout/components/TagsView/ScrollPane.vue b/src/layout/components/TagsView/ScrollPane.vue index 34a7e55f..655b6cce 100644 --- a/src/layout/components/TagsView/ScrollPane.vue +++ b/src/layout/components/TagsView/ScrollPane.vue @@ -34,11 +34,12 @@ export default { emitScroll() { this.$emit('scroll') }, - moveToTarget(currentTag) { + moveToTarget(currentRoute) { const $container = this.$refs.scrollContainer.$el const $containerWidth = $container.offsetWidth const $scrollWrapper = this.scrollWrapper - const tagList = this.$parent.$refs.tag + const tagList = Array.from(window.document.querySelectorAll('#tags-view-container .tags-view-item')) + const currentTag = tagList.find(i => i.dataset.fullPath === currentRoute.fullPath) let firstTag = null let lastTag = null @@ -60,10 +61,10 @@ export default { const nextTag = tagList[currentIndex + 1] // the tag's offsetLeft after of nextTag - const afterNextTagOffsetLeft = nextTag.$el.offsetLeft + nextTag.$el.offsetWidth + tagAndTagSpacing + const afterNextTagOffsetLeft = nextTag.offsetLeft + nextTag.offsetWidth + tagAndTagSpacing // the tag's offsetLeft before of prevTag - const beforePrevTagOffsetLeft = prevTag.$el.offsetLeft - tagAndTagSpacing + const beforePrevTagOffsetLeft = prevTag.offsetLeft - tagAndTagSpacing if (afterNextTagOffsetLeft > $scrollWrapper.scrollLeft + $containerWidth) { $scrollWrapper.scrollLeft = afterNextTagOffsetLeft - $containerWidth diff --git a/src/layout/components/TagsView/index.vue b/src/layout/components/TagsView/index.vue index d2a56e70..7a3d3067 100644 --- a/src/layout/components/TagsView/index.vue +++ b/src/layout/components/TagsView/index.vue @@ -1,20 +1,22 @@