Swiftgram/submodules/LegacyComponents/LegacyComponents/TGModernGalleryZoomableScrollView.m
Peter d153fe0f21 Add 'submodules/LegacyComponents/' from commit 'd5594346161c1b7f203d1e87068bbe77bcaac019'
git-subtree-dir: submodules/LegacyComponents
git-subtree-mainline: 608630530451e02e5aec48389d144dbf7a3625b9
git-subtree-split: d5594346161c1b7f203d1e87068bbe77bcaac019
2019-06-11 18:51:15 +01:00

49 lines
1.2 KiB
Objective-C

#import "TGModernGalleryZoomableScrollView.h"
#import "TGDoubleTapGestureRecognizer.h"
@interface TGModernGalleryZoomableScrollView () <TGDoubleTapGestureRecognizerDelegate>
@end
@implementation TGModernGalleryZoomableScrollView
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self != nil)
{
TGDoubleTapGestureRecognizer *recognizer = [[TGDoubleTapGestureRecognizer alloc] initWithTarget:self action:@selector(doubleTapGesture:)];
recognizer.consumeSingleTap = true;
[self addGestureRecognizer:recognizer];
_normalZoomScale = 1.0f;
}
return self;
}
- (void)doubleTapGesture:(TGDoubleTapGestureRecognizer *)recognizer
{
if (recognizer.state == UIGestureRecognizerStateRecognized)
{
if (recognizer.doubleTapped)
{
if (_doubleTapped)
_doubleTapped([recognizer locationInView:self]);
}
else
{
if (_singleTapped)
_singleTapped();
}
}
}
- (void)doubleTapGestureRecognizerSingleTapped:(TGDoubleTapGestureRecognizer *)__unused recognizer
{
if (_singleTapped)
_singleTapped();
}
@end