Jump to content
Search Community

not able to get the right input range to get the smooth pointermove animation on mockup animation

whizzbbig test
Moderator Tag

Recommended Posts

I went on to create this mockup animation, and I was able to complete half of it. But I got stuck when I tried to achieve smooth rotation on mouse movement from the X and Y direction. I thought using .maprange would be a good idea to map the input range of -100 to 100 (which corresponds to the full range of the X and Y values) to the output range of -30 to 30. However, the result didn't turn out as I hoped 


. Can you help me like where I went wrong? Also, could you enlighten me on how I can make the div rotate on click and infinitely, like it is being rotated using CSS custom properties? I'm really feeling very embarrassed about not being that good in math.


Website Link: https://linktr.ee/

See the Pen BaORxjq?editors=0010 by raj-shukla (@raj-shukla) on CodePen

Link to comment
Share on other sites

13 hours ago, Ali Manuel said:

Hello @whizzbbig , There might be better ways to accomplish this animation , such as


I am using this article by @jhey to get started with the animation, and I think there's something wrong with the math the example you shared is better and easy to accomplish and i really liked it 😍 but at the end of the day the purpose is to learn and explore how beyond we can get with the CSS 3D Transforms.. 

  • Like 1
Link to comment
Share on other sites

Heya! I noticed you had a typo in your CSS, prespective instead of perspective.

I'd also recommend removing transitions in your CSS and just using GSAP for the animation (or just using CSS) Using both is muddle-city. Just asking for trouble and conflicts.

Here's a little minified example of using GSAP to tween a CSS var, hopefully that helps. You'll usually be better off just setting transforms directly using GSAP's shortcodes though - x, y, rotation,  etc


See the Pen poOrXgw?editors=0011 by GreenSock (@GreenSock) on CodePen


@jh3y pops in here occasionally so maybe he'll be able to give you a hand with the rest! I took a look at your markup and CSS and I'm not quite sure what your goal is there, maybe you were trying to make a box?

Another tip - I'd use quickTo for stuff like this. Better for performance, it's basically an optimized function that's tied to a particular property. So it pipes a new number to it and skips convenience tasks that you get in a normal gsap.to() call


  • Like 3
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...