|
@@ -4,6 +4,7 @@ $(function() {
|
|
needPower: ['yyszb'],
|
|
needPower: ['yyszb'],
|
|
data: {},
|
|
data: {},
|
|
imageViewer: null,
|
|
imageViewer: null,
|
|
|
|
+ lastScrollCall: null,
|
|
init: function() {
|
|
init: function() {
|
|
var pageCodeList = Object.keys(__page_config)
|
|
var pageCodeList = Object.keys(__page_config)
|
|
var success = this.initPageData()
|
|
var success = this.initPageData()
|
|
@@ -11,6 +12,12 @@ $(function() {
|
|
console.log('页面数据初始化成功', pageCodeList)
|
|
console.log('页面数据初始化成功', pageCodeList)
|
|
this.initModule()
|
|
this.initModule()
|
|
}
|
|
}
|
|
|
|
+ $(window).on('scroll', function() {
|
|
|
|
+ this.windowScrollFn()
|
|
|
|
+ }.bind(this))
|
|
|
|
+ $(window).on('resize', function() {
|
|
|
|
+ this.windowScrollFn()
|
|
|
|
+ }.bind(this))
|
|
},
|
|
},
|
|
initPageData: function() {
|
|
initPageData: function() {
|
|
var code = __pageInfo.code
|
|
var code = __pageInfo.code
|
|
@@ -239,6 +246,20 @@ $(function() {
|
|
})
|
|
})
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
+ windowScrollFn: function() {
|
|
|
|
+ // 判断留资模块是否处于可视区域
|
|
|
|
+ var mainFooter = $('.j-bottom')
|
|
|
|
+ var stickyBanner= $('.bottom-banner-container')
|
|
|
|
+ if (!mainFooter.length) return
|
|
|
|
+
|
|
|
|
+ var now = Date.now()
|
|
|
|
+ if (this.lastScrollCall && now - this.lastScrollCall < 100) return
|
|
|
|
+ this.lastScrollCall = now
|
|
|
|
+ // 精确计算元素位置
|
|
|
|
+ var rect = mainFooter[0].getBoundingClientRect()
|
|
|
|
+ var isInViewport = rect.top <= window.innerHeight && rect.bottom >= 0
|
|
|
|
+ stickyBanner.toggleClass('fixed', !isInViewport)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
__page.init();
|
|
__page.init();
|
|
})
|
|
})
|