Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Scaling on pan #91

Open
wants to merge 2 commits into from

2 participants

@niklassaers

Hi Gulam,
When I pan an item in my grid view, I want to have the ability for the item to stand a bit out. Thus I've added a scaling factor, and that seems to work fine. I'd love to have this as a part of the master branch, as I'm sure more people would like this feature.

Cheers

Nik

@MaxZeng

Hi, Niklassarers,

thanks for your code. I use it during testing, everything works correctly except I need to remove the line on 575, i.e. "_sortMovingItem.transform = CGAffineTransformMakeScale(self.scaleOnPan, self.scaleOnPan);"

or when the gesture ends, the dragging cell will be restored to the orignal position, then move to the destination place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 8, 2012
  1. @niklassaers

    Add scaling on pan

    niklassaers authored
  2. @niklassaers
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 1 deletion.
  1. +1 −0  GMGridView/GMGridView.h
  2. +7 −1 GMGridView/GMGridView.m
View
1  GMGridView/GMGridView.h
@@ -84,6 +84,7 @@ typedef enum
@property (nonatomic) UIEdgeInsets minEdgeInsets; // Default is (5, 5, 5, 5)
@property (nonatomic) CFTimeInterval minimumPressDuration; // Default is 0.2; if set to 0, the view wont be scrollable
@property (nonatomic) BOOL showFullSizeViewWithAlphaWhenTransforming; // Default is YES - not working right now
+@property (nonatomic) float scaleOnPan; // Default is 1.1
@property (nonatomic) BOOL enableEditOnLongPress; // Default is NO
@property (nonatomic) BOOL disableEditOnEmptySpaceTap; // Default is NO
View
8 GMGridView/GMGridView.m
@@ -144,6 +144,7 @@ @implementation GMGridView
@synthesize minEdgeInsets = _minEdgeInsets;
@synthesize showFullSizeViewWithAlphaWhenTransforming;
@synthesize editing = _editing;
+@synthesize scaleOnPan=_scaleOnPan;
@synthesize enableEditOnLongPress;
@synthesize disableEditOnEmptySpaceTap;
@@ -245,6 +246,7 @@ - (void)commonInit
self.editing = NO;
self.itemSpacing = 10;
self.style = GMGridViewStyleSwap;
+ self.scaleOnPan = 1.1f;
self.minimumPressDuration = 0.2;
self.showFullSizeViewWithAlphaWhenTransforming = YES;
self.minEdgeInsets = UIEdgeInsetsMake(5, 5, 5, 5);
@@ -570,6 +572,8 @@ - (void)longPressGestureUpdated:(UILongPressGestureRecognizer *)longPressGesture
{
[_sortingPanGesture end];
+ _sortMovingItem.transform = CGAffineTransformMakeScale(self.scaleOnPan, self.scaleOnPan);
+
if (_sortMovingItem)
{
CGPoint location = [longPressGesture locationInView:self];
@@ -607,7 +611,8 @@ - (void)sortingPanGestureUpdated:(UIPanGestureRecognizer *)panGesture
CGPoint offset = translation;
CGPoint locationInScroll = [panGesture locationInView:self];
- _sortMovingItem.transform = CGAffineTransformMakeTranslation(offset.x, offset.y);
+ _sortMovingItem.transform = CGAffineTransformConcat(CGAffineTransformMakeScale(self.scaleOnPan, self.scaleOnPan),
+ CGAffineTransformMakeTranslation(offset.x, offset.y));
[self sortingMoveDidContinueToPoint:locationInScroll];
break;
@@ -709,6 +714,7 @@ - (void)sortingMoveDidStartAtPoint:(CGPoint)point
[self bringSubviewToFront:item];
_sortMovingItem = item;
+ _sortMovingItem.transform = CGAffineTransformMakeScale(self.scaleOnPan, self.scaleOnPan);
CGRect frameInMainView = [self convertRect:_sortMovingItem.frame toView:self.mainSuperView];
Something went wrong with that request. Please try again.