Skip to content

Commit ffe8db1

Browse files
author
Martin Kluska
committed
- disabled outside of bounds on pan
- improved resize when pan is enabled
1 parent ea6c2b0 commit ffe8db1

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

SPUserResizableView/SPUserResizableView.m

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ - (void)setContentView:(UIView *)newContentView {
184184
// Ensure the border view is always on top by removing it and adding it to the end of the subview list.
185185
[borderView removeFromSuperview];
186186
[self addSubview:borderView];
187+
[self setFrame:[self frame]];
187188
}
188189

189190
- (void)setFrame:(CGRect)newFrame {
@@ -464,8 +465,9 @@ - (void)translateUsingTouchLocation:(CGPoint)touchPoint {
464465

465466
CGPoint newCenter = CGPointMake(self.center.x + touchPoint.x - touchStart.x, self.center.y + touchPoint.y - touchStart.y);
466467

467-
if (self.preventsPositionOutsideSuperview) {
468+
if (self.preventsPositionOutsideSuperview) {/*
468469
// Ensure the translation won't cause the view to move offscreen.
470+
469471
CGFloat midPointX = CGRectGetMidX(self.bounds);
470472
if (newCenter.x > self.superview.bounds.size.width - midPointX) {
471473
newCenter.x = self.superview.bounds.size.width - midPointX;
@@ -479,7 +481,7 @@ - (void)translateUsingTouchLocation:(CGPoint)touchPoint {
479481
}
480482
if (newCenter.y < midPointY) {
481483
newCenter.y = midPointY;
482-
}
484+
}*/
483485
}
484486
self.center = newCenter;
485487
}
@@ -510,8 +512,10 @@ - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
510512
if (![self isDisabledForTouches:touches]) {
511513
CGPoint point = [[touches anyObject] locationInView:self.superview];
512514

513-
if ([self isResizing] && [touches count] == 1 && [self willResize:point]) {
514-
[self resizeUsingTouchLocation:point];
515+
if ([self isResizing] && [touches count] == 1) {
516+
if ([self willResize:point]) {
517+
[self resizeUsingTouchLocation:point];
518+
}
515519
} else if (![self disablePan]){
516520
[self translateUsingTouchLocation:[[touches anyObject] locationInView:self]];
517521
}

0 commit comments

Comments
 (0)