Authored by xuqi

滑动过快时状态切换不及的bug

@@ -85,36 +85,34 @@ exports.init = function() { @@ -85,36 +85,34 @@ exports.init = function() {
85 containerH = container.height(); //article-type-three高度 85 containerH = container.height(); //article-type-three高度
86 containerTop = container.offset().top; //article-type-three offset top 86 containerTop = container.offset().top; //article-type-three offset top
87 87
  88 + function resetStatus() {
  89 + thumbContainer.removeClass('static fixed-top fixed-bottom absolute').css('top', '');
  90 + prodList.css('margin-top', '');
  91 + }
  92 +
88 //scroll时控制列表的位置 93 //scroll时控制列表的位置
89 $(document).scroll(function() { 94 $(document).scroll(function() {
90 var sTop = $(this).scrollTop(); 95 var sTop = $(this).scrollTop();
91 - 96 + resetStatus();
92 //Tip: removeClass只用移除相邻状态即可 97 //Tip: removeClass只用移除相邻状态即可
93 if (sTop <= containerTop - wH + tContainerH) { 98 if (sTop <= containerTop - wH + tContainerH) {
94 thumbContainer 99 thumbContainer
95 - .addClass('fixed-bottom')  
96 - .removeClass('static'); 100 + .addClass('fixed-bottom');
97 prodList.css({ 101 prodList.css({
98 'margin-top': tContainerH 102 'margin-top': tContainerH
99 }); 103 });
100 } else if (sTop <= containerTop) { 104 } else if (sTop <= containerTop) {
101 thumbContainer 105 thumbContainer
102 - .addClass('static')  
103 - .removeClass('fixed-bottom fixed-top')  
104 - .css('top' , '');  
105 - prodList.removeAttr('style') 106 + .addClass('static');
106 } else if (sTop <= containerTop + containerH - tContainerH) { 107 } else if (sTop <= containerTop + containerH - tContainerH) {
107 thumbContainer 108 thumbContainer
108 - .addClass('fixed-top')  
109 - .removeClass('static absolute')  
110 - .css('top' , ''); 109 + .addClass('fixed-top');
111 prodList.css({ 110 prodList.css({
112 'margin-top': tContainerH 111 'margin-top': tContainerH
113 }); 112 });
114 } else if (sTop <= containerTop + containerH) { 113 } else if (sTop <= containerTop + containerH) {
115 thumbContainer 114 thumbContainer
116 .addClass('absolute') 115 .addClass('absolute')
117 - .removeClass('static fixed-top')  
118 .css({ 116 .css({
119 top: containerTop + containerH - tContainerH 117 top: containerTop + containerH - tContainerH
120 }); 118 });
@@ -123,10 +121,7 @@ exports.init = function() { @@ -123,10 +121,7 @@ exports.init = function() {
123 }); 121 });
124 } else if (sTop > containerTop + containerH) { 122 } else if (sTop > containerTop + containerH) {
125 thumbContainer 123 thumbContainer
126 - .addClass('static')  
127 - .removeClass('absolute')  
128 - .css('top' , '');  
129 - prodList.removeAttr('style'); 124 + .addClass('static');
130 } 125 }
131 }); 126 });
132 127