jiggle
jiggle copied to clipboard
Preserve the tip position when growing
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?
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
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
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!