Jump to content

Archived

This topic is now archived and is closed to further replies.

Keith Vaugh

Fixed navbar - resize logo on scroll

Recommended Posts

Keith Vaugh

Hi All

I am trying to figure out how I might get the logo in the fixed navi bar to resize when I scroll down the page. 

 

The css I have added is:

.section-navi .pl-nav > li > a {
line-height: 50px;

}
.section-navi img {
max-height: 180px;
}
.section-navi .nav-searchform, .section-navi ul {
font-size: 15px;
}

.section-navi.smaller {
 height: 75px;
}

and I have added this js to the header:

<script>
$(function() {
    $(window).scroll(function() {
        var scroll = $(window).scrollTop();
 
        if (scroll >= 500) {
            $(".section-navi").addClass('smaller');
        } else {
            $(".section-navi").removeClass("smaller");
        }
    });
});
</script>

The site is currently on a local installation only. 

 

I would really appreciate some input or suggestions on how I might be able to achieve this.

Ideally I want to have a larger logo change into a smaller version, similar to response logos found here http://www.responsivelogos.co.uk/

alternatively if this is not achievable, I;d settle for scaling the logo down in size. 

Many thanks.

 

Share this post


Link to post
Share on other sites
Aires

Hi keithmagvacom

 

I tried this a couple months ago using this tutorial but didnt get any results but it may assist you some how

 

http://callmenick.com/2014/02/18/create-an-animated-resizing-header-on-scroll/

 

I even tried again last night using another method on my test site http://mytestdesigns.pw/my-test-navi/

 

you can see my code here I used http://forum.pagelines.com/pst/p/110-ulewkt/  and on both attempts it was like the js was not being applied and i couldnt figure out why the js seemed correct but no results

 

Hope this helps 

 

~Aires


ndTgvai.jpg

Visit iheartpagelines.com for the latest tutorials on PageLines related products.

 

Share this post


Link to post
Share on other sites
Keith Vaugh

Thanks Aires for having a look. I had spotted the callmenick tutorial, along with loads of other ones out there. 

 

It seems that for ever reason, the javascript is not working in any manner. Maybe its a thing that I am picking out the wrong identifiers. I also tried this js:

<script>
    $(window).scroll(function() {
        var scroll = $(window).scrollTop();
 
        if (scroll >= 500) {
          $('.navi-left img').css({'height': '75px'});
        } else {
            $('.navi-left img').css({'height': '180px'});
        }
    });
});
</script>

and also have tried changing .navi-left img with .section-navi img but nothing seems to work. I'd imagine there has to be a way of achieving this using navi.

 

Share this post


Link to post
Share on other sites
Keith Vaugh

I have also tried this js:

<script>
    $(window).scroll(function() {
        var scroll = $(window).scrollTop();
 
        if (scroll >= 500) {
          $('.section-navi img').attr('src', 'http://localhost:8888/magva/wp-content/uploads/2014/10/FB_logo.png');
        } else {
            $('.section-navi img').attr('src', 'http://localhost:8888/magva/wp-content/uploads/2014/10/magva_white.png');
        }
    });
});
</script>

but can't seem to get any affect. 

 

Ideally what I want to achieve, is to change have a large logo when a visitor arrives on the page site, but have it change (to a different logo) when they scroll downwards past a certain point.

NJWpLRj.jpg

Share this post


Link to post
Share on other sites
Keith Vaugh

Not having any luck on this one. It seems that the js doesn't have any effect when its implemented. I have tried a number of different version of the js, but none seems to work.

 

Would really appreciate some input. 

Share this post


Link to post
Share on other sites

  • Similar Content

    • Lisa Haran
      By Lisa Haran+
      Hi 
      I have a map here http://www.iloveoffset.com/maps/
      I want to add several pointer locations to the map, but when I do they do not appear.
      On this map there are 2 pointer locations and as you can there is only one visible.
      Earlier today I added 7 and could only see 4 so there is something odd going on.
      My theme is up to date
    • clj182
      By clj182+
      Hello,
      I've been having trouble unlocking the template section for past couple of weeks. When I try clicking nothing happens. 
      I've deleted my custom css and removed plugins. Im down to having only the following plugins:
      Akismet
      Contact Form 7
      DMS Professional Tools
      Pagelines Updater
      WooCommerce
      It was working fine before i have no idea what's going on with it.
    • flourishdesignstudio
      By flourishdesignstudio+
      My DMS 2 site http://www.heart-stone.com/ will not save any new custom css... I can still edit templates and publish those but any custom css that I enter never saves.
      All WP files, themes, and plugins are up to date. 
      Any thought about what might be causing this?
    • flourishdesignstudio
      By flourishdesignstudio+
      Is there a way to edit the custom CSS via FTP? I know I can edit the custom code in the Chrome editor but is there a file path I can use to find and edit the CSS directly from our FTP?
      Thanks in advance for the help!
    • nizami
      By nizami+
      Using navbar section with correctly configured WP menu to display main navigation at https://elenaangel.com. 
      All fine in desktop viewport. Menu displays twice in hamburger mode. How to fix this please? 

×