assets/js/tim.js
// ajusta o tamanho do mapa internamente no leaflet
ajusta o tamanho do mapa internamente no leaflet
ajusta o tamanho do mapa internamente no leaflet
function adjustHeader() {
            var $mapa, $editableEntity, $busca, $mapa, buscaTop, headerDosResultadosHeight,
                    scrollTop = $(this).scrollTop(),
                    diffScrollTop = (lastScrollTop - scrollTop),
                    newHeaderTop = parseInt($mainHeader.css('top')) + diffScrollTop;
            if ($('#header-search-row').length) {
                $busca = $('#header-search-row');
                $mapa = $('#search-map-container');
                if (!$busca.parent().is($mainHeader)) {
                    $mainHeader.append($('<div id="header-nav-row" class="clearfix">').append($mainHeader.find('>*')));
                    $busca.appendTo($mainHeader);
                }
                headerDosResultadosHeight = $("#search-results-header").outerHeight(true);
                headerHeight = $mainHeader.outerHeight() - headerDosResultadosHeight;
                buscaTop = $mainHeader.outerHeight(true);
                if (buscaTop < 0)
                    buscaTop = 0;
                $('#lista').css('margin-top', headerHeight + headerDosResultadosHeight);
                if ($mapa.is(':visible')) {
                    $busca.addClass('sombra');
                    $mapa.css('top', newHeaderTop + headerHeight + headerDosResultadosHeight);
                    if ($mapa.data('oldHeight') != $mapa.height() && window.leaflet)
                        window.leaflet.map.invalidateSize();
                    if ($('#infobox'))
                        $('#infobox').height($('#search-map-container').height() - 44)
                    $mapa.data('oldHeight', $mapa.height());
                } else if (scrollTop == 0 && !$mapa.is(':visible'))
                    $busca.removeClass('sombra');
                else
                    $busca.addClass('sombra');
                $('body').css('min-height', $(window).height() + headerHeight - headerDosResultadosHeight - 30);
            }
            if (newHeaderTop <= -headerHeight) {
                newHeaderTop = -headerHeight;
            } else if (newHeaderTop >= 0) {
                newHeaderTop = 0;
            } else if (newHeaderTop < -$(window).scrollTop()) {
                newHeaderTop = -$(window).scrollTop();
            }
            if (parseInt($mainHeader.css('top')) <= -headerHeight + 3)
                $mainHeader.removeClass('sombra');
            else
                $mainHeader.addClass('sombra');
            $mainHeader.css('top', newHeaderTop);
            if ($('#editable-entity:visible').length) {
                $editableEntity = $('#editable-entity');
                $editableEntity.css('top', newHeaderTop + headerHeight);
                if ($editableEntity.position().top == 0) {
                    $mainHeader.removeClass('sombra');
                    $editableEntity.addClass('sombra');
                    $('#small-brand').stop().fadeIn(100);
                } else {
                    $editableEntity.removeClass('sombra');
                    $('#small-brand').stop().fadeOut(100);
                }
            }
            lastScrollTop = scrollTop;
        }
function adjustHeader ( ) { var $mapa , $editableEntity , $busca , $mapa , buscaTop , headerDosResultadosHeight , scrollTop = $ ( this ) . scrollTop ( ) , diffScrollTop = ( lastScrollTop - scrollTop ) , newHeaderTop = parseInt ( $mainHeader . css ( 'top' ) ) + diffScrollTop ; if ( $ ( '#header-search-row' ) . length ) { $busca = $ ( '#header-search-row' ) ; $mapa = $ ( '#search-map-container' ) ; if ( ! $busca . parent ( ) . is ( $mainHeader ) ) { $mainHeader . append ( $ ( '<div id="header-nav-row" class="clearfix">' ) . append ( $mainHeader . find ( '>*' ) ) ) ; $busca . appendTo ( $mainHeader ) ; } headerDosResultadosHeight = $ ( "#search-results-header" ) . outerHeight ( true ) ; headerHeight = $mainHeader . outerHeight ( ) - headerDosResultadosHeight ; buscaTop = $mainHeader . outerHeight ( true ) ; if ( buscaTop < 0 ) buscaTop = 0 ; $ ( '#lista' ) . css ( 'margin-top' , headerHeight + headerDosResultadosHeight ) ; if ( $mapa . is ( ':visible' ) ) { $busca . addClass ( 'sombra' ) ; $mapa . css ( 'top' , newHeaderTop + headerHeight + headerDosResultadosHeight ) ; if ( $mapa . data ( 'oldHeight' ) != $mapa . height ( ) && window . leaflet ) window . leaflet . map . invalidateSize ( ) ; if ( $ ( '#infobox' ) ) $ ( '#infobox' ) . height ( $ ( '#search-map-container' ) . height ( ) - 44 ) $mapa . data ( 'oldHeight' , $mapa . height ( ) ) ; } else if ( scrollTop == 0 && ! $mapa . is ( ':visible' ) ) $busca . removeClass ( 'sombra' ) ; else $busca . addClass ( 'sombra' ) ; $ ( 'body' ) . css ( 'min-height' , $ ( window ) . height ( ) + headerHeight - headerDosResultadosHeight - 30 ) ; } if ( newHeaderTop <= - headerHeight ) { newHeaderTop = - headerHeight ; } else if ( newHeaderTop >= 0 ) { newHeaderTop = 0 ; } else if ( newHeaderTop < - $ ( window ) . scrollTop ( ) ) { newHeaderTop = - $ ( window ) . scrollTop ( ) ; } if ( parseInt ( $mainHeader . css ( 'top' ) ) <= - headerHeight + 3 ) $mainHeader . removeClass ( 'sombra' ) ; else $mainHeader . addClass ( 'sombra' ) ; $mainHeader . css ( 'top' , newHeaderTop ) ; if ( $ ( '#editable-entity:visible' ) . length ) { $editableEntity = $ ( '#editable-entity' ) ; $editableEntity . css ( 'top' , newHeaderTop + headerHeight ) ; if ( $editableEntity . position ( ) . top == 0 ) { $mainHeader . removeClass ( 'sombra' ) ; $editableEntity . addClass ( 'sombra' ) ; $ ( '#small-brand' ) . stop ( ) . fadeIn ( 100 ) ; } else { $editableEntity . removeClass ( 'sombra' ) ; $ ( '#small-brand' ) . stop ( ) . fadeOut ( 100 ) ; } } lastScrollTop = scrollTop ; }
ajusta o tamanho do mapa internamente no leaflet
ajusta o tamanho do mapa internamente no leaflet
// @TODO: pra otimizar a performance só calcular e executar a animação se esta ainda não terminou para o sentido do scroll, // exemplo: se está scrollando pra baixo e o header já está oculto não precisa calcular e mover ele //                $busca.css({position: 'fixed', top: buscaTop, zIndex: 123}); //Sugestão de colocar o logo e outras coisas na edit bar: // if scrolltop > x