Scroll animation working only on page load
-
The animation is working only when i load the page with the ‘#’ in the url.
When i click on the menu link ‘CAMERE’, it goes to the section with that id, but not with the animation.
The page I need help with: [log in to see the link]
-
Can you give me access to your site/page to check what happens?
You can also try enabling “Prevent other scripts from handling plugin’s links” option in plugin settings.
You can now access the site.
Ok, go to plugin settings and in the “selectors are excluded” field, change the following value:
a[data-toggle]:not([data-toggle='tooltip'])to:
a[data-toggle]:not([data-toggle='tooltip']):not([data-toggle='dropdown'])Scroll down and enable “Prevent other scripts from handling plugin’s links” option.
Save changes, test and let me know
No, it’s not working
OK. In plugin settings add the following value to the “Prevent other scripts from handling plugin’s links selector(s)” field:
.mobile_menuSave changes and let me know.
If the above doesn’t work you’ll need to manually edit a specific script in your theme which actively prevents the plugin from scrolling the page to the target.
Now it’s working 🙂
But if i try to go on the link from another page it doesn’t work (from the footer menu it works).
This is because the link default behavior is blocked by bootstrap as it’s considered a dropdown. Can you add the following code in your theme/child-theme functions.php?
function ps2id_custom_script(){ wp_register_script( 'ps2id-custom-script', '', array('jquery', '', true ); wp_enqueue_script( 'ps2id-custom-script' ); wp_add_inline_script( 'ps2id-custom-script', '(function($){ $(function(){ $(document).on("click","a.dropdown-toggle.__mPS2id[href*='#']:not([href='#']):not(._mPS2id-h)",function(){ window.location.href=$(this).attr("href"); }); }); })(jQuery);'); } add_action( 'wp_enqueue_scripts', 'ps2id_custom_script' );This should fix the issue. Try it and let me know.
Just added the function on functions.php but it’s not working.
I had to change the function like this:
function ps2id_custom_script(){ wp_register_script( 'ps2id-custom-script', '', array('jquery', '', true )); wp_enqueue_script( 'ps2id-custom-script' ); wp_add_inline_script( 'ps2id-custom-script', '(function($){ $(function(){ $(document).on("click","a.dropdown-toggle.__mPS2id[href*=\'#\']:not([href=\'#\']):not(._mPS2id-h)",function(){ window.location.href=$(this).attr("href"); }); }); })(jQuery);'); } add_action( 'wp_enqueue_scripts', 'ps2id_custom_script' );“)” was missing in the second line.
I had to add “\” before the quotes inside the hrefs.
-
This reply was modified 2 years, 4 months ago by
bigh3ad.
Ah yes, the typo was my bad.
It works now when I test it, correct?
Ah there’s a mistake in the code when you added the “)”. Change it to:
function ps2id_custom_script(){ wp_register_script( 'ps2id-custom-script', '', array('jquery'), '', true ); wp_enqueue_script( 'ps2id-custom-script' ); wp_add_inline_script( 'ps2id-custom-script', '(function($){ $(function(){ $(document).on("click","a.dropdown-toggle.__mPS2id[href*=\'#\']:not([href=\'#\']):not(._mPS2id-h)",function(){ window.location.href=$(this).attr("href"); }); }); })(jQuery);'); } add_action( 'wp_enqueue_scripts', 'ps2id_custom_script' );Now it’s working, thank you 🙂
You’re welcome 🙂
Marking this as resolved but let me know if you need more help.
-
This reply was modified 2 years, 4 months ago by
The topic ‘Scroll animation working only on page load’ is closed to new replies.