Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve the tip position when growing #57

Open
HifeFish opened this issue Feb 19, 2022 · 3 comments
Open

Preserve the tip position when growing #57

HifeFish opened this issue Feb 19, 2022 · 3 comments

Comments

@HifeFish
Copy link

If the cursor is grown and I want to click on something, the tip of the enlarged pointer is not the point the click will register at. This can lead to accidental clicks on the wrong button or similar.

Would it be difficult to make the cursor grow "away from the tip" so that the position of the tip is preserved?

@jeffchannell
Copy link
Owner

It really depends on the cursor icon and the "xhot/yhot" values that can be read from the shell...

https://github.com/jeffchannell/jiggle/blob/master/effects/ScalingEffect.js#L80

@HifeFish
Copy link
Author

HifeFish commented Jun 6, 2022

Unfortunately, I do not completely understand the code, but if it helps, here are some calculations that might save you at least a little bit of time:

Original cursor:
(x0,y0) = position of top left corner
(xhot,yhot) = coordinates of tip counted from top left corner

Scaled cursor:
(x0',y0') = position of top left corner
(xhot',yhot') = coordinates of tip counted from top left corner

Then for the tips to coincide, we need:
x0'+xhot' = x0+xhot

So we should take:
x0' = x0+xhot-xhot'

If our scaling factor is r, then:
x0' = x0+ (1-r)*xhot

(Same for y0.)

There seems to be some conversion between center and corner position in your code, but I did not quite understand when you need which, but the conversion should follow from:
w,h = width, height
(xc,yc) = (x0+w/2,y0+h/2) = center of cursor image

@jeffchannell
Copy link
Owner

I've made some adjustments in the master branch for cursor positioning as I was revamping the animations to remove Tweener. Adding some modifiers to the X and Y offsets seems to get the fake cursor incredibly close for each supported size.

Feel free to make local and test the changes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants