|
|
@@ -28,7 +28,15 @@
|
|
|
},
|
|
|
methods: {
|
|
|
_calcaulateHeight() {
|
|
|
- this.bannerHeight = document.querySelectorAll('.normal-floor')[0].offsetTop
|
|
|
+ let _heis0 = document.querySelectorAll('header')[0].clientHeight
|
|
|
+ let _heis1 = document.querySelectorAll('.header.clearfix')[0].clientHeight
|
|
|
+ let _heis2 = document.querySelectorAll('.nav-list')[0].clientHeight
|
|
|
+ let _heis3 = document.querySelectorAll('.carousel')[0].clientHeight
|
|
|
+ let _heis4 = document.querySelectorAll('.advert-slide')[0].clientHeight
|
|
|
+ let _heis5 = document.querySelectorAll('.banner')[0].clientHeight
|
|
|
+ let _heis6 = document.querySelectorAll('.floor.price-floor')[0].clientHeight
|
|
|
+ let _heis7 = document.querySelectorAll('.floor.price-floor')[1].clientHeight
|
|
|
+ this.bannerHeight = _heis0 + _heis1 + _heis2 + _heis3 + _heis4 + _heis5 + _heis6 + _heis7
|
|
|
this.listHeight = []
|
|
|
this.list = document.querySelectorAll('.normal-floor')
|
|
|
let height = 0
|
|
|
@@ -36,7 +44,7 @@
|
|
|
for (let i = 0; i < this.list.length; i++) {
|
|
|
const item = this.list[i]
|
|
|
if (i === 0) {
|
|
|
- height += item.offsetTop + item.clientHeight / 2
|
|
|
+ height += this.bannerHeight + item.clientHeight / 2
|
|
|
} else {
|
|
|
height += item.clientHeight
|
|
|
}
|
|
|
@@ -46,23 +54,26 @@
|
|
|
onScroll () {
|
|
|
if (window.location.pathname === '/') {
|
|
|
let scrolled = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop
|
|
|
- this.visible = scrolled >= this.bannerHeight - window.innerHeight / 2 + 220
|
|
|
+ console.log(this.bannerHeight)
|
|
|
+ this.visible = scrolled >= this.bannerHeight - window.innerHeight / 2 + 200
|
|
|
+ // console.log(this.bannerHeight, window.innerHeight)
|
|
|
let _scrollHeight = scrolled
|
|
|
const listHeight = this.listHeight
|
|
|
for (let i = 0; i < listHeight.length; i++) {
|
|
|
let height1 = listHeight[i]
|
|
|
- // let height2 = listHeight[i + 1]
|
|
|
- console.log(height1, _scrollHeight)
|
|
|
- if (_scrollHeight >= height1) this.activeFloor = i
|
|
|
- // if (_scrollHeight >= height1 && _scrollHeight < height2) {
|
|
|
- // this.activeFloor = i
|
|
|
- // }
|
|
|
+ let height2 = listHeight[i + 1]
|
|
|
+ // console.log(height1, _scrollHeight)
|
|
|
+ // if (_scrollHeight >= height1) this.activeFloor = i
|
|
|
+ if (_scrollHeight >= height1 && _scrollHeight < height2) {
|
|
|
+ this.activeFloor = i
|
|
|
+ }
|
|
|
}
|
|
|
if (_scrollHeight > listHeight[listHeight.length - 1]) {
|
|
|
this.visible = false
|
|
|
}
|
|
|
// let floors = document.querySelectorAll('.normal-floor')
|
|
|
// let barOffset = document.querySelector('.floor-bar').offsetTop
|
|
|
+ // console.log(barOffset)
|
|
|
// if (floors[0].offsetTop === 0) {
|
|
|
// this.visible = scrolled >= floors[0].offsetTop + this.floor_scrollTop - barOffset && scrolled <= floors[floors.length - 1].offsetTop + floors[floors.length - 1].offsetHeight - barOffset - document.querySelector('.floor-bar').offsetHeight + this.floor_scrollTop
|
|
|
// if (this.visible) {
|