Authored by biao

解决购物车页面弹出时,商品详情页会滚动的问题。 code review by BIKAI.

@@ -67,11 +67,12 @@ function show(html, cb) { @@ -67,11 +67,12 @@ function show(html, cb) {
67 document.documentElement.scrollLeft || document.body.scrollLeft, 67 document.documentElement.scrollLeft || document.body.scrollLeft,
68 document.documentElement.scrollTop || document.body.scrollTop 68 document.documentElement.scrollTop || document.body.scrollTop
69 ], 69 ],
70 - $html = $('html'); // it would make more sense to apply this to body, but IE7 won't have that 70 + $html = $('html, body'); // it would make more sense to apply this to body, but IE7 won't have that
71 71
72 $html.data('scroll-position', scrollPosition); 72 $html.data('scroll-position', scrollPosition);
73 $html.data('previous-overflow', $html.css('overflow')); 73 $html.data('previous-overflow', $html.css('overflow'));
74 $html.css('overflow', 'hidden'); 74 $html.css('overflow', 'hidden');
  75 + $html.css('height', '100%');
75 window.scrollTo(scrollPosition[0], scrollPosition[1]); 76 window.scrollTo(scrollPosition[0], scrollPosition[1]);
76 77
77 if (html) { 78 if (html) {
@@ -89,11 +90,12 @@ function show(html, cb) { @@ -89,11 +90,12 @@ function show(html, cb) {
89 90
90 //隐藏当前Panel 91 //隐藏当前Panel
91 function hide() { 92 function hide() {
92 - var $html = $('html'), 93 + var $html = $('html, body'),
93 scrollPosition = $html.data('scroll-position'); 94 scrollPosition = $html.data('scroll-position');
94 95
95 // un-lock scroll position 96 // un-lock scroll position
96 $html.css('overflow', $html.data('previous-overflow')); 97 $html.css('overflow', $html.data('previous-overflow'));
  98 + $html.css('height', 'auto');
97 window.scrollTo(scrollPosition[0], scrollPosition[1]); 99 window.scrollTo(scrollPosition[0], scrollPosition[1]);
98 $('.chose-panel').hide(); 100 $('.chose-panel').hide();
99 } 101 }