Commit 3595cd44ba69c02ae4cd096210d82df438492053
1 parent
f561d73e
Exists in
master
and in
7 other branches
Pequenas melhorias no scroll #217
Showing
1 changed file
with
20 additions
and
10 deletions
Show diff stats
js/main.js
@@ -301,6 +301,9 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | @@ -301,6 +301,9 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | ||
301 | }, | 301 | }, |
302 | navigateTo: function(hash){ | 302 | navigateTo: function(hash){ |
303 | var scrollTop = 0; | 303 | var scrollTop = 0; |
304 | + var $nav = $('nav[role="tabpanel"]'); | ||
305 | + var navOffset = $nav.offset(); | ||
306 | + | ||
304 | var regexProposals = /#\/programas/; | 307 | var regexProposals = /#\/programas/; |
305 | var regexCategory = /#\/temas/; | 308 | var regexCategory = /#\/temas/; |
306 | var regexHideBarra = /barra=false$/; | 309 | var regexHideBarra = /barra=false$/; |
@@ -326,9 +329,13 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | @@ -326,9 +329,13 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | ||
326 | this.navigateToProposal(proposalId); | 329 | this.navigateToProposal(proposalId); |
327 | 330 | ||
328 | var $proposal = $('#proposal-item-' + proposalId); | 331 | var $proposal = $('#proposal-item-' + proposalId); |
329 | - var offset = $proposal.offset(); | ||
330 | - if(offset){ | ||
331 | - scrollTop = offset.top; | 332 | + var proposalOffset = $proposal.offset(); |
333 | + if(proposalOffset){ | ||
334 | + scrollTop = proposalOffset.top; | ||
335 | + }else{ | ||
336 | + if(navOffset){ | ||
337 | + scrollTop = navOffset.top; | ||
338 | + } | ||
332 | } | 339 | } |
333 | } | 340 | } |
334 | 341 | ||
@@ -339,9 +346,13 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | @@ -339,9 +346,13 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | ||
339 | this.navigateToCategory(categoryId); | 346 | this.navigateToCategory(categoryId); |
340 | 347 | ||
341 | var $category = $('#proposal-item-' + categoryId); | 348 | var $category = $('#proposal-item-' + categoryId); |
342 | - var offset = $category.offset(); | ||
343 | - if(offset){ | ||
344 | - scrollTop = offset.top; | 349 | + var categoryOffset = $category.offset(); |
350 | + if(categoryOffset){ | ||
351 | + scrollTop = categoryOffset.top; | ||
352 | + }else{ | ||
353 | + if(navOffset){ | ||
354 | + scrollTop = navOffset.top; | ||
355 | + } | ||
345 | } | 356 | } |
346 | } | 357 | } |
347 | 358 | ||
@@ -350,10 +361,9 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | @@ -350,10 +361,9 @@ define(['handlebars', 'fastclick', 'handlebars_helpers'], function(Handlebars, F | ||
350 | // show the 'index' -> category tab | 361 | // show the 'index' -> category tab |
351 | this.display_category_tab(); | 362 | this.display_category_tab(); |
352 | 363 | ||
353 | - var $nav = $('nav[role="tabpanel"]'); | ||
354 | - var offset = $nav.offset(); | ||
355 | - if(offset){ | ||
356 | - scrollTop = offset.top; | 364 | + |
365 | + if(navOffset){ | ||
366 | + scrollTop = navOffset.top; | ||
357 | } | 367 | } |
358 | } | 368 | } |
359 | 369 |