prajakta pawar
prajakta pawar

Reputation: 109

In ionic2, how to slideTo an index without animation?

I have an array of images and I am showing 1st image in Slide, now I want to jump to nth position without showing the images between 1st and nth images. What is happening, the slider is sliding all the images between 1 and n very quickly, with animation. I want to skip all images in-between and directly show nth image.

Here's the code I am using to go to nth position.

this.slides.slideTo(this.SelecteduserIndex);

Upvotes: 2

Views: 889

Answers (1)

sebaferreras
sebaferreras

Reputation: 44659

Just like you can see in the Slide docs, the slideTo method accepts the speed (transition duration in ms) as the second parameter:

> slideTo(index, speed, runCallbacks)

Transition to the specified slide.

Param           Type      Details
index           number    The index number of the slide.
speed           number    Transition duration (in ms). (OPTIONAL)
runCallbacks    boolean   Whether or not to emit the ionSlideWillChange/ionSlideDidChange events. Default true. (OPTIONAL)

So you can use 0 as the speed to remove the animation, like this:

this.slides.slideTo(this.SelecteduserIndex, 0);

Working Stackblitz demo.

Upvotes: 1

Related Questions