Make the CGpoint click;
variable CGpoint click;
to remember the start point of the drag, then create a local NSEvent
... handler
[NSEvent addLocalMonitorForEventsMatchingMask: NSMouseMovedMask | NSLeftMouseDownMask handler:^(NSEvent *e) { if ( e.type == NSLeftMouseDown ) click = e.locationInWindow; else "yourDelta" = click - e.locationInWindow;
"yourDelta" is the offset of this starting point from the current location ... you can also achieve similar results with scroll events by tracking NSEventScrollWheelMask
... and looking at the values โโof e.deltaX
and e.deltaY
.
Edit: I am not so familiar with event handling on iOS .. but the same method can be applied with regular event handlers ... i.e.
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent*)e { click = [e locationInView:_yourView]; } - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent*)e { "yourDelta" = click - [e locationInView:_yourView];
Regarding the "search" of your animation ... One possible way is simply [layer addAnimation:theNewAnimation]
using the previous toValue
, but instead of basing fromValue
0, or your layer
model. use layer.presentationLayer
? It's hard to say without seeing the full contents of your CAKeyframeAnimation
.
source share