Jump to content
Search Community

Background Slider and draggable

SimonDucak test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hello,

 

I tried create background slider where slides are stretched on window height and width. Snaps work good because i tried something similar but only in smaller dimensions. I think the problem is in the distance. Which must drag the element so that the slider changes its position to the next snap.

 

I searched solution how can i decrease this distance. But i didn't find something.

 

Thank you for answer. 

 

 

Bez-názvu-1.png

See the Pen RyNBjP?editors=0010 by SimkoDucko (@SimkoDucko) on CodePen

Link to comment
Share on other sites

You can calculate snap using a function as in following demo, a lot more flexible when your slides are of same width.

 

Idea is to use a container with width 100%, which becomes your "viewport" for slider. Then calculate width of your slides container by multiplying length and then use snap function to keep track of active slide so you can recalculate slides container on resize.

 

See the Pen XqJxWK?editors=0010 by Sahil89 (@Sahil89) on CodePen

 

  • Like 4
  • Thanks 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...