Tagged: ,

Viewing 21 posts - 1 through 21 (of 21 total)
  • Author
    Posts
  • #698946

    I have set my header not to resize, and now when I go to an internal link (#my_anchor) it jumps too far and the anchor position is under the header.

    #698992

    Hey lunatrix,

    Please try adding this at the very end of your themes / child themes functions.php file:

    // Scroll to div
    function scrollToDiv(){
    ?>
    <script>
         jQuery(document).scroll(function() {
         var sections = jQuery('.avia-section'),
            menu   = jQuery('a[href^="#"]');
         	menu.on('click', function(event) {
        		var target = jQuery(this.getAttribute('href'));
        		if( target.length ) {
            		event.preventDefault();
            			jQuery('html, body').stop().animate({
                			scrollTop: target.offset().top - 200
            			}, 1000);
        			}
    			});
    		});
     
    </script>
    <?php
    }
    add_action('wp_head', 'scrollToDiv');

    If yous till have any issues Please post us your login credentials (in the “private data” field), so we can take a look at your backend.

    Login credentials include:

    • The URL to the login screen.
    • A valid username (with full administration capabilities).
    • As well as a password for that username.
    • permission to deactivate plugins if necessary.

    Best regards,
    Vinay

    #699252

    Hi. It didn’t work. Well, sort of – it works if I am on the page where the internal links are, but doesn’t work if I link to an anchor from a different page. Weird!

    • This reply was modified 7 years, 9 months ago by lunatrix.
    #700360

    Bump

    #700787

    Hi,

    I tried to troubleshoot this issue but the login credentials you provided do not work for me. Would you mind checking once again and then send us working login credentials?

    The user role for the account you send us should be set to ‘administrator’ so we can try to disable all plugins and add custom code (if necessary) to resolve the issue.

    In the code provided earlier please replace the below line

    
       menu   = jQuery('a[href^="#"]');

    with

    
       menu   = jQuery('a'); 

    Best regards,
    Vinay

    #700800

    Hi Vinay,

    Sorry, that was my mistake… I spelled kriesi wrong :-/

    I tried changing the bit of code you suggested, and that didn’t fix the issue. I have fixed the login, and unlocked your IP range, so you should be good to log in and poke around.

    Thanks,
    Nancy

    #702154

    Hi,

    The code is working as intended but the browser will not re-direct the users to the page because of the menu path. In this case you need to use 2 different menu and add the one with just the #ID to homepage and the menu with relative path to the inner pages.

    Please use a plugin like
    https://wordpress.org/plugins/page-specific-menu-items/
    https://wordpress.org/plugins/menu-items-visibility-control/

    Best regards,
    Vinay

    • This reply was modified 7 years, 9 months ago by Vinay.
    #702667

    Hi Vinay,

    I am not having issues with the menu/redirecting…

    When I add an anchor for an internal link, such as, /#captcha, it will jump to the correct page, but the text is at the top of the browser (not the container) so the relevant text is UNDER the top header bar.

    • This reply was modified 7 years, 9 months ago by lunatrix.
    #703636

    Hi,

    We have updated the scroll offset value to 150 in functions.php file and it scrolls to the right place now please review the page or check the attached screenshot.

    Best regards,
    Vinay

    • This reply was modified 7 years, 9 months ago by Vinay.
    #704096

    Hey Vinay,

    Yep, the letters have always been working correctly (from within the document). It’s when using a URL with a #, such as:

    https://workathome24x7.com/glossary-of-internet-marketing-terms/#captcha

    Then the anchored text – in this case “captcha” – is underneath the titlebar.

    • This reply was modified 7 years, 9 months ago by lunatrix.
    #705818

    Hi,

    The captcha also appears correctly on my end however you can still modify the scrolled location by changing the value 200 to 250 or more in the line

    scrollTop: target.offset().top - 200

    Let us know if you have any further questions.

    Best regards,
    Vinay

    #1016987

    Hi Vinay, I’m having a similar problem.
    The code that you suggested solved the in-page scrolling problem that now it is perfect.
    When i try to open a link to anchor from the outside i have the same issue:
    For example.
    If i try to open the link https://changeinvestments.it/blockchain/#blockchain the title “2. COS’È LA BLOCKCHAIN” is hided under the submenu.
    If i am already in the page and i use the submenu that take me to the same anchor i don’t have the issue.
    Do you have any suggestions?

    Ps. The div tag is inside the title, with the text.

    Thank you for the support!

    #1017663

    Hi,

    Is it working properly when you disable the columns’ animation?

    Best regards,
    Ismael

    #1284063

    The Script from Vinay works for me:

    function scrollToDiv(){
    ?>
    <script>
         jQuery(document).scroll(function() {
         var sections = jQuery('.avia-section'),
            menu   = jQuery('a[href^="#"]');
         	menu.on('click', function(event) {
        		var target = jQuery(this.getAttribute('href'));
        		if( target.length ) {
            		event.preventDefault();
            			jQuery('html, body').stop().animate({
                			scrollTop: target.offset().top - 200
            			}, 1000);
        			}
    			});
    		});
    </script>
    <?php
    }
    add_action('wp_head', 'scrollToDiv');

    … but the anchor link will not show in the URL – not like this http://www.mysite#anchor

    This function doesn’t work at all:

    add_filter('avf_header_setting_filter', 'avf_header_setting_filter_mod', 9999, 1);
    function avf_header_setting_filter_mod($header) {
    	$header['header_scroll_offset'] = $header['header_scroll_offset'] + 100;
    	return $header;
    }

    Can you give us a working script that leaves the anchor in the url?

    #1284414

    Hi,

    Try to replace the script with the following to append the hash or the anchor to the URL.

    function scrollToDiv(){
    ?>
    <script>
         jQuery(document).scroll(function() {
         var sections = jQuery('.avia-section'),
            menu   = jQuery('a[href^="#"]');
         	menu.on('click', function(event) {
        		var target = jQuery(this.getAttribute('href'));
        		if( target.length ) {
            		event.preventDefault();
            			jQuery('html, body').stop().animate({
                			scrollTop: target.offset().top - 200
            			}, 1000);
        			}
                            window.location.hash = this.getAttribute('href');
    			});
    		});
    </script>
    <?php
    }
    add_action('wp_head', 'scrollToDiv');
    

    Best regards,
    Ismael

    #1284737

    His Ismael,
    your new function append the hash to the URL – thanks! One more problem with this function: It´s not responsive. On smaller screens it will jump to false position.

    #1287312

    Hi frankeee,

    I’m sorry for the late reply. You could try to add a different version of the script for mobile, like so:

    function scrollToDiv(){
    	if(wp_is_mobile()) {
    ?>
    <script>
         jQuery(document).scroll(function() {
         var sections = jQuery('.avia-section'),
            menu   = jQuery('a[href^="#"]');
         	menu.on('click', function(event) {
        		var target = jQuery(this.getAttribute('href'));
        		if( target.length ) {
            		event.preventDefault();
            			jQuery('html, body').stop().animate({
                			scrollTop: target.offset().top - 200
            			}, 1000);
        			}
                            window.location.hash = this.getAttribute('href');
    			});
    		});
    </script>
    <?php
    }
    	else {
    		?>
    		<script>
    		     jQuery(document).scroll(function() {
    		     var sections = jQuery('.avia-section'),
    		        menu   = jQuery('a[href^="#"]');
    		     	menu.on('click', function(event) {
    		    		var target = jQuery(this.getAttribute('href'));
    		    		if( target.length ) {
    		        		event.preventDefault();
    		        			jQuery('html, body').stop().animate({
    		            			scrollTop: target.offset().top - 200
    		        			}, 1000);
    		    			}
    		                        window.location.hash = this.getAttribute('href');
    					});
    				});
    		</script>
    		<?php
    	}
    }
    add_action('wp_head', 'scrollToDiv');

    Adjust the 200 value on this line in the first block, to your liking:

    scrollTop: target.offset().top - 200

    Best regards,
    Rikard

    #1287415

    .. thanks Rikard but your extension has no effect. On smaller screens <768px the position is the failure – no matter how I adjust the values.

    #1288486

    Hey,

    Could you please try changing the code to following one and adjust “300” as needed?

    function scrollToDiv(){
    ?>
    <script>
         jQuery(document).scroll(function() {
         var sections = jQuery('.avia-section'),
            menu   = jQuery('a[href^="#"]');
         	menu.on('click', function(event) {
        		var target = jQuery(this.getAttribute('href'));
        		if( target.length ) {
            		event.preventDefault();
                        if($(window).width() >= 769){
            			     jQuery('html, body').stop().animate({
                		      	scrollTop: target.offset().top - 200
            			     }, 1000);
                        }
                        else{
                             jQuery('html, body').stop().animate({
                                scrollTop: target.offset().top - 300
                             }, 1000);
                        }
        			}
                            window.location.hash = this.getAttribute('href');
    			});
    		});
    </script>
    <?php
    }
    add_action('wp_head', 'scrollToDiv');

    Regards,
    Yigit

    #1288539

    sorry, this is also not working. Thank you anyway for your efforts.

    #1288581

    Hey @frankeee,

    Could you please start a new thread under Enfold sub forum, attach temporary admin logins in private content field, reference this thread and point out how we can reproduce the issue? I think it will make it easier for us to provide you an accurate solution :)

    Regards,
    Yigit

Viewing 21 posts - 1 through 21 (of 21 total)
  • You must be logged in to reply to this topic.