malihu / page-scroll-to-id

Animated page scrolling to specific id within the document with jquery.
MIT License
224 stars 98 forks source link

Smooth scroll not working in sparkling theme #17

Closed yudiznilay closed 5 years ago

yudiznilay commented 5 years ago

Smooth scroll in the sparkling theme is not working. Clicking on the menu link directly jumps to section. It works perfectly in twenty nineteen theme.

jQuery version - 3.3.1

Plugins installed: WPBakery Page Builder jQuery updater Disable Gutenburg.

malihu commented 5 years ago

This is a known issue with the jQuery updater.

Go to plugin settings and change the "Selector(s)" option to:

a[href*='#']:not([href='#'])

Save changes and test your page.

This "fix" is already implemented and will be public in the next plugin version (1.6.5). You can download and use plugin's development version (which has this fix) if you want:

https://downloads.wordpress.org/plugin/page-scroll-to-id.zip

yudiznilay commented 5 years ago

I tried the above solution but still no luck in sparkling theme. It's working fine in Twentynineteen theme. Below are the attached videos.

videos.zip

malihu commented 5 years ago

Go to plugin settings and enable/check the "Prevent other scripts from handling plugin’s links" option. Save changes and test.

yudiznilay commented 5 years ago

Still the same. Browser shows error as follows:

Firefox: TypeError: a.selector is undefined[Learn More] page-scroll-to-id.min.js:2:13192 p http://localhost/one-page/wp-content/plugins/page-scroll-to-id/js/page-scroll-to-id.min.js:2

http://localhost/one-page/wp-content/plugins/page-scroll-to-id/js/page-scroll-to-id.min.js:2 **Chrome:** Uncaught TypeError: Cannot read property 'indexOf' of undefined at p (page-scroll-to-id.min.js:2) at page-scroll-to-id.min.js:2 **Safari:** [Error] TypeError: undefined is not an object (evaluating 'a.selector.indexOf') p (page-scroll-to-id.min.js:2:13399) (anonymous function) (page-scroll-to-id.min.js:2:16708)
malihu commented 5 years ago

Can you make a test by deactivating jQuery updater and see if it works?

yudiznilay commented 5 years ago

I deleted that plugin but shows the same error.

malihu commented 5 years ago

Hey, I've found the issue. I'll post an update here asap.

malihu commented 5 years ago

OK. I've just pushed a fix for this issue in plugin's development version here: https://downloads.wordpress.org/plugin/page-scroll-to-id.zip

Please (re)download/install/activate. After (re)activation, go to plugin settings and enable/check the "Prevent other scripts from handling plugin’s links" option. Save changes and test again. It should work now.

Let me know :)

yudiznilay commented 5 years ago

That removed the error but the smooth scroll is still not working. Any idea why?

malihu commented 5 years ago

Not sure. I've installed in a test environment the latest WordPress, WPBakery Page Builder and Sparkling theme. Created few menu links and a couple targets (as described here) and everything works as expected.

Do you have "Prevent other scripts from handling plugin’s links" option enabled?

What links have you created and how did you created them?

yudiznilay commented 5 years ago

Do you have "Prevent other scripts from handling plugin’s links" option enabled? - Yes

What links have you created and how did you created them? : I have created custom links in Menu and given the link for first- #section1, second- #section2 and so on... And have added id in the Row ID field as section1, section 2 and so on... Selector in page scroll to id field : a[href*='#']:not([href='#']) Excluded selector as provided in the plugin: a[href^='#tab-'], a[data-toggle].

Let me know if I am missing something.

malihu commented 5 years ago

Seems that everything you've done is correct. There must be a script that prevents "Page scroll to id" from scrolling the page but I can't tell which. Every test I've done with wpbakery and sparkling theme (and jQuery updater) works for me.

Is it possible for me to see your site? I'd probably be able to provide an exact solution if I could see which script causes the issue.

yudiznilay commented 5 years ago

I have sent credentials to your mail (manos@malihu.gr)

malihu commented 5 years ago

Thanks. I've just replied to you by email.

yudiznilay commented 5 years ago

Many thanks, it worked. Thank you for your support. 👍 I have overridden its function in the child theme by this code:

add_action( 'init', 'remove_my_action'); function remove_my_action() { remove_action( 'wp_footer','sparkling_make_top_level_menu_clickable',1 ); }

function sparkling_menu_clickable() { if ( ! wp_is_mobile() ) { ?>

<?php
}

}

add_action( 'wp_footer', 'sparkling_menu_clickable', 1 );

malihu commented 5 years ago

Great. Glad I helped :)

I think you have a typo in your code. Change the line:

$('.navbar-nav > li.menu-item > a.not("a[href*='#']:not([href='#'])').click(function () {

to:

$('.navbar-nav > li.menu-item > a').not("a[href*='#']:not([href='#'])").click(function () {

yudiznilay commented 5 years ago

Okay, thanks for the update and correction. 👍