Authored by 陈峰

wap优化第一版开发结束等Back to Top图标

... ... @@ -5,6 +5,7 @@
Back to top
<i class="iconfont">&#xe608;</i>
</span>
<div class="float-top ">Top</div>
</p>
<address class="copyright">
CopyRight©2007-2016 南京新与力文化传播有限公司
... ...
... ... @@ -165,11 +165,13 @@ $.extend({
// 页面通用底部位置及status设置
(function() {
var $op = $footer.children('.op-row'),
$backToTop = $('.back-to-top');
$backToTop = $('.back-to-top'),
$floatTop = $('.float-top');
var user = getUser();
var backToTopHammer;
var floatTopHammer;
rePosFooter(); // 计算底部位置
... ... @@ -199,6 +201,14 @@ $.extend({
return false;
});
}
if ($floatTop.length > 0) {
floatTopHammer = new Hammer($floatTop[0]);
floatTopHammer.on('tap', function(e) {
$(window).scrollTop(0);
e.srcEvent.preventDefault();
return false;
});
}
$footer.removeClass('hide');
... ...
... ... @@ -31,9 +31,10 @@ function init($container, options) {
$loading = $container.children('.loading-mask');
$('body').on('touchstart touchmove touchend', '.loading-mask', function() {
return false;
});
//产品优化loading时可以滑动
// $('body').on('touchstart touchmove touchend', '.loading-mask', function() {
// return false;
// });
}
// 显示loading
... ...
... ... @@ -11,10 +11,12 @@ var $ = require('yoho-jquery'),
require('./detail/page-render')(function() {
var $discountFolder = $('.goods-discount .discount-folder'),
$discountArrow = $('.goods-discount .first-item span');
$discountArrow = $('.goods-discount .first-item span'),
$bannerSwiper = $('.banner-swiper');
var goodsDiscountEl = document.getElementById('goodsDiscount'),
goodsDiscountHammer = goodsDiscountEl && new Hammer(goodsDiscountEl),
bannerSwiperHammer = new Hammer($bannerSwiper[0]),
$discountFirstItem = $(goodsDiscountEl).find('.first-item');
var $cart = $('.cart-bar');
... ... @@ -48,7 +50,7 @@ require('./detail/page-render')(function() {
}
// 顶部swiper
new Swiper('.banner-swiper', {
var swiper = new Swiper('.banner-swiper', {
lazyLoading: true,
lazyLoadingInPrevNext: true,
paginationClickable: true,
... ... @@ -57,6 +59,10 @@ require('./detail/page-render')(function() {
prevButton: '.my-swiper-button-prev',
spaceBetween: 3
});
bannerSwiperHammer.on('tap', function() {
$('.banner-top').toggleClass('hover');
swiper.onResize();
})
// 初始化goods-discount
if ($discountFolder.children().length === 0) {
... ... @@ -151,6 +157,31 @@ require('./detail/page-render')(function() {
if ($('.good-detail-page').length > 0) {
$('#yoho-footer').css('border-top', '1px solid #e0e0e0');
}
//加载详情页的返回顶部按钮并注册事件
$(document).scroll(function() {
if($(document).scrollTop() >= $(document).height() - $(window).height() - 20) {
if (!$('.float-top').hasClass('animation')) {
console.log('animation')
var top = $('.back-to-top').offset().top - $('.float-top').offset().top + ($('.back-to-top').height()-$('.float-top').height())/2;
var left = $('.back-to-top').offset().left - $('.float-top').offset().left;
$('.float-top').addClass('animation').css({
'transform': 'translate('+left+'px, '+top+'px) scale(0, 0)',
});
}
} else if ($('.product-detail').length && $(document).scrollTop() >= $('.product-detail').offset().top) {
if (!$('.float-top').hasClass('hover') || $('.float-top').hasClass('animation')) {
console.log('hover')
$('.float-top').addClass('hover').removeClass('animation').removeAttr('style');
}
} else {
if ($('.float-top').hasClass('hover')) {
console.log('remove hover')
$('.float-top').removeClass('hover');
}
}
})
//加载详情页的返回顶部按钮并注册事件-end
});
... ...
... ... @@ -207,6 +207,30 @@ $basicBtnC: #eb0313;
position: relative;
overflow: hidden;
min-height: 660px;
display: flex;
align-items: center;
&.hover {
position: fixed;
width: 100%;
background-color: black;
height: 100%;
top: 0px;
left: 0px;
right: 0px;
border: 0px;
z-index: 999;
.banner-swiper {
margin: 0px 0px !important;
overflow: initial !important;
max-height: initial !important;
ul {
max-height: initial !important;
}
}
.swiper-pagination-bullet-active {
background-color: #FFF !important;
}
}
.swiper-pagination {
position: absolute;
... ... @@ -887,3 +911,30 @@ $basicBtnC: #eb0313;
iframe {
display: none;
}
.float-top {
position: absolute;
top: 47px;
right: 47px;
left: initial;
bottom: initial;
border-radius: 50%;
color: #fff;
width: 50px;
height: 50px;
background-color: rgba(0,0,0,0.7);
display: none;
transition: transform 0.5s;
-webkit-transition: transform 0.5s;
&.hover {
position: fixed;
top: initial;
left: initial;
right: 47px;
bottom: 250px;
z-index: 9999;
display: block;
}
&.animation {
}
}
\ No newline at end of file
... ...