Jump to content
Search Community

infinite cube carousel

Lovestoned 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

Hi all

 

I want to make infinite 3d cube carousel...I have some products images on my website and I want to list them as carousel with prev next buttons...each time click next or prev turn them cubic...I searched on web but I couldnt find it as infinite...

 

I found derek wheelden codepen link about it but it has 4 slides...I have 30 images for example...

 

any idea?

 

thanks so much...

 

See the Pen HnEdt by frxnz (@frxnz) on CodePen

Link to comment
Share on other sites

3D cube was one of the first thing that I did as experiment with GSAP. Following is the demo I created by modifying @OSUblake's demo in this thread. You may want to refactor some of the code. Everything is perfect except if you click too quickly the cube behaves like animating cards but you can avoid that by maintaining reference to tween and use it to ignore clicks if cube is animating.

 

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

 

  • Like 2
Link to comment
Share on other sites

Ya like I said you can maintain a variable with reference to those tweens, so if cube is animating then you can ignore the clicks until animation finishes. Another option is to increase the timescale of ongoing animation and once it completes only then begin new animation, users will hardly notice this.

 

And sorry I am not really feeling well, I was just excited to do it so gave it a try. All the best.

  • Like 1
Link to comment
Share on other sites

Thanks Sahil its great...

 

But I wanna ask you last question...

 

slide2 is on the left and when I press next button or swipe right to left slide2 coming from left to right...could you please change them reverse? 

 

I mean I wanna make : when I swipe right to left slide2 must come from right...

 

Link to comment
Share on other sites

LoveStoned,

 

I think you can just change the order things appear in the html

 

<div id="container">
  <div class="slide">1</div>
  <div class="slide">6</div>
  <div class="slide">5</div>
  <div class="slide">4</div>
  <div class="slide">3</div>
  <div class="slide">2</div>
  
  
</div>
<div class="controls">
  <div id="next">Prev</div>
  <div id="prev">Next</div>
</div>
<span id="info"></div>

See the Pen MrBRMP?editors=1010 by GreenSock (@GreenSock) on CodePen

 

 

You can then update your ID's on your buttons ("next" and "prev") and tweak the js as needed so it makes sense.

 

 

 

 

  • Like 2
Link to comment
Share on other sites

Hello @Lovestoned and welcome to the GreenSock Forum!

 

Just to add to the Mighty @Carl and @Sahil great advice and examples!

 

I made some quick optimizations so when you animate it animates each slide using matrix3d() instead of matrix() for a smoother animation, by adding a slight rotation of 0.01. Since i was seeing some jank (lost frames) on windows 10 latest Firefox when animating left or right. As well as adding the CSS transform-style: preserve-3d on the .slide CSS rule elements for cross browser compatibility and preventing some browser bugs.

 

See the Pen XVPvZq by jonathan (@jonathan) on CodePen

 

Happy Tweening! :)

 

  • Like 5
Link to comment
Share on other sites

@Lovestoned Yes technically you can use ThrowProps with Draggable. But the way it is setup now the drag only allows it to animate a certain distance.

 

You would need to add the GSAP ThrowPropsPlugin (which is a Club GreenSock Membership plugin). Then you will need to add the GSAP ThrowPropsPlugin JS script and then add throwProps: true to the Draggable.create() parameters. But again you would need to change the functions of next and previous to go past their predefined distance of just moving to the next or prev slide.

 

GreenSock allows you to use the GSAP ThrowPropsPlugin JS on codepen so you can play and test with it. But keep in mind that the GSAP ThrowPropsPlugin will only work on codepen and not outside of it.

 

See the Pen ywpet by GreenSock (@GreenSock) on CodePen

 

:)

  • Like 3
Link to comment
Share on other sites

  • 7 months later...
Quote

Is it possible to apply it to svg elements?

 

If you mean 3D in SVG then no because only few browsers support 3D spec for SVG elements. You can use multiple SVG containers instead.

 

Yes you can set them to auto-rotate, take a look at original demo by @OSUblake

 

 

  • Like 1
Link to comment
Share on other sites

It's hard to guess what you are doing without seeing your code. But I don't know why you are trying to uncomment autoplay lines when you are trying to make it autoplay.

 

I would suggest following Blake's original demo from scratch, by typing everything line by line without copy pasting. It will help you understand what is happening, it is far easy to make changes when you understand what is happening. If you still couldn't make it work then create new thread and post your demo there.

Link to comment
Share on other sites

6 hours ago, sali and the kat said:

var autoPlay = TweenLite.delayedCall(1, setSlide);

 

To pause it and restart im fighting.... 

 

You can pause that and restart just like any tween because it is instance of TweenLite, autoPlay.pause() and autoPlay.restart().

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...