Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #1404057

    Hello,

    Any link to an accordion’s tab scrolls the page so that the tab title becomes invisible. I use custom tab and toggle ID’s, but with the default ones it was the same. Please click the first “Comparing WPML” link on the page from the private content to see the issue.

    Regards,
    Marina

    #1404297

    Hey Marina,
    Thanks for your patience and the link to your site, Try adding this code to the end of your child theme functions.php file in Appearance ▸ Editor:

    function anchor_offset_with_slow_scroll() { ?>
      <script>
    (function($) {
      $('a[href*=#]:not([href=#])').click(function() {
        if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') 
    && location.hostname == this.hostname) {
    
          var target = $(this.hash);
          target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
          if (target.length) {
            $('html,body').animate({
              scrollTop: target.offset().top - 100 //offsets for fixed header
            }, 1000);
            return false;
          }
        }
      });
    }(jQuery));
    </script>
      <?php
    }
    add_action('wp_footer', 'anchor_offset_with_slow_scroll');

    Please ensure to copy the code from the forum and not an email notification so the symbols are not converted.

    Best regards,
    Mike

    #1404376

    Hi Mike,

    Thank you for the code, it works. There is only one issue: it added an offset for all the anchors. Is it possible to apply the offset only for links to accordion toggles?

    Regards,
    Marina

    #1404417

    Hi,
    You will need to add a custom class to the links to your accordion toggles or we could have it work only on certain pages.

    Best regards,
    Mike

    #1404419

    Hi Mike,

    I would prefer to use a custom class. Something like the following will do?

    <a href="#wps-hide-login" class="link-to-accordion">WPS Hide Login</a>

    Regards,
    Marina

    #1404424

    Hi,
    If you are using the custom class link-to-accordion then this should work:

    function anchor_offset_with_slow_scroll() { ?>
      <script>
    (function($) {
      $('a.link-to-accordion[href*=#]:not([href=#])').click(function() {
        if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') 
    && location.hostname == this.hostname) {
    
          var target = $(this.hash);
          target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
          if (target.length) {
            $('html,body').animate({
              scrollTop: target.offset().top - 100 //offsets for fixed header
            }, 1000);
            return false;
          }
        }
      });
    }(jQuery));
    </script>
      <?php
    }
    add_action('wp_footer', 'anchor_offset_with_slow_scroll');

    If not then please add the class to the test link Comparing WPML

    Best regards,
    Mike

    #1404711

    Hi Mike,

    Thank you for your help, now everything works perfectly.

    Could you please have a look at one issue as well? The two buttons on the page in private content display images in a lightbox, however, sometimes the title there is “null”. It is quite difficult to reproduce the issue. Is it possible to impose manually a title for each lightbox? There are four such lightboxes: two in English version and two in the Russian one.

    Thank you,
    Marina

    #1404733

    Hi,
    Thanks for the feedback, I checked the button “sitemap example” and while the title in the lightbox showed in my tests, I do see that you are using a script to remove the title on hover, probably for images or another element and it needs to be adjusted to exclude these buttons.
    Please include an admin login and explain what titles need to be removed with the script.
    Please also explain how to see the null error for the button lightbox, is in a certain browser or clicking back and forth between the buttons?

    Best regards,
    Mike

    #1404756

    Hi Mike,

    To reproduce the error, open the site in the private mode, navigate to the Workflow page and click any of two buttons: if you do not get the “null”, open in a private mode again, after a couple of attempts (I normally need 3 or 4) it should reproduce.

    I actually want that there are no titles on hover on these buttons, but it seems to sometimes remove the linked lightbox title as well. So the script should remove the title on hover for: images, text links, and buttons (normal and fullwidth).

    Best regards,
    Marina

    • This reply was modified 1 year, 7 months ago by Marina.
    #1404825

    Hi,
    Thanks for the login, I’m not seeing a link in the button, how is the link to the image added?
    The image needs to have a title for it to show in the lightbox, the script adds the title back on click so it will show in the lightbox, but it seems that once in a while the lightbox is faster than the script. I have a hard time reproducing, like you said, we need to try 3 or 4 times, it’s hard to correct an issue that doesn’t occur all of the time.

    Best regards,
    Mike

    #1404950

    Hi Mike,

    Trying to fix the issue, I edited the button code in the debug mode, now everything is back as it should be. The problem is that the lightbox takes the Button Title Attribute, and does not display the image title at all. Please have a look at the third button I added, it has an empty Button Title Attribute, but the image has a title. Maybe this can help?

    Best regards,
    Marina

    #1404975

    Hi,
    Glad to hear that you have this sorted out, I was mistaken about which title was used, unless there is anything else we can assist with on this issue, shall we close this then?

    Best regards,
    Mike

    #1405028

    Hi Mike,

    Sorry, you did not understand me correctly, the issue is still there. I meant that the links are added to the buttons again normally. With respect to the issue: is it possible to make the respective lightboxes take the title from the image and not from the button? If not, thank you again for your help, and you can close the ticket.

    Best regards,
    Marina

    #1405061

    Hi,
    Unfortunately not in this case because the image title is not used in the button element, only a link to the image.

    Best regards,
    Mike

    #1405209

    Hi Mike,

    Thank you for your help anyway, you can close the ticket.

    Best regards,
    Marina

Viewing 15 posts - 1 through 15 (of 15 total)
  • The topic ‘Link to an accordion’s tab scrolls too much down and hides the tab’s title’ is closed to new replies.