Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Lovestoned

infinite cube carousel

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

Thanks Sahil

 

İt looks good..I will use it only on mobile...swipe left or right...on fast swipe cube behaves like cards? What do you think?

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

Demo that fixes fast clicking,

 

See the Pen JMBPZW by Sahil89 (@Sahil89) on CodePen

 

Demo with swipe only.

 

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

 

I think to take advantage of all features of draggable, it will be a lot better to create a fixed rotating cube and change the images on the fly as it rotates.

  • Like 4
  • Thanks 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

yep jonathan its great....I implemented your code...its working well

 

another question...is it possible to use throw props with draggable?

 

if yes it would be great...

 

thanks...

  • Like 2
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

I added throwprops plugin and throwProps: true  to draggable.create() but I dont know what I am gonna do ob js code...I think you dont have any idea? 

Link to comment
Share on other sites

  • 7 months later...

Hi,

 

I am trying to reuse this pen but with svg elements but I cant make it work. What should I fix? Is it possible to apply it to svg elements? And finally, is it possible to make it roll automatically? (no prev and next buttons). 

Thanks so much for your time and help. 

 

See the Pen ZMQmgr by Salithekat (@Salithekat) on CodePen

 

Link to comment
Share on other sites

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

Thanks a lot for answering. Please , is there any example on your suggestion "You can use multiple SVG containers instead"? I dont understand the meaning. Merci much. 

 

Link to comment
Share on other sites

Ya I meant you can replace div tag with SVG tag. So you will need multiple SVG tags that will act as containers for sides of cubes.

  • Like 1
Link to comment
Share on other sites

Sorry, I cant make it autoplay. When I uncomment the autoplay lines it gives error, "Cannot read property 'index' of undefined".  Thanks for any help. 

 

 

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

Thanks you! finally I managed. Is there a way to pause the animation? 

to start the animation rotation I am using this code:

 

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

 

To pause it and restart im fighting....

 

thanks!!

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