Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

select cell without animation #128

Closed
Wolfr opened this issue May 4, 2015 · 19 comments
Closed

select cell without animation #128

Wolfr opened this issue May 4, 2015 · 19 comments

Comments

@Wolfr
Copy link

Wolfr commented May 4, 2015

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 .

@desandro
Copy link
Member

desandro commented May 4, 2015

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 desandro changed the title Prevent beginning animation add selectInstantly method May 4, 2015
@Wolfr
Copy link
Author

Wolfr commented May 4, 2015

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

@desandro desandro changed the title add selectInstantly method select cell without animation Jun 10, 2015
@desandro
Copy link
Member

desandro commented Jul 3, 2015

@iammattq
Copy link

iammattq commented Jul 3, 2015

Thanks @desandro! this is perfect.

@jgerigmeyer
Copy link

+1

@iammattq
Copy link

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?

@desandro
Copy link
Member

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

@mellinger
Copy link

+1

4 similar comments
@IbeVanmeenen
Copy link

+1

@graygilmore
Copy link

+1

@sambaldwin
Copy link

+1

@rzschoch
Copy link

+1

@desandro
Copy link
Member

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

Thanks so much for all the feedback! 🌈 🐻

@raphaelokon
Copy link

raphaelokon commented Jul 29, 2016

In version > 2.0.0 the Flickity object is missing the this.setSelectedCell property throwing an TypeError when using this #128 (comment)

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

@desandro
Copy link
Member

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

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

@raphaelokon
Copy link

Worth noting that the vanilla API looks like:

flkty.select( index, isWrapped, isInstant )

@reformatco
Copy link

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

@stevesoldierunltd
Copy link

+1

1 similar comment
@hemant-tivlabs
Copy link

+1

@metafizzy metafizzy locked as resolved and limited conversation to collaborators Dec 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests