flickity icon indicating copy to clipboard operation
flickity copied to clipboard

select cell without animation

Open Wolfr opened this issue 11 years ago • 19 comments

Q: Is there a way to prevent the excessive animation at the beginning when scrolling to a slide?

See video: http://cl.ly/0k3T3n2m1x30/kanamaster.mp4

I could hide while animating but that would just make the app feel slower.

Loving Flickity, great work @desandro .

Wolfr avatar May 04 '15 09:05 Wolfr

Ah! Good feature request. Sounds like you want a selectInstantly method. You can add this code:

Flickity.prototype.selectInstantly = function( index ) {
  if ( !this.cells[ index ] ) {
    return;
  }

  this.selectedIndex = index;
  this.setSelectedCell();
  // instantly go to cell
  this.x = -this.selectedCell.target;
  this.positionSlider();
  this.dispatchEvent('cellSelect');
};

See http://codepen.io/desandro/pen/aOvoPv


+1 this issue if you would like to see this method added to Flickity.

desandro avatar May 04 '15 13:05 desandro

Thanks so much. I've been going through the source of Flickity it's a good learning experience :+1: My project is OSS but I'll buy a license tomorrow to support your work.

Wolfr avatar May 04 '15 13:05 Wolfr

+1 from https://twitter.com/iammattq/status/617000462479396864

desandro avatar Jul 03 '15 16:07 desandro

Thanks @desandro! this is perfect.

iammattq avatar Jul 03 '15 16:07 iammattq

+1

jgerigmeyer avatar Jul 10 '15 20:07 jgerigmeyer

Hey there @desandro. I ran into a snag with your selectInstantly method. I'm currently creating an overlay and adding elements to Flickity dynamically with flkty.insert. When I close the overlay I do flkty.remove on the items in the slider (clearing them all out). When I open the overlay I re-populate the slider with new tiles via flkty.insert. The problem is is once I re-populate the slider the the selectInstantly method no longer works (reverts to old animated select).

Any ideas on how to get this to work?

iammattq avatar Jul 13 '15 17:07 iammattq

@iammattq Sorry to hear the trouble. Can you provide a reduced test case?

desandro avatar Jul 20 '15 14:07 desandro

+1

mellinger avatar Aug 21 '15 19:08 mellinger

+1

IbeVanmeenen avatar Aug 28 '15 09:08 IbeVanmeenen

+1

graygilmore avatar Oct 14 '15 22:10 graygilmore

+1

sambaldwin avatar Oct 17 '15 22:10 sambaldwin

+1

rzschoch avatar Dec 15 '15 18:12 rzschoch

In Flickity v1.1.2, select() has an additional argument to select instantly without animation.

Thanks so much for all the feedback! :rainbow: :bear:

desandro avatar Dec 16 '15 16:12 desandro

In version > 2.0.0 the Flickity object is missing the this.setSelectedCell property throwing an TypeError when using this https://github.com/metafizzy/flickity/issues/128#issuecomment-98707460

TypeError: this.setSelectedCell is not a function. (In 'this.setSelectedCell()', 'this.setSelectedCell' is undefined)

raphaelokon avatar Jul 29 '16 09:07 raphaelokon

@raphaelokon Use the isInstant argument instead of code you mentioned.

$carousel.flickity( 'select', 2, false, true )

desandro avatar Jul 29 '16 12:07 desandro

Worth noting that the vanilla API looks like:

flkty.select( index, isWrapped, isInstant )

raphaelokon avatar Aug 05 '16 13:08 raphaelokon

Is it possible to autoplay instantly so it simulates a GIF effect? I've been trying having friction: 1 with fade: true but doesn't quite work

reformatco avatar Dec 06 '19 10:12 reformatco

+1

stevesoldierunltd avatar Jun 13 '21 18:06 stevesoldierunltd

+1

hemant-tivlabs avatar Dec 24 '21 06:12 hemant-tivlabs