Authored by xuqi

scroll with header

@@ -163,14 +163,21 @@ exports.init = function (flag) { @@ -163,14 +163,21 @@ exports.init = function (flag) {
163 163
164 // 初始化iscroll 164 // 初始化iscroll
165 window.onload = function() { 165 window.onload = function() {
166 - var $scroller = $('#scroller'); 166 + var $scroller = $('#scroller'),
  167 + $yohoHeader = $('.yoho-header');
167 168
168 - var winH, tcH, cbH, cbTop, fixedThumbDom; 169 + var hH = 0,
  170 + winH, tcH, cbH, cbTop, fixedThumbDom;
169 171
170 if (!isIphone || isEzinPage) { 172 if (!isIphone || isEzinPage) {
171 return; 173 return;
172 } 174 }
173 175
  176 + //考虑通用头部的影响:对offset().top以及winH做对应偏移
  177 + if ($yohoHeader.length > 0) {
  178 + hH = $yohoHeader.outerHeight();
  179 + }
  180 +
174 myScroll = new IScroll('#wrapper', { 181 myScroll = new IScroll('#wrapper', {
175 probeType: 3, 182 probeType: 3,
176 mouseWheel: true, 183 mouseWheel: true,
@@ -188,12 +195,12 @@ window.onload = function() { @@ -188,12 +195,12 @@ window.onload = function() {
188 return; 195 return;
189 } 196 }
190 197
191 - winH = $(window).height(); 198 + winH = $(window).height() - hH;
192 fixedThumbDom = $fixedThumbContainer[0]; 199 fixedThumbDom = $fixedThumbContainer[0];
193 200
194 - tcH = $thumbContainer.height();  
195 - cbH = $coBlock.height();  
196 - cbTop = $coBlock.offset().top; 201 + tcH = $thumbContainer.outerHeight();
  202 + cbH = $coBlock.outerHeight();
  203 + cbTop = $coBlock.offset().top - hH;
197 204
198 myScroll.on('scroll', function() { 205 myScroll.on('scroll', function() {
199 var sTop = -this.y; 206 var sTop = -this.y;
@@ -224,7 +231,7 @@ window.onload = function() { @@ -224,7 +231,7 @@ window.onload = function() {
224 .addClass('absolute') 231 .addClass('absolute')
225 .removeClass('fixed-top hide'); 232 .removeClass('fixed-top hide');
226 } 233 }
227 - fixedThumbDom.style.top = cbTop + cbH - tcH - sTop + 'px'; 234 + fixedThumbDom.style.top = cbTop + hH + cbH - tcH - sTop + 'px';
228 } else if (sTop > cbTop + cbH) { 235 } else if (sTop > cbTop + cbH) {
229 if (classList.indexOf('hide') === -1) { 236 if (classList.indexOf('hide') === -1) {
230 $fixedThumbContainer 237 $fixedThumbContainer
@@ -38,6 +38,10 @@ $clothes: sprite-map("guang/clothes/*.png"); @@ -38,6 +38,10 @@ $clothes: sprite-map("guang/clothes/*.png");
38 38
39 &.has-head { 39 &.has-head {
40 top: 90rem / $pxConvertRem; 40 top: 90rem / $pxConvertRem;
  41 +
  42 + + .fixed-top {
  43 + top: 90rem / $pxConvertRem;
  44 + }
41 } 45 }
42 } 46 }
43 47
@@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
6 overflow: hidden; 6 overflow: hidden;
7 height: 90rem / $pxConvertRem; 7 height: 90rem / $pxConvertRem;
8 line-height: 90rem / $pxConvertRem; 8 line-height: 90rem / $pxConvertRem;
  9 + z-index: 1;
9 10
10 &.boys { 11 &.boys {
11 @include background-image(linear-gradient(#323232, #414141)); 12 @include background-image(linear-gradient(#323232, #414141));