Authored by biao

fix layer position update bug

... ... @@ -45,7 +45,7 @@ $fixTitleBar.css({
minBrandListTop = brandSwipe + $('.hot-brand').outerHeight() + $('.banner-top').outerHeight();
$brandList.last().append($fixTitleBar);
$(window).scroll(function() {
function scrollHandler() {
var scrTop = $(window).scrollTop();
if ($brandList.eq(0).offset().top < minBrandListTop) {
... ... @@ -62,6 +62,10 @@ $(window).scroll(function() {
}
});
}
$(window).scroll(function() {
window.requestAnimationFrame(scrollHandler);
});
function changeBackground() {
... ...
... ... @@ -107,12 +107,16 @@ $nav.on('touchend touchcancel', function(e) {
}
});
$(document).scroll(function() {
function scrollHandler() {
var $c = $infos.not('.hide');
if ($(window).scrollTop() + winH >= $(document).height() - 0.25 * $c.height()) {
loadMore($c, state[curType]);
}
}
$(window).scroll(function() {
window.requestAnimationFrame(scrollHandler);
});
$nav.on('touchstart', function(e) {
... ...
... ... @@ -40,8 +40,12 @@ if ($tag.length > 0) {
});
}
$(document).scroll(function() {
function scrollHandler() {
if ($(window).scrollTop() + winH >= $(document).height() - 0.25 * $infos.height()) {
loadMore($infos, setting);
}
}
$(window).scroll(function() {
window.requestAnimationFrame(scrollHandler);
});
\ No newline at end of file
... ...
... ... @@ -133,13 +133,17 @@ function search() {
});
}
$('.maybe-like p').on('touchstart', function (e) {
$('.maybe-like p').on('touchstart', function(e) {
search();
});
//srcoll to load more
$(window).scroll(function () {
function scrollHandler() {
if ($(window).scrollTop() + winH >= $(document).height() - 50) {
search();
}
}
$(window).scroll(function() {
window.requestAnimationFrame(scrollHandler);
});
\ No newline at end of file
... ...
... ... @@ -18,45 +18,14 @@ var $search = $searchBox.children('input[type="text"]'),
$cancelSearch = $box.children('.no-search'),
$searchIcon = $searchBox.children('.search-icon');
var updateLayerPosition = (function() {
var init = false,
windowViewHeight = 0;
return function() {
var winHeight = window.innerHeight,
bodyHeight = $doc.height(),
scrollTopPosition = $win.scrollTop(),
// variables for calculate the app download layer position
var layerInit = false,
windowViewHeight = 0,
layerContentHeight = $appFloatLayer.height(),
layerPaddingTop = parseInt($appFloatLayer.css('padding-top')),
layerPaddingBottom = parseInt($appFloatLayer.css('padding-bottom')),
layerHeight = layerContentHeight + layerPaddingTop + layerPaddingBottom,
newPosition;
if (init) {
//keyboard is shown
if (windowViewHeight - winHeight > 200) {
newPosition = bodyHeight - winHeight - scrollTopPosition - layerHeight;
} else {
newPosition = bodyHeight - winHeight - scrollTopPosition;
}
if (scrollTopPosition + winHeight === bodyHeight) {
newPosition = 0;
}
} else {
windowViewHeight = winHeight;
newPosition = bodyHeight - winHeight - scrollTopPosition + layerHeight;
init = true;
}
$appFloatLayer.css({
position: 'relative',
bottom: newPosition + 'px'
});
};
})();
layerNewPos;
require('../common');
... ... @@ -110,9 +79,38 @@ $channelLink.on('touchstart', function() {
});
$win.scroll(function() {
updateLayerPosition();
});
function updateLayerPosition() {
var winHeight = window.innerHeight,
bodyHeight = $doc.height(),
scrollTopPosition = $win.scrollTop();
if (layerInit) {
//keyboard is shown
if (windowViewHeight - winHeight > 200) {
if (scrollTopPosition + windowViewHeight + layerHeight >= bodyHeight) {
layerNewPos = 0;
} else {
layerNewPos = bodyHeight - windowViewHeight - scrollTopPosition - layerHeight;
}
} else {
layerNewPos = bodyHeight - winHeight - scrollTopPosition;
}
} else {
windowViewHeight = winHeight;
layerNewPos = bodyHeight - winHeight - scrollTopPosition + layerHeight;
layerInit = true;
}
$appFloatLayer.css({
position: 'relative',
bottom: layerNewPos + 'px'
});
}
$(window).scroll(function() {
window.requestAnimationFrame(updateLayerPosition);
});
$doc.on('ready', updateLayerPosition);
... ...
... ... @@ -164,6 +164,12 @@ $addressListPage.find('.address-last').each(function(i, elem) {
});
});
$addressListPage.on('touchstart', 'li', function() {
$(this).addClass('highlight');
}).on('touchend touchcancel', 'li', function() {
$(this).removeClass('highlight');
});
$('input, textarea').on('focus', function() {
$footer.hide();
}).on('blur', function() {
... ...
var $ = require('jquery'),
Hammer = require('yoho.hammer');
Hammer = require('yoho.hammer'),
ellipsis = require('mlellipsis');
var employ;
ellipsis.init();
//Żȯ2ʾ
setTimeout(function() {
$('.coupon-name').each(function() {
this.mlellipsis(2);
});
}, 0);
window.rePosFooter();
$('.yoho-footer').css('border-top', '1px solid #e0e0e0');
$('.employ span').each(function(index) {
... ...
... ... @@ -206,9 +206,8 @@ favContentHammer.on('tap', function(e) {
});
});
// 上拉加载更多
$(document).scroll(function() {
function scrollHandler() {
if ($(window).scrollTop() + winH >= $(document).height() - footerH) {
if (brandTab) {
... ... @@ -231,4 +230,8 @@ $(document).scroll(function() {
}
}
}
}
$(window).scroll(function() {
window.requestAnimationFrame(scrollHandler);
});
\ No newline at end of file
... ...
... ... @@ -18,13 +18,17 @@ var setting = {
end: false
};
function scrollHandler() {
if ($(window).scrollTop() + winH >= $(document).height() - 0.25 * $infoList.height()) {
loadMore($infoList, setting, '/home/myguang');
}
}
//对于有逛收藏的页面进行事件处理
if ($infoList.length > 0) {
info.initInfosEvt($infoList);
$(window).scroll(function() {
if ($(window).scrollTop() + winH >= $(document).height() - 0.25 * $infoList.height()) {
loadMore($infoList, setting, '/home/myguang');
}
window.requestAnimationFrame(scrollHandler);
});
}
\ No newline at end of file
... ...
... ... @@ -167,7 +167,7 @@ orderHammer.on('tap', function(e) {
}
});
$(window).scroll(function() {
function scrollHandler() {
if (order.end === false && $(window).scrollTop() + winH >
$(document).height() - 0.25 * $orderContainer.height()) {
... ... @@ -176,6 +176,10 @@ $(window).scroll(function() {
noLoadingMask: true
});
}
}
$(window).scroll(function() {
window.requestAnimationFrame(scrollHandler);
});
//初始化请求第一页数据
... ...
... ... @@ -362,13 +362,17 @@ $listNav.on('touchend touchcancel', function(e) {
}
});
$(window).scroll(function() {
function scrollHandler() {
//当scroll到1/4$goodsContainer高度后继续请求下一页数据
if ($(window).scrollTop() + winH >
$(document).height() - 0.25 * $goodsContainer.height()) {
search();
}
}
$(window).scroll(function() {
window.requestAnimationFrame(scrollHandler);
});
if ($brandHeader.length > 0) {
... ...
... ... @@ -347,11 +347,10 @@ $listNav.on('touchend touchcancel', function(e) {
search();
}
}
e.stopPropagation();
});
$(window).scroll(function() {
function scrollHandler() {
//当scroll到1/4$goodsContainer高度后继续请求下一页数据
if ($(window).scrollTop() + winH >
... ... @@ -360,6 +359,10 @@ $(window).scroll(function() {
search();
}
}
}
$(window).scroll(function() {
window.requestAnimationFrame(scrollHandler);
});
//初始请求最新第一页数据
... ...
... ... @@ -53,7 +53,8 @@ function hotrank(page, sort, tabId, notab) {
});
}
$(window).scroll(function () {
function scrollHandler() {
if (page === 2) {
return;
}
... ... @@ -63,11 +64,15 @@ $(window).scroll(function () {
page = 2;
notab = 1;
hotrank(page, sort, id, notab);
}
$(window).scroll(function() {
window.requestAnimationFrame(scrollHandler);
});
hotrank(page, sort, id, notab);
hotnav = new Hammer(document.getElementById('hotRank'));
hotnav.on('tap', function (e) {
hotnav.on('tap', function(e) {
var ev = ev || window.event;
var target = ev.target || ev.srcElement;
... ...
... ... @@ -359,7 +359,8 @@ $listNav.on('touchend touchcancel', function(e) {
e.stopPropagation();
});
$(window).scroll(function() {
function scrollHandler() {
//当scroll到1/4$goodsContainer高度后继续请求下一页数据
if ($(window).scrollTop() + winH >
... ... @@ -368,6 +369,10 @@ $(window).scroll(function() {
search();
}
}
}
$(window).scroll(function() {
window.requestAnimationFrame(scrollHandler);
});
//初始请求最新第一页数据
... ...
... ... @@ -207,10 +207,16 @@
font-size: pxToRem(32px);
line-height: pxToRem(88px);
border-bottom: 1px solid #e0e0e0;
.iconfont {
float: right;
color: #d0d0d0;
}
&.highlight {
background: #eee;
}
ul {
display: none;
position: absolute;
... ...
... ... @@ -3,6 +3,7 @@
height: 90rem / $pxConvertRem;
overflow: hidden;
border-bottom:1px solid #e0e0e0;
position: relative;
span{
width: 49%;
height: 48rem / $pxConvertRem;
... ... @@ -72,7 +73,7 @@
position: absolute;
left: 0;
top:50%;
@include transform(translateY(-60%));
@include transform(translateY(-50%));
i{
width: 100%;
height: 120rem / $pxConvertRem;
... ... @@ -100,7 +101,7 @@
background: #444444;
color: #fff;
text-align: center;
margin: 32em / $pxConvertRem auto;
margin: 60rem / $pxConvertRem auto 0;
@include border-radius(.2rem);
}
... ...