code review by hf: merge zhangzhen code to fixes home floor bugs
Showing
4 changed files
with
50 additions
and
1 deletions
@@ -2185,12 +2185,24 @@ var $searchBox = $('.search-box'), | @@ -2185,12 +2185,24 @@ var $searchBox = $('.search-box'), | ||
2185 | $box = $('.box'), | 2185 | $box = $('.box'), |
2186 | $indexSearch = $('.index-search'), | 2186 | $indexSearch = $('.index-search'), |
2187 | $indexLogo = $('.index-logo'), | 2187 | $indexLogo = $('.index-logo'), |
2188 | - $channelLink = $('.index-channel a'); | 2188 | + $channelLink = $('.index-channel a'), |
2189 | + $win = $(window), | ||
2190 | + $doc = $(document), | ||
2191 | + $appFloatLayer = $('#float-layer-app'); | ||
2189 | 2192 | ||
2190 | var $search = $searchBox.children('input[type="text"]'), | 2193 | var $search = $searchBox.children('input[type="text"]'), |
2191 | $cancelSearch = $box.children('.no-search'), | 2194 | $cancelSearch = $box.children('.no-search'), |
2192 | $searchIcon = $searchBox.children('.search-icon'); | 2195 | $searchIcon = $searchBox.children('.search-icon'); |
2193 | 2196 | ||
2197 | +// variables for calculate the app download layer position | ||
2198 | +var layerInit = false, | ||
2199 | + windowViewHeight = 0, | ||
2200 | + layerContentHeight = $appFloatLayer.height(), | ||
2201 | + layerPaddingTop = parseInt($appFloatLayer.css('padding-top')), | ||
2202 | + layerPaddingBottom = parseInt($appFloatLayer.css('padding-bottom')), | ||
2203 | + layerHeight = layerContentHeight + layerPaddingTop + layerPaddingBottom, | ||
2204 | + layerNewPos; | ||
2205 | + | ||
2194 | require("js/common"); | 2206 | require("js/common"); |
2195 | 2207 | ||
2196 | $search.on('focus', function() { | 2208 | $search.on('focus', function() { |
@@ -2245,6 +2257,43 @@ $channelLink.on('touchstart', function() { | @@ -2245,6 +2257,43 @@ $channelLink.on('touchstart', function() { | ||
2245 | }); | 2257 | }); |
2246 | }); | 2258 | }); |
2247 | 2259 | ||
2260 | + | ||
2261 | +function updateLayerPosition() { | ||
2262 | + var winHeight = window.innerHeight, | ||
2263 | + bodyHeight = $doc.height(), | ||
2264 | + scrollTopPosition = $win.scrollTop(); | ||
2265 | + | ||
2266 | + if (layerInit) { | ||
2267 | + | ||
2268 | + //keyboard is shown | ||
2269 | + if (windowViewHeight - winHeight > 200) { | ||
2270 | + if (scrollTopPosition + windowViewHeight + layerHeight >= bodyHeight) { | ||
2271 | + layerNewPos = 0; | ||
2272 | + } else { | ||
2273 | + layerNewPos = bodyHeight - windowViewHeight - scrollTopPosition - layerHeight; | ||
2274 | + } | ||
2275 | + } else { | ||
2276 | + layerNewPos = bodyHeight - winHeight - scrollTopPosition; | ||
2277 | + } | ||
2278 | + | ||
2279 | + } else { | ||
2280 | + windowViewHeight = winHeight; | ||
2281 | + layerNewPos = bodyHeight - winHeight - scrollTopPosition + layerHeight; | ||
2282 | + layerInit = true; | ||
2283 | + } | ||
2284 | + | ||
2285 | + $appFloatLayer.css({ | ||
2286 | + position: 'relative', | ||
2287 | + bottom: layerNewPos + 'px' | ||
2288 | + }); | ||
2289 | +} | ||
2290 | + | ||
2291 | +$(window).scroll(function() { | ||
2292 | + window.requestAnimationFrame(updateLayerPosition); | ||
2293 | +}); | ||
2294 | + | ||
2295 | +$doc.on('ready', updateLayerPosition); | ||
2296 | + | ||
2248 | }); | 2297 | }); |
2249 | define("js/passport/entry", ["jquery"], function(require, exports, module){ | 2298 | define("js/passport/entry", ["jquery"], function(require, exports, module){ |
2250 | /** | 2299 | /** |
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
-
Please register or login to post a comment