Smooth ScrollTo prevents bootstrap slideshows to work properly.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Simon Georges’s picture

Status: Active » Needs review
FileSize
562 bytes

All credits for this patch goes to Grsmto.

Simon Georges’s picture

(It seems to prevent linking to another page with an anchor as well, see for example permalinks on node comments).

AvO WebWorks’s picture

The patch above works wonderfully thank you.

Simon Georges’s picture

Status: Needs review » Reviewed & tested by the community
JadH’s picture

Patch worked for me also

markhalliwell’s picture

Status: Reviewed & tested by the community » Fixed

Thanks @simongeorges!

Committed 638f919 to 7.x-3.x:

Issue #2153689 by Simon Georges: Smooth ScrollTo is a little aggressive, preventing slideshow to work properly.

markhalliwell’s picture

Version: 7.x-3.x-dev » 8.x-3.x-dev
Assigned: Unassigned » ryan.armstrong
Status: Fixed » Needs review

  • Commit 638f919 on 7.x-3.x, 8.x-3.x authored by Simon Georges, committed by Mark Carver:
    Issue #2153689 by Simon Georges: Smooth ScrollTo is a little aggressive...
dagomar’s picture

Could someone explain why we need that functionality in the first place? It doesn't seem to be part of bootstrap to begin with, and it interferes with all links to anchors, also the ones that some modules, like the media field, rely on.

markhalliwell’s picture

When a fixed navbar or some sort of fixed menu (admin_menu) is present, it overlays the actual position of the anchor clicked. It's a simple setting that can be disabled if it's really "interferes" with your design.

dagomar’s picture

Hi Mark,

thanks so much for yor reply! I completely overlooked that it's possible to turn that feature off. However, if I or anyone else wants to use it, perhaps there should be a way to influence the selector?

Thanks again,

Dagomar

markhalliwell’s picture

Version: 8.x-3.x-dev » 7.x-3.x-dev
Assigned: ryan.armstrong » Unassigned
Status: Needs review » Closed (fixed)

I'm just moving this back to 7.x. If this needs re-evaluation in 8.x, create a new issue.

kopeboy’s picture

Title: Smooth ScrollTo is a little aggressive, preventing slideshow to work properly » Smooth ScrollTo / Fix anchor position prevents anchor links in menus to work
Version: 7.x-3.x-dev » 7.x-3.0
Status: Closed (fixed) » Active

I am sorry to reopen this but I cannot use the feature at all with anchor links. Anchor links work only if I disable "Fix anchor position", but disabling that hides the scrolling functionality as well. So what is the rationale of this feature at all? I don't get it.

What is the problem causing anchor links not to work when "Fix anchor position" is enabled?

Using fresh install site with latest core, jquery 10 (with jquery update) and anchor links in a menu with #anchor and anchors either with name or ids.
Everything works properly when I disable the feature but of course I would like the smooth scrolling functionality. I tried other modules for that too but no one seems to work :(

kopeboy’s picture

Title: Smooth ScrollTo / Fix anchor position prevents anchor links in menus to work » Smooth ScrollTo is a little aggressive, preventing slideshow to work properly
Version: 7.x-3.0 » 7.x-3.x-dev
Status: Active » Closed (fixed)
donquixote’s picture

Status: Closed (fixed) » Needs work

This caused some confusion with Gallery formatter:
#2274693: Undesired scrolling, if used in combination with Bootstrap theme.

I think the problem is that the "fix" is only meant for anchors that work as regular links, but it also affects anchor links that already have a click behavior attached, and where the regular link action is suppressed.

Yes, it can be turned off. But it would be preferable to find a solution that only affects the links we actually care about.
Or otherwise make this opt-in.

Konstantin Komelin’s picture

The anchorBehvior should probably compare url paths and not only anchors #2343539: bootstrapAnchor does not check if URLs are different

ChrisSnyder’s picture

ScrollTo is a little aggressive, in order to prevent issues with jquery ui date popup i had to change the following:

@@ -117,7 +117,7 @@ var Drupal = Drupal || {};
         }
       }
       $scrollableElement.once('bootstrap-anchors', function () {
-        $scrollableElement.on('click.bootstrap-anchors', 'a[href*="#"]:not([data-toggle],[data-target],[data-slide])', function(e) {
+        $scrollableElement.on('click.bootstrap-anchors', 'a[href*="#"]:not([data-toggle],[data-target],[data-slide],[class^=ui-])', function(e) {
           this.scrollTo(e);
klokie’s picture

I just ran into this issue as well. Seems to me that the jQuery selector that matches the URL fragment should be a[href^="#"] – i.e. URL starts with a hash mark – rather than a[href*="#"] – i.e. URL contains a hash mark at any position. That should prevent this unwanted behavior on links to other pages (and may also help with #2343539: bootstrapAnchor does not check if URLs are different), though it probably won't fix the conflicts with other modules like Gallery formatter or Date.

markhalliwell’s picture

Status: Needs work » Closed (won't fix)

Closing in favor of #2462645: Create @BootstrapPlugin for "bootstrap-anchor".

Marking as "won't fix", because any solution(s) provided here is against the current code. This will be replaced with http://markcarver.github.io/bootstrap-anchor/ instead.