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

Go to certain li element #27

Closed
lizzie1987 opened this issue Jan 26, 2012 · 2 comments
Closed

Go to certain li element #27

lizzie1987 opened this issue Jan 26, 2012 · 2 comments

Comments

@lizzie1987
Copy link

Hi there,

I'm a sort of newbie to js and I was wondering if the following is possible?

If I make a link on one page, and when clicked/touched on, I want it to go to a certain li element. So not next or previous but for example 3 slides further, how do I do this and is this even possible?

I guess I have to name the li elements and change something in the onclick?

Hope someone can help me!
Regards,
Lizzie

@oslego
Copy link

oslego commented Feb 15, 2012

Hi lizzie1987,

You can jump to a specific element, based on its index.
The Swipe API provides the .slide(index, duration) method.

You'd use it like this:

// considering #slider has an UL list as a fist child node. 
var mySwipe = new Swipe(document.getElementById('slider'));

// the button that makes the jump when clicked
var theTrigger = document.getElementById('trigger');

// handle the "onclick" event nicely
theTrigger.addEventListener("click", function(){

  // jump to the 4th LI element (4th, because it's a zero-indexed array)
  // animate across 500 milliseconds
  mySwipe.slide(3, 500)
})

@thebird thebird closed this as completed Feb 22, 2012
@ghost
Copy link

ghost commented Dec 29, 2013

Might be useful to add this and small snippet examples of the api in the docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants