From 87ce0f7e0620291f59cddeef8eddc7b8f7befb0b Mon Sep 17 00:00:00 2001 From: song Date: Fri, 10 Sep 2021 15:21:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B7=BB=E5=8A=A0=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E5=8A=9F=E8=83=BD=20=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E8=A7=92=E8=89=B2=E6=BB=9A=E5=8A=A8bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + src/components/Roles/Roles.vue | 24 ++++++++++++++++-------- src/components/Title/Title.vue | 6 ++++-- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 43e08ca..730aeff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -158,6 +158,7 @@ - | 监听时间基本点 | [033fca0](https://dd.tall.wiki/gitea/wally/tall-mui-3-project/commits/033fca0) - | 角色显示状态修改 | [7d3b906](https://dd.tall.wiki/gitea/wally/tall-mui-3-project/commits/7d3b906) - | 角色栏修改 | [19228d6](https://dd.tall.wiki/gitea/wally/tall-mui-3-project/commits/19228d6) + - | 角色滚动问题修复 | [c8ee189](https://dd.tall.wiki/gitea/wally/tall-mui-3-project/commits/c8ee189) - | 解决时间轴报错 | [da1eece](https://dd.tall.wiki/gitea/wally/tall-mui-3-project/commits/da1eece) - | 设置时间轴自动滚动到当前位置 | [a3474f8](https://dd.tall.wiki/gitea/wally/tall-mui-3-project/commits/a3474f8) - | 调试定期任务bug;不能合并使用 | [d641312](https://dd.tall.wiki/gitea/wally/tall-mui-3-project/commits/d641312) diff --git a/src/components/Roles/Roles.vue b/src/components/Roles/Roles.vue index 72d76cb..18a56d0 100644 --- a/src/components/Roles/Roles.vue +++ b/src/components/Roles/Roles.vue @@ -46,6 +46,7 @@ export default { { id: 1, name: '项目经理', mine: 0, pm: 1, sequence: 1 }, { id: 2, name: '运维', mine: 0, pm: 0, sequence: 2 }, ], + roleLeft: 0, }; }, @@ -69,6 +70,16 @@ export default { } else { this.roles = [...this.visibleRoles]; } + + this.$nextTick(() => { + const query = uni.createSelectorQuery().in(this); + query + .selectAll('.tab-children') + .boundingClientRect(data => { + this.roleLeft = data[0].left; + }) + .exec(); + }); }, methods: { @@ -77,7 +88,6 @@ export default { ...mapMutations('task', ['setPermanents', 'clearEndFlag']), scroll(e) { - console.log(e.detail.scrollLeft); this.scrollLeft = e.detail.scrollLeft; }, @@ -88,10 +98,7 @@ export default { .selectAll('.tab-children') .boundingClientRect(data => { data.forEach(item => { - this.tabList.push({ - width: item.width, - left: item.left, - }); + this.tabList.push({ width: item.width }); }); }) .exec(); @@ -102,14 +109,15 @@ export default { // 当前滚动的位置 let left = 0; for (let i = 0; i < index; i++) { - left += this.tabList[i].width + (this.tabList[0].left - 8) * 2; + left += this.tabList[i].width + (this.roleLeft - 8) * 2; } - left += (this.tabList[index].width + (this.tabList[0].left - 8) * 2) / 2; + + left += (this.tabList[index].width + (this.roleLeft - 8) * 2) / 2; if (left > screenWidth) { this.scrollLeft = left - screenWidth + screenWidth / 2; } else if (left > screenWidth / 2) { this.scrollLeft = left - screenWidth / 2; - } else { + } else if (left < screenWidth / 2) { this.scrollLeft = 0; } }, diff --git a/src/components/Title/Title.vue b/src/components/Title/Title.vue index 3d52c26..b4f5a2d 100644 --- a/src/components/Title/Title.vue +++ b/src/components/Title/Title.vue @@ -1,6 +1,7 @@