pull/9/head
tjz 2018-02-03 11:20:05 +08:00
parent 35a8c72c0c
commit b88193e31d
1 changed files with 20 additions and 9 deletions

View File

@ -9,24 +9,28 @@ export default {
}, },
data () { data () {
this.offset = 0
return { return {
next: false, next: false,
prev: false, prev: false,
offset: 0,
} }
}, },
mounted () { mounted () {
this.$nextTick(() => {
this.updatedCal() this.updatedCal()
const debouncedResize = debounce(() => { const debouncedResize = debounce(() => {
this.setNextPrev() this.setNextPrev()
this.scrollToActiveTab() this.scrollToActiveTab()
}, 200) }, 200)
this.resizeEvent = addDOMEventListener(window, 'resize', debouncedResize) this.resizeEvent = addDOMEventListener(window, 'resize', debouncedResize)
})
}, },
updated () { updated () {
this.$nextTick(() => {
this.updatedCal() this.updatedCal()
})
}, },
beforeDestroy () { beforeDestroy () {
@ -36,11 +40,18 @@ export default {
}, },
watch: { watch: {
tabBarPosition (val) { tabBarPosition (val) {
this.tabBarPositionChange = true
this.$nextTick(() => {
this.setOffset(0) this.setOffset(0)
})
}, },
}, },
methods: { methods: {
updatedCal () { updatedCal () {
if (this.tabBarPositionChange) {
this.tabBarPositionChange = false
return
}
this.setNextPrev() this.setNextPrev()
this.$nextTick(() => { this.$nextTick(() => {
this.scrollToActiveTab() this.scrollToActiveTab()