Responsive WordPress Theme – Caliber

A theme with simple controls and limitless potential. Work fast and build an amazing website!   Find out more »

UpThemes – Beautiful WordPress Themes

Create a site your church, gallery, newspaper, blog, recipes, band and more!   See the themes »

Need a little help?  Find answers quickly by searching the forum.
Group Admins
  • jeffw
  • ljungi
  • maxleondalheimer
  • admin
Group Mods
  • malekovitch

Support for: Vellum – Responsive WordPress Theme

Vellum

Public Group  |  active 1 month ago ago
Viewing post 1 to 15 (19 total posts)

Call to action button smooth scroll to anchor link on same page?

  • blu42

    said

    I’m using a onepage layout where the menu links all scroll smoothly to the designated sections. How do I get the same smooth scrolling action for a link in a Call to Action design element? Right now the link just jumps to the section instead of scrolling. Thanks.

  • andy

    said

    If you give any link the class “local” it will do the scroll animation.

  • freshmarketing

    said

    I’m also doing a one page layout with a top navigation menu. Is there any way I can make my menu items change to an active state color? Right now, the Welcome (home) page button stays active no matter where you are on the page.

  • jeffw

    said

    Hi, freshmarketing.

    I’m not sure there is anything you can do about that. WordPress assigns unique classes to the current menu item (current-menu-item) and the current page item (current_page_item) but because a one-page site is all the same URL (so all the menu items are essentially the same link) then there doesn’t appear to be any CSS way in a menu to highlight which particular anchor on that one page is currently being looked at.

    I think this would be have to be done with JavaScript and it is something @andy might want to add to his big yellow notebook.

  • freshmarketing

    said

    Thanks Jeffw. I first tried building my scrolling “page” actually using different pages by adding those pages to my Home Page Layout in the Layout Manager, but that method seemed to break the smooth scroll. When you clicked a menu item it would refresh the entire page rather than smooth scrolling down to the section. I noticed the Vellum demo used anchor links instead of the layout manager, so I back tracked and went that route. But the active state issue is not going to pass with my client. So any ideas other than purchasing another OnePage theme that does it? (I’d rather not do that).

  • andy

    said

    @freshmarketing

    For the current “home” link showing the active state, the best solution to that would be to change the setting in the “Appearance > Theme Options > Fonts” for your main menu “active” color to be the same as the menu color. If you set the color this way it will ensure that a link to the current page isn’t getting a different color.

    We don’t use a link to the current page as the “home” link in the demo, instead we apply a scroll to top function by making a link with the URL “#ScrollTop” which will apply a special function to go to the top of the page. That’s a pretty normal thing for a one-page design to do.

    Right now the theme doesn’t apply any custom colors or scroll state markings to the menu items as the page scrolls. This is something that will require custom JavaScript to achieve and it’s on our list of future updates. Right now you might be able to add this yourself to the theme if it’s a requirement for your project. There are a lot of resources and tutorials out there with example JavaScript functions that achieve this result.

    When I searched the topic (https://www.google.com/search?q=highlight+link+on+scroll) I found a few resources that can probably be adapted easily for a WordPress menu:

    http://stackoverflow.com/questions/2896869/jquery-changing-css-on-navigation-when-div-scrolls-into-view/2898109#2898109

    This is adapted from the code on that page to apply to the WP menu structure, but it gets the process started. You can add this into the Custom JavaScript area of the Theme Options

    var topRange   = 200,  // measure from the top of the viewport to X pixels down
        edgeMargin = 20,   // margin above the top or margin from the end of the page
        contentTop = [];
     
    jQuery(document).ready(function($){ 
      // Set up content an array of locations
      $('#MainNav li.menu-item.ss-nav-menu-item-depth-0').find('a').each(function(){
        contentTop.push( $( $(this).attr('href') ).offset().top );
      });
     
      // adjust side menu
      $(window).scroll(function(){
        var winTop = $(window).scrollTop(),
            bodyHt = $(document).height(),
            vpHt   = $(window).height() + edgeMargin;  // viewport height + margin
        
        $.each( contentTop, function(i,loc){
          if ( ( loc > winTop - edgeMargin && ( loc < winTop + topRange || ( winTop + vpHt ) >= bodyHt ) ) ){
            $('#MainNav li.menu-item.ss-nav-menu-item-depth-0')
              .removeClass('selected')
              .eq(i).addClass('selected');
          }
        });
      });
    });

    With that code included it will apply the class “selected” to each of the menu <li> items. That will give you the ability to set your own custom styling for the selected state of the element, maybe by entering something like this into the Custom CSS area:

    #MainNav li.menu-item.ss-nav-menu-item-depth-0.selected { color: #d00 !important; }

    We will likely add something like this into the theme in the future to make it a default feature. We developed the theme not as a one-page theme first, but a fully functional theme that’s capable of one-page designs. The updates and additions of small enhancements like this will be a continuous thing intended to expand on all the different ways the theme can be used.

  • freshmarketing

    said

    Andy, thanks. I really appreciate the quick response time and look forward to the update. I hope to use your theme for future clients too.

  • jeffw

    said

    @andy I’ve started a ticket for this so that it doesn’t get forgotten.

  • tommynerd

    said

    Hi guys,

    I’d like to have the smooth scrolling effect for a button of an “Icon Box” I’m using, but unfortunately there is no “extra class” field where I could put “local”. I tried to add el_class=”local” to the short code as it is done for the Call to action buttons, but no luck.

    Cheers

  • jeffw

    said

    You can add the icon box as HTML and then you can set a class for the button’s anchor tag. For example…

    <div class="iconBox icon">
      <i class="fa fa-plus"></i>
      <div class="textContent">
        <h2 class="iconBoxTitle">My title</h2>
        <div class="theText">My text.</div>
        <a class="btn small local" href="#section_one">My button</a>
      </div>
    </div>

    Add that HTML to a Raw HTML element and adapt it to suit your needs.

  • mgamboa1517

    said

    @jeffw, do you have any idea if/when the Active Menu item enhancement may appear in an update? We’ve been trying to work around this for a while now, hoping you have some news that it will be rolled into an update soon.

  • jeffw

    said

    It’s something that’s on the ideas list but I don’t think it’s even made it to the ToDo list yet. I’ll check with Andy.

  • jeffw

    said

    I have no idea at all whether your problems are being caused by a JavaScript error. If you suspect a JavaScript error then open your browser’s JavaScript console to see if there is an error message there.

    Unfortunately we can’t support this custom JavaScript as part of theme support. It is provided “as-is” and if you can’t get it to work then you are on your own. Sorry to be so blunt, tact and diplomacy is not my strong suit. :D

Viewing post 1 to 15 (19 total posts)
Topic tags: button, call to action, one page, smooth scrolling