From eecb90ed17b9d0e7af5d74dca46f3f7f1ce6981d Mon Sep 17 00:00:00 2001 From: AmyFoxFN Date: Thu, 3 May 2018 18:18:07 +0800 Subject: [PATCH] [fix] index-list: title height --- src/components/index-list/index-list.vue | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/components/index-list/index-list.vue b/src/components/index-list/index-list.vue index 0d07bf82..e59e4851 100644 --- a/src/components/index-list/index-list.vue +++ b/src/components/index-list/index-list.vue @@ -95,15 +95,14 @@ currentIndex: 0, scrollY: -1, diff: -1, - titleHeight: null + titleHeight: 0 } }, computed: { fixedTitle() { - if (this.titleHeight === null || this.scrollY > -this.titleHeight) { - return '' - } - return this.data[this.currentIndex] ? this.data[this.currentIndex].name : '' + this.title && !this.titleHeight && this._caculateTitleHeight() + + return this.scrollY <= -this.titleHeight && this.data[this.currentIndex] ? this.data[this.currentIndex].name : '' }, shortcutList() { return this.data.map((group) => { @@ -127,7 +126,7 @@ }, mounted() { this.$nextTick(() => { - this.titleHeight = this.title && this.$refs.title ? getRect(this.$refs.title).height : 0 + this.title && this._caculateTitleHeight() this._calculateHeight() }) }, @@ -172,6 +171,9 @@ onPullingDown() { this.$emit(EVENT_PULLING_DOWN) }, + _caculateTitleHeight() { + this.titleHeight = this.$refs.title ? getRect(this.$refs.title).height : 0 + }, _calculateHeight() { this.groupList = this.$el.getElementsByClassName('cube-index-list-group') const subTitleEl = this.$el.getElementsByClassName('cube-index-list-anchor')[0] @@ -208,7 +210,7 @@ }, title(newVal) { this.$nextTick(() => { - this.titleHeight = newVal && this.$refs.title ? getRect(this.$refs.title).height : 0 + this._caculateTitleHeight() this._calculateHeight() }) }, -- GitLab