From c84ec20a61ad4b019836c27e702c39a5773e070b Mon Sep 17 00:00:00 2001 From: Wonday Date: Mon, 10 Jul 2017 17:31:12 +0800 Subject: [PATCH] 1. do not trigger onPageChanged when no page changing 2. comment out debug log --- ios/RCTPdf/RCTPdfView.m | 2 +- ios/RCTPdf/WPdfView.m | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/ios/RCTPdf/RCTPdfView.m b/ios/RCTPdf/RCTPdfView.m index c110e108..02eb2024 100644 --- a/ios/RCTPdf/RCTPdfView.m +++ b/ios/RCTPdf/RCTPdfView.m @@ -95,7 +95,7 @@ - (void)setOnChange:(RCTBubblingEventBlock)onChange - (void)layoutSubviews { [super layoutSubviews]; - NSLog(@"super bunds.size:%f,%f", self.bounds.size.width, self.bounds.size.height); +// NSLog(@"super bunds.size:%f,%f", self.bounds.size.width, self.bounds.size.height); [wPdfView updateBounds]; diff --git a/ios/RCTPdf/WPdfView.m b/ios/RCTPdf/WPdfView.m index a8845398..1f2cc65d 100644 --- a/ios/RCTPdf/WPdfView.m +++ b/ios/RCTPdf/WPdfView.m @@ -234,12 +234,16 @@ - (void)noticePageChanged { if(_onChange){ + static lastPage = -1; - DLog(@"pageChanged,%d,%d", _page, _numberOfPages); + if (lastPage!=_page) { - _onChange(@{ @"message": [[NSString alloc] initWithString:[NSString stringWithFormat:@"pageChanged|%d|%d", _page, _numberOfPages]]}); - _isLoadCompleteNoticed = TRUE; + DLog(@"pageChanged,%d,%d", _page, _numberOfPages); + _onChange(@{ @"message": [[NSString alloc] initWithString:[NSString stringWithFormat:@"pageChanged|%d|%d", _page, _numberOfPages]]}); + _isLoadCompleteNoticed = TRUE; + lastPage = _page; + } } } @@ -365,8 +369,8 @@ - (void)drawRect:(CGRect)rect } - DLog(@"bunds.size:%f,%f", self.bounds.size.width, self.bounds.size.height); - DLog(@"page:%d scale:%f offset:%d,%d, pageWidth/pageHeight:%f,%f", _page, _scale, _offsetX, _offsetY, pageWidth, pageHeight); +// DLog(@"bunds.size:%f,%f", self.bounds.size.width, self.bounds.size.height); +// DLog(@"page:%d scale:%f offset:%d,%d, pageWidth/pageHeight:%f,%f", _page, _scale, _offsetX, _offsetY, pageWidth, pageHeight); CGContextRef context = UIGraphicsGetCurrentContext(); @@ -519,7 +523,7 @@ - (void)handlePan:(UIPanGestureRecognizer *)recognizer [recognizer.view.superview bringSubviewToFront:recognizer.view]; CGPoint translation = [recognizer translationInView:self]; - NSLog(@"translation %f,%f", translation.x, translation.y); +// NSLog(@"translation %f,%f", translation.x, translation.y); _offsetX += translation.x; _offsetY += translation.y;