How to disable the auto scroll when I click on slide thumbnails?

Comments

okokokok’s picture

Where does this slide stuff come from?

okokokok’s picture

Looks like there's no setting for this.

I simply uncommented the two lines in galleryformatter.module with

// $renderitems['slides'][$delta]['hash_id'] = 'slide-' . $delta . '-' . $slideset_id;

(I find it odd this "feature" was added without a related setting.)

okokokok’s picture

Ah oops. Merely uncommenting the hash_id stuff as above makes the main image disappear!

okokokok’s picture

We have this module on http://teakmoebel.com/
If someone clicks on a product thumb on the front page they will end up seeing the same thumb at the top of the screen, but we want the title to be visible. And we don't mind if our header is visible as well.

Manuel Garcia’s picture

The "scrolling" is not a feature of galleryformatter at all.

What happens is when some js updates window.location.hash (adds #slide-3-field_image-467 to the location bar of your browser), then the browser by default scrolls that DOM element with that ID into view.

However, I'm pretty sure the problem is not with galleryformatter, since we don't update window.location.hash (see the @FIXME comment on line 65 of galleryformatter.js).

So something else is probably triggering that...

okokokok’s picture

I'm starting to think that the code at http://cgit.drupalcode.org/galleryformatter/tree/theme/galleryformatter.... somehow does set location.hash if it wasn't set before.
If I disable the code no hash appears (but the image doesn't appear either).

okokokok’s picture

Ok, it's not that. I turned the event function with this and it's still setting the hash location somewhere (else).

      $hash = $(this.hash);
      $slides.filter(':visible').hide();
      $hash.show();
      $slideContainer.css("height",$hash.find('img').height());
      e.preventDefault();
okokokok’s picture

Ah I think I found it now:

    function showFirstSlide(){
      // Activate the first slide
      $('a', $thumbsLi.filter('.slide-0:not(".cloned")')).trigger('click');
     }

And gallery formatter is setting the hash of a href in galleryformatter.tpl.php: <a href="#<?php print $data['hash_id']; ?>"><?php print $data['image']; ?>

Manuel Garcia’s picture

Yes, that is triggered on load, but the click event does NOT change window.location.hash. You can easily test this on a clean Drupal install.

donquixote’s picture

Title: Disable Auto Scroll » Undesired scrolling, if used in combination with Bootstrap theme.

I found what is causing this. (I am working on the same project)

We are using a custom theme based on the Drupal Bootstrap theme, and the bootstrap.js has one behavior called "bootstrapAnchors".

  Drupal.behaviors.bootstrapAnchors = {
    attach: function(context, settings) {
      ..
      var anchors = $(context).find('a').toArray();
      for (i = 0; i < anchors.length; i++) {
        if (!anchors[i].scrollTo) {
          this.bootstrapAnchor(anchors[i]);
        }
      }

If I disable this behavior with a return; statement, the problem is gone.
See also #2153689: Smooth ScrollTo is a little aggressive, preventing slideshow to work properly in the bootstrap queue.

The anchor stuff can be switched off in the bootstrap theme settings, which we are going to do.

donquixote’s picture

Status: Active » Closed (works as designed)
Related issues: +#2153689: Smooth ScrollTo is a little aggressive, preventing slideshow to work properly

I think if anything this needs to be fixed in Bootstrap theme, which is just a bit too aggressive.

Manuel Garcia’s picture

Thanks for the update @donquixote, glad you managed to find where the problem was coming from.

@ironmanwk are you using the bootstrap theme also?