Authored by xuqi

return top logic

... ... @@ -343,7 +343,7 @@
</div>
</div>
</div>
<div class="return-top">
<div class="return-top hide">
<span class="iconfont">&#xe610;</span>
</div>
</div>
\ No newline at end of file
... ...
... ... @@ -10,8 +10,6 @@ require('./footer');
require('./simple-header');
require('./header');
function cookie(name) {
var cookies = document.cookie,
cookieVal,
... ...
... ... @@ -6,6 +6,8 @@
var $ = require('yoho.jquery');
var $returnTop = $('.return-top');
var apiDomain;
/**
... ... @@ -126,6 +128,39 @@ function actionhomeFootChange() {
});
}
function rePosReturn() {
if ($(window).height() < $(document).height()) {
$returnTop.removeClass('hide');
} else {
$returnTop.addClass('hide');
}
}
//返回顶部
$returnTop.click(function() {
$('html,body').animate({
scrollTop: 0
}, 500);
});
$(window).scroll(function() {
if ($(window).scrollTop() === 0) {
$returnTop.addClass('hide');
} else {
$returnTop.removeClass('hide');
}
});
rePosReturn();
//如果初始是隐藏的,监听图片加载,重新确定return-top的高度
if ($returnTop.hasClass('hide')) {
$('img').load(rePosReturn);
}
//初始化
actionSubscription();
actionhomeFootChange();
//暴露给有可能通AJAX改变内容的页面去用
window.rePosReturnTop = rePosReturn;
... ...