Merge branch 'feature/h5detail' of http://git.dev.yoho.cn/web/yohobuy-frontend into feature/h5detail
三角符号js修改 Conflicts: mobile/public/js/article-type-three.js mobile/public/sass/_article-type-three.scss mobile/views/partials/article-type-three.html
Showing
4 changed files
with
54 additions
and
44 deletions
mobile/public/img/thumb-container-bg.png
0 → 100644
3.29 KB
@@ -20,6 +20,26 @@ exports.init = function() { | @@ -20,6 +20,26 @@ exports.init = function() { | ||
20 | containerH, | 20 | containerH, |
21 | containerTop; | 21 | containerTop; |
22 | 22 | ||
23 | + /** | ||
24 | + * 计算小箭头位置函数 | ||
25 | + * @param index(类型为number,调用函数li的index) | ||
26 | + */ | ||
27 | + arrowPosition = function (element,index) { | ||
28 | + var clientWidth = document.documentElement.clientWidth, | ||
29 | + container = element, | ||
30 | + item = container.find('li'), | ||
31 | + len = item.size(), | ||
32 | + midNum = Math.ceil(len / 2), | ||
33 | + documentFont = parseInt($("html").css("fontSize")), | ||
34 | + itemMarginRight = parseInt(item.css('marginRight'))/ documentFont * 40, | ||
35 | + itemWidth = item.width() / documentFont * 40, | ||
36 | + surPlusValue = parseInt(container.css('padding-left'))/ documentFont * 40 - itemMarginRight, | ||
37 | + backgroundLeft; | ||
38 | + | ||
39 | + backgroundLeft = -(320 - (index - midNum) * (itemWidth + itemMarginRight) - surPlusValue)/40 + 'rem'; | ||
40 | + container.css({"backgroundPosition":backgroundLeft + " bottom"}) | ||
41 | + }; | ||
42 | + | ||
23 | //点击分类,显示分类下推荐商品列表 | 43 | //点击分类,显示分类下推荐商品列表 |
24 | thumbContainer.delegate('.thumb', 'click', function() { | 44 | thumbContainer.delegate('.thumb', 'click', function() { |
25 | var curItem, | 45 | var curItem, |
@@ -29,6 +49,7 @@ exports.init = function() { | @@ -29,6 +49,7 @@ exports.init = function() { | ||
29 | index = curItem.index(); | 49 | index = curItem.index(); |
30 | thumbContainer.find('.thumb').removeClass('focus') | 50 | thumbContainer.find('.thumb').removeClass('focus') |
31 | curItem.addClass('focus'); | 51 | curItem.addClass('focus'); |
52 | + arrowPosition(thumbContainer,index + 1); | ||
32 | 53 | ||
33 | prodList.find('.prod') | 54 | prodList.find('.prod') |
34 | .addClass('hide') | 55 | .addClass('hide') |
@@ -66,15 +87,23 @@ exports.init = function() { | @@ -66,15 +87,23 @@ exports.init = function() { | ||
66 | thumbContainer | 87 | thumbContainer |
67 | .addClass('fixed-bottom') | 88 | .addClass('fixed-bottom') |
68 | .removeClass('static'); | 89 | .removeClass('static'); |
90 | + prodList.css({ | ||
91 | + 'margin-top': tContainerH | ||
92 | + }); | ||
69 | } else if (sTop <= containerTop) { | 93 | } else if (sTop <= containerTop) { |
70 | thumbContainer | 94 | thumbContainer |
71 | .addClass('static') | 95 | .addClass('static') |
72 | - .removeClass('fixed-bottom fixed-top'); | 96 | + .removeClass('fixed-bottom fixed-top') |
97 | + .css('top' , ''); | ||
98 | + prodList.removeAttr('style') | ||
73 | } else if (sTop <= containerTop + containerH - tContainerH) { | 99 | } else if (sTop <= containerTop + containerH - tContainerH) { |
74 | thumbContainer | 100 | thumbContainer |
75 | .addClass('fixed-top') | 101 | .addClass('fixed-top') |
76 | .removeClass('static absolute') | 102 | .removeClass('static absolute') |
77 | - .removeAttr('style'); | 103 | + .css('top' , ''); |
104 | + prodList.css({ | ||
105 | + 'margin-top': tContainerH | ||
106 | + }); | ||
78 | } else if (sTop <= containerTop + containerH) { | 107 | } else if (sTop <= containerTop + containerH) { |
79 | thumbContainer | 108 | thumbContainer |
80 | .addClass('absolute') | 109 | .addClass('absolute') |
@@ -82,11 +111,15 @@ exports.init = function() { | @@ -82,11 +111,15 @@ exports.init = function() { | ||
82 | .css({ | 111 | .css({ |
83 | top: containerTop + containerH - tContainerH | 112 | top: containerTop + containerH - tContainerH |
84 | }); | 113 | }); |
114 | + prodList.css({ | ||
115 | + 'margin-top': tContainerH | ||
116 | + }); | ||
85 | } else if (sTop > containerTop + containerH) { | 117 | } else if (sTop > containerTop + containerH) { |
86 | thumbContainer | 118 | thumbContainer |
87 | .addClass('static') | 119 | .addClass('static') |
88 | .removeClass('absolute') | 120 | .removeClass('absolute') |
89 | - .removeAttr('style'); | 121 | + .css('top' , ''); |
122 | + prodList.removeAttr('style'); | ||
90 | } | 123 | } |
91 | }); | 124 | }); |
92 | 125 | ||
@@ -95,23 +128,5 @@ exports.init = function() { | @@ -95,23 +128,5 @@ exports.init = function() { | ||
95 | $(document).scroll(); | 128 | $(document).scroll(); |
96 | } | 129 | } |
97 | 130 | ||
98 | - //计算小箭头位置 | ||
99 | - (function (doc, win) { | ||
100 | - var docEl = doc.documentElement, | ||
101 | - resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize', | ||
102 | - arrowPosition = function () { | ||
103 | - var clientWidth = docEl.clientWidth; | ||
104 | - if (!clientWidth) { | ||
105 | - return; | ||
106 | - } | ||
107 | - docEl.style.fontSize = 20 * (clientWidth / 320) + 'px'; | ||
108 | - }; | ||
109 | - | ||
110 | - if (!doc.addEventListener) { | ||
111 | - return; | ||
112 | - } | ||
113 | - win.addEventListener(resizeEvt, arrowPosition, false); | ||
114 | - doc.addEventListener('DOMContentLoaded', arrowPosition, false); | ||
115 | - })(document, window); | ||
116 | }); | 131 | }); |
117 | }; | 132 | }; |
@@ -2,21 +2,15 @@ | @@ -2,21 +2,15 @@ | ||
2 | $pxConvertRem : 40; | 2 | $pxConvertRem : 40; |
3 | 3 | ||
4 | .article-type-three { | 4 | .article-type-three { |
5 | - padding:0 0 0 15rem / $pxConvertRem; | ||
6 | background: #fff; | 5 | background: #fff; |
7 | 6 | ||
8 | - /*container脱离文本流时占位用,指定高度为内部所有内容高度*/ | ||
9 | - .container-fixed-pos { | ||
10 | - height: 195rem / $pxConvertRem; | ||
11 | - margin-left: -15rem / $pxConvertRem; | ||
12 | - | ||
13 | - } | ||
14 | - | ||
15 | .thumb-container { | 7 | .thumb-container { |
16 | font-size: 0; | 8 | font-size: 0; |
17 | - padding: 30rem / $pxConvertRem 0 0 30rem / $pxConvertRem; /*修改padding-bottom时请修正.container-fixed-pos高度*/ | 9 | + padding: 30rem / $pxConvertRem 0 0 30rem / $pxConvertRem; |
18 | z-index: 10; | 10 | z-index: 10; |
19 | - background: url('../img/thumb-container-bg.png') no-repeat -72rem / $pxConvertRem bottom; | 11 | + background-color: transparent; |
12 | + background-image: url('../img/thumb-container-bg.png'); | ||
13 | + background-repeat: no-repeat; | ||
20 | background-size: 200% 100%; | 14 | background-size: 200% 100%; |
21 | 15 | ||
22 | &.fixed-top { | 16 | &.fixed-top { |
@@ -31,6 +25,7 @@ $pxConvertRem : 40; | @@ -31,6 +25,7 @@ $pxConvertRem : 40; | ||
31 | left: 0; | 25 | left: 0; |
32 | right: 0; | 26 | right: 0; |
33 | bottom: 0; | 27 | bottom: 0; |
28 | + background: #fff; | ||
34 | 29 | ||
35 | .thumb.focus .arrow { | 30 | .thumb.focus .arrow { |
36 | display: none; | 31 | display: none; |
@@ -39,6 +34,8 @@ $pxConvertRem : 40; | @@ -39,6 +34,8 @@ $pxConvertRem : 40; | ||
39 | 34 | ||
40 | &.absolute { | 35 | &.absolute { |
41 | position: absolute; | 36 | position: absolute; |
37 | + left: 0; | ||
38 | + right: 0; | ||
42 | } | 39 | } |
43 | 40 | ||
44 | &.static { | 41 | &.static { |
@@ -49,7 +46,7 @@ $pxConvertRem : 40; | @@ -49,7 +46,7 @@ $pxConvertRem : 40; | ||
49 | display: inline-block; | 46 | display: inline-block; |
50 | position: relative; | 47 | position: relative; |
51 | margin-right: 22rem / $pxConvertRem; | 48 | margin-right: 22rem / $pxConvertRem; |
52 | - padding-bottom: 30rem / $pxConvertRem; /*修改padding-bottom时请修正.container-fixed-pos高度*/ | 49 | + padding-bottom: 30rem / $pxConvertRem; |
53 | 50 | ||
54 | &:last-child { | 51 | &:last-child { |
55 | margin-right: 0; | 52 | margin-right: 0; |
@@ -75,7 +72,7 @@ $pxConvertRem : 40; | @@ -75,7 +72,7 @@ $pxConvertRem : 40; | ||
75 | } | 72 | } |
76 | 73 | ||
77 | .thumb-img { | 74 | .thumb-img { |
78 | - height: 134rem / $pxConvertRem; /*修改height时请修正.container-fixed-pos高度*/ | 75 | + height: 134rem / $pxConvertRem; |
79 | width: 96rem / $pxConvertRem; | 76 | width: 96rem / $pxConvertRem; |
80 | border: 1px solid transparent; | 77 | border: 1px solid transparent; |
81 | } | 78 | } |
@@ -84,7 +81,7 @@ $pxConvertRem : 40; | @@ -84,7 +81,7 @@ $pxConvertRem : 40; | ||
84 | } | 81 | } |
85 | 82 | ||
86 | .prod-list { | 83 | .prod-list { |
87 | - padding-top: 28rem / $pxConvertRem; | 84 | + padding: 28rem / $pxConvertRem 0 0 15rem / $pxConvertRem; |
88 | } | 85 | } |
89 | 86 | ||
90 | .clothe-type { | 87 | .clothe-type { |
1 | {{# collocation}} | 1 | {{# collocation}} |
2 | <div class="article-type-three"> | 2 | <div class="article-type-three"> |
3 | - <div class="container-fixed-pos"> | ||
4 | - <ul class="thumb-container clearfix"> | ||
5 | - {{# list}} | ||
6 | - <li class="thumb"> | ||
7 | - <img class="thumb-img lazy" data-original="{{thumb}}"> | ||
8 | - <span class="clothe-type {{type}}"></span> | ||
9 | - </li> | ||
10 | - {{/ list}} | ||
11 | - </ul> | ||
12 | - </div> | 3 | + <ul class="thumb-container clearfix"> |
4 | + {{# list}} | ||
5 | + <li class="thumb"> | ||
6 | + <img class="thumb-img lazy" data-original="{{thumb}}"> | ||
7 | + <span class="clothe-type {{type}}"></span> | ||
8 | + </li> | ||
9 | + {{/ list}} | ||
10 | + </ul> | ||
13 | <div class="prod-list clearfix"> | 11 | <div class="prod-list clearfix"> |
14 | {{# list}} | 12 | {{# list}} |
15 | <div class="prod hide"> | 13 | <div class="prod hide"> |
-
Please register or login to post a comment