Authored by biao

fix layer display issue

... ... @@ -9,7 +9,10 @@ var $searchBox = $('.search-box'),
$box = $('.box'),
$indexSearch = $('.index-search'),
$indexLogo = $('.index-logo'),
$channelLink = $('.index-channel a');
$channelLink = $('.index-channel a'),
$win = $(window),
$doc = $(document),
$appFloatLayer = $('#float-layer-app');
var $search = $searchBox.children('input[type="text"]'),
$cancelSearch = $box.children('.no-search'),
... ... @@ -65,3 +68,43 @@ $channelLink.on('touchstart', function() {
borderColor: '#fff'
});
});
var removeAppFloatLayerFixed = (function() {
var init = false;
return function() {
var winHeight = window.innerHeight;
var bodyHeight = $doc.height();
var scrollTopPosition = $win.scrollTop();
var layerHeight = $appFloatLayer.height();
var layerPaddingTop = parseInt($appFloatLayer.css('padding-top'));
var layerPaddingBottom = parseInt($appFloatLayer.css('padding-bottom'));
var newPosition;
if(init){
newPosition = bodyHeight - winHeight- scrollTopPosition;
}else{
init = true;
newPosition = bodyHeight - winHeight - scrollTopPosition + layerHeight + layerPaddingTop + layerPaddingBottom;
}
$appFloatLayer.css({
'position': 'relative',
'bottom': newPosition + 'px'
});
};
})();
$win.scroll(function() {
clearTimeout($.data(this, 'scrollTimer'));
$.data(this, 'scrollTimer', setTimeout(function() {
removeAppFloatLayerFixed();
}, 2));
});
$win.on('resize', function(){
console.log('resize');
});
$win.on('scrollstop', function(){
console.log('stop');
});
$doc.on('ready', removeAppFloatLayerFixed);
... ...