• Resolved katastr0phal

    (@katastr0phal)


    Hi there,

    I am trying to get your Plugin to work with a Child Theme based on OceanWP.

    However, there is some JavaScript (I guess from the Theme) which interferes with the Plugin, but I just don’t know how to Debug this phenomen.

    When I open https://michaela.mschoder.at/programs#kids the smooth scroll down to the kids section works as expected (+88 px offset which i defined in the plugin settings).
    But when I then select “Aktuelles Angebot” >> “Kinderyoga” from the header it just ignores the offset for my sticky header.
    Doing this in firefox and edge shows that it scrolls to the offset (from the plugin) and then back down ignoring the offset (by some other JavaScript?).

    Do you happen to know in which JS file and what I need to alter to disable any OceanWP smooth scrolling behaviour?

    Let me know if I was unclear or if you miss any additional info.

    Thank you very much!

    • This topic was modified 3 years, 9 months ago by katastr0phal.

    The page I need help with: [log in to see the link]

Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author malihu

    (@malihu)

    Hello,

    I think the js comes from Elementor smooth scrolling feature. Can you add some javascript in your theme/child-theme template? If yes, try this:

    Add the following code in your theme/child-theme footer.php template, right above the closing body tag (</body>):

    <script>
    (function($){
        $(window).on("elementor/frontend/init",function(){
            if(typeof elementorFrontend==='undefined') return;
            elementorFrontend.on("components:init",function(){
                elementorFrontend.utils.anchors.setSettings("selectors.targets",".dummy-selector");
            });
        });
    })(jQuery);
    </script>

    Save, test and let me know if it worked.

    • This reply was modified 3 years, 9 months ago by malihu.
    Thread Starter katastr0phal

    (@katastr0phal)

    Thank you very much. It works now as expected!!!! ๐Ÿ™‚

    Furthermore, how would you go about embedding this in my child-theme so it doesn’t get overriden on any update?

    Plugin Author malihu

    (@malihu)

    You’re welcome ๐Ÿ™‚

    The quickest way is to copy the footer.php template from your theme to your child-theme and apply the script there (in the cloned footer.php in your child-theme dir).

    Otherwise you could use the wp_add_inline_script in your child-theme functions.php to add the script via wp_enqueue_scripts.

    I’m marking this as resolved but let me know if you need more help.

    Thread Starter katastr0phal

    (@katastr0phal)

    I am sorry to bother you again, but it stopped working (or I was falsely reporting that it worked before due to some cached content).

    When inspecting the site I can see the script within the footer but it seems not to fix the problem.

    Plugin Author malihu

    (@malihu)

    No problem.

    Leave the script as it is, as it disables the Elementor smooth scrolling.

    There’s another script in your oceanwp theme that seems to has its own scrolling function and prevents “Page scroll to id” from doing its thing. The script is this one:

    ...themes/oceanwp/assets/js/scroll-effect.min.js

    Do this:

    1)Firstly, you need to change your links URL to have the trailing slash before the hash. For example, change your “Kinderyoga” link URL from:

    https://michaela.mschoder.at/programs#kids

    to:

    https://michaela.mschoder.at/programs/#kids

    Otherwise your page will be reloaded each time you click the link (your server redirects all requests to the ones with the trailing slash). Do this for all your links.

    2)Search within the OceanWP theme settings for an option to disable its smooth scrolling feature/effect. If there is such option, disable it and test your links to see if everything works.

    If there’s no such option or it doesn’t have the effect we want, edit your menu in wp admin and add the following class to each one of your menu items:

    opl-link

    Save the menu and test your links. Smooth scrolling should work.

    Let me know ๐Ÿ™‚

    Thread Starter katastr0phal

    (@katastr0phal)

    Hey,

    i did as you said and it seems to have done the trick.
    The current version of OceanWP doesn’t have an option to disable their smooth scrolling script, but adding opl-link as CSS Class worked.

    Mind elaborating, where this class comes from?

    Anyways, thank you very very much! I spent hours on this problem :X

    Plugin Author malihu

    (@malihu)

    You’re welcome.

    When I checked the OceanWP smooth scrolling function in scroll-effect.min.js, I saw that it checks for the opl-link class (among others) and if it’s present on the link item, the script does not apply its smooth scrolling effect (for that link item).

    That’s it. We just used the class that bypasses the smooth scrolling in the OceanWP script ๐Ÿ˜‰

    I had a similar issue to what is described here. Took me a while to figure out theย oceanwp-scroll-effect* JavaScript (.js) ย (/wp-content/themes/oceanwp/assets/js/scroll-effect.min.js) was preventing the Plugin:ย Page scroll to id from working properly on my main page even with the Advanced optionย “Prevent other scripts from handling pluginโ€™s links (if possible)” enabled. Scrolling from different pages worked fine.

    I was successful disabling the oceanwp-scroll-effect with the plugin “Asset CleanUp”. Now it works perfectly. Maybe that will help others as well.

    Thanks a lot for the great plugin malihu!

    Plugin Author malihu

    (@malihu)

    @hpclt Thanks a lot for the solution and feedback ๐Ÿ™‚

    I have to reopen this thread again. Both @katastr0phal as my own site ( https://zwxnge.de/ ) work great in desktop mode. However, once you reach the mobile breakpoint which changes the header menu to the mobile dropdown menu style, P2SID does not work for the menu links anymore. Since both methods in this thread overwrite the included oceanwp scroll animation, there is now no animation for these mobile dropdown menu links at all. They’re now just instant.

    P2SID generally works on my site even at mobile and tablet breakpoints (see the blue “Hier Klicken” Button under “Allgemeine Objektbeschreibung” on my site)

    I suspect it’s caused by another oceanwp script, maybe “drop-down-mobile-menu.min.js” but that’s way past my skill level. @malihu could you please take another look at this?

    Thanks in advance!

    Plugin Author malihu

    (@malihu)

    @hpclt Indeed drop-down-mobile-menu.min.js causes the issue.

    The only way to solve this is with some extra javascript. Add the script below in your theme/template:

    <script>
    (function($){
    	$(window).on("load",function(){
    		$("#mobile-dropdown li.current-menu-item a.__mPS2id[href*='#']:not([href='#'])").each(function(){
    			var $this=$(this),
    				_hash=$this.attr("href").split("#")[1];
    			$this.attr("href","#");
    			$this.attr("data-ps2id-href","#"+_hash);
    		}).on("click",function(e){
    			e.preventDefault();
    			$.mPageScroll2id("scrollTo",$(this).attr("data-ps2id-href"));
    		});
    	});
    })(jQuery);
    </script>

    Test it and let me know. It should work.

    Awesome! I added the script at the end of my footer.php just before </body> as you suggested above. This absolutely did the trick. In combination with disabling the scroll-effect.min.js my website based on OceanWP now works with P2SID on all breakpoints and it looks great! Hopefully this can help others too.

    Thanks a lot for your amazing support malihu!

    Plugin Author malihu

    (@malihu)

    @hpclt You’re welcome ๐Ÿ™‚ Thanks a lot for your donation and feedback!

Viewing 13 replies - 1 through 13 (of 13 total)

The topic ‘Compatibility with OceanWP Theme’ is closed to new replies.