Jump to content
Search Community

Delayed motion on mouse movement with quickSetters

pilicorp test
Moderator Tag

Recommended Posts

Hi there!

 

I've spent a few days trying to find out how to delay a motion based on mouse movement.
In my example (which is a POC with dirty hacks, please don't mind them), there is my failed attempt to do it, but I only succeed in resetting the object back to its position. What I'm trying to achieve is the "added" motion, including the easing effect.

If anyone is able to pinpoint what I'm missing (probably something obvious), I would be very grateful.

See the Pen ExyNJdG by anaelbe (@anaelbe) on CodePen

Link to comment
Share on other sites

To create that sort of effect you should 

  1. Set a variable (or variables) to determine the max distance the object (to be moved) can go.
  2. Set a variable (or variables) to determine the max distance away from the center of the measurement object the mouse should be tracked.
  3. Measure the distance from the current mouse position to the center of the measurement object.
  4. Get the percent of the distance measured in 3. compared to the variable(s) set in 2.
  5. Multiply the distance from 1. by the percent obtained in 4. and apply that to the object(s) to be moved.

Make sense?

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