select cell without animation
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 .
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.
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.
+1 from https://twitter.com/iammattq/status/617000462479396864
Thanks @desandro! this is perfect.
+1
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 Sorry to hear the trouble. Can you provide a reduced test case?
+1
+1
+1
+1
+1
In Flickity v1.1.2, select() has an additional argument to select instantly without animation.
Thanks so much for all the feedback! :rainbow: :bear:
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 Use the isInstant argument instead of code you mentioned.
$carousel.flickity( 'select', 2, false, true )
Worth noting that the vanilla API looks like:
flkty.select( index, isWrapped, isInstant )
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
+1
+1