raana Posted November 6, 2021 Share Posted November 6, 2021 Hi, I want to learn how to make book pages. With what I have learned so far, I was only able to show the divs one after the other, but this is not enough at all and it has many problems. I want the pages to change and drag smoothly after dragging. my cod in codesandbox and https://codesandbox.io/s/test-drag-g9bkc See the Pen by (@) on CodePen Link to comment Share on other sites More sharing options...
Cassie Posted November 6, 2021 Share Posted November 6, 2021 Hi @raana, Thanks for being a club GreenSock member! Have you taken a look at draggable? This sounds like quite a complex problem to solve so I'm *just* taking a guess here - but I'd probably try to use the onDrag event, maybe map the minX and minY coordinates to a tween that moves one of the pages? onDrag Function - A function that should be called every time the mouse (or touch) moves during the drag. Inside that function, this refers to the Draggable instance (unless you specifically set the scope using callbackScope), making it easy to access the target element (this.target) or the boundary coordinates (this.maxX, this.minX, this.maxY, and this.minY). By default, the pointerEvent (last mouse or touch event related to the Draggable) will be passed as the only parameter to the callback so that you can, for example, access its pageX, pageY, target, currentTarget, etc. This is only called once per requestAnimationFrame. An easier task would be to initially try to implement click event listeners on the pages, then on click, tween to the previous or next page. It's a lot like a slider or carousel really so taking a look at some slider demos might help with the logic! See the Pen JjomKjq by GreenSock (@GreenSock) on CodePen 1 Link to comment Share on other sites More sharing options...
raana Posted November 6, 2021 Author Share Posted November 6, 2021 Thanks, I used onClick and startDrag, The click event runs correctly but not startDrag! Is there a way to run the gopage function when dragging instead of moving? https://codesandbox.io/s/test-drag-g9bkc Link to comment Share on other sites More sharing options...
PointC Posted November 6, 2021 Share Posted November 6, 2021 There is no startDrag callback. I think you meant to use onDragStart. https://greensock.com/docs/v3/Plugins/Draggable Happy tweening. 3 Link to comment Share on other sites More sharing options...
raana Posted November 11, 2021 Author Share Posted November 11, 2021 @PointC Thank you very much, I did not know it needs to be on before, I wrote according to the tutorials and examples Dagstart. 😁 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now