Skip to content

Commit

Permalink
Added delegate calls for drag begin and ended
Browse files Browse the repository at this point in the history
  • Loading branch information
gklka committed Sep 23, 2020
1 parent 3406db8 commit 8544851
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
8 changes: 8 additions & 0 deletions Example/GKPictureInPictureView/GKViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,12 @@ - (void)pictureInPictureView:(GKPictureInPictureView *)pictureInPictureView chan
[self.pipView setPosition:position animated:YES];
}

- (void)pictureInPictureViewBeganDragging:(GKPictureInPictureView *)pictureInPictureView {
NSLog(@"%@ began dragging", pictureInPictureView);
}

- (void)pictureInPictureViewEndedDragging:(GKPictureInPictureView *)pictureInPictureView {
NSLog(@"%@ ended dragging", pictureInPictureView);
}

@end
2 changes: 1 addition & 1 deletion GKPictureInPictureView.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'GKPictureInPictureView'
s.version = '0.1.0'
s.version = '0.2.0'
s.summary = 'FaceTime/iOS PiP like throwable view'

# This description is used to generate tags and improve search results.
Expand Down
14 changes: 14 additions & 0 deletions GKPictureInPictureView/Classes/GKPictureInPictureView.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,20 @@ typedef NS_ENUM(NSUInteger, GKPictureInPictureViewSize) {
*/
- (void)pictureInPictureView:(GKPictureInPictureView *)pictureInPictureView changedSizeClass:(GKPictureInPictureViewSize)sizeClass;

/**
This method will be called when the user start to drag the view.
@property pictureInPictureView The view which has changed position
*/
- (void)pictureInPictureViewBeganDragging:(GKPictureInPictureView *)pictureInPictureView;

/**
This method will be called when the user stops dragging operation.
@property pictureInPictureView The view which has changed position
*/
- (void)pictureInPictureViewEndedDragging:(GKPictureInPictureView *)pictureInPictureView;

@end


Expand Down
11 changes: 10 additions & 1 deletion GKPictureInPictureView/Classes/GKPictureInPictureView.m
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@ - (void)pan:(UIPanGestureRecognizer *)gesutreRecognizer {

if (gesutreRecognizer.state == UIGestureRecognizerStateBegan) {
self.panInitialCenter = piece.center;
if (self.delegate &&
[self.delegate respondsToSelector:@selector(pictureInPictureViewBeganDragging:)]) {
[self.delegate pictureInPictureViewBeganDragging:self];
}
return;
}

if (gesutreRecognizer.state != UIGestureRecognizerStateCancelled) {
Expand All @@ -205,6 +210,11 @@ - (void)pan:(UIPanGestureRecognizer *)gesutreRecognizer {
} completion:^(BOOL finished) {
[self refreshAnimated:NO];
}];

if (self.delegate &&
[self.delegate respondsToSelector:@selector(pictureInPictureViewEndedDragging:)]) {
[self.delegate pictureInPictureViewEndedDragging:self];
}
}
} else {
piece.center = self.panInitialCenter;
Expand All @@ -231,7 +241,6 @@ - (void)pinch:(UIPinchGestureRecognizer *)gestureRecognizer {
}];
}
}

}

- (void)doubleTap:(UITapGestureRecognizer *)gestureRecognizer {
Expand Down

0 comments on commit 8544851

Please sign in to comment.