darsain / sly

JavaScript library for one-directional scrolling with item based navigation support.
http://darsa.in/sly
2.87k stars 497 forks source link

Start at the end (One item per frame) #222

Closed Nycko97 closed 8 years ago

Nycko97 commented 8 years ago

Hi, I would like the last "item_year" get the class "active", not the first for start the slide from the left. How can I do this ? What could I change in the sly.js or anything else ? I try with startAt but it don't work and here on the picture there is only 3 "div" but in the future it will change so i can't put a static number. I hope that you'll understand what I mean and sorry if my english is not correct.

Thank you

capture d ecran 2015-10-01 a 03 44 16

darsain commented 8 years ago

I'm not 100% sure, but you can try using negative index in startAt option to select last item, like so:

startAt: -1

Should work.

If it doesn't, you can still use Sly's API to do what you want. Just call toEnd after the initialization:

new Sly(frame, options).init().toEnd();
Nycko97 commented 8 years ago

Thank you it's work well with "toEnd". An other relative question, when the page load I see the effect from the first item to the last. How can I remove this effect to show the last item without the sliding (only when I arrive at the page)

darsain commented 8 years ago
new Sly(frame, options).init().toEnd(true);
Nycko97 commented 8 years ago

Thank you :+1: for the rapidity and the efficiency