From 7b7ecb0e6027004bc547fb369afad88970156d67 Mon Sep 17 00:00:00 2001 From: AppFeel Date: Thu, 25 Jun 2015 12:20:49 +0200 Subject: [PATCH] AutoFadeIn option in open method --- src/ios/OverAppBrowser.m | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/ios/OverAppBrowser.m b/src/ios/OverAppBrowser.m index 036523a..9f8af08 100755 --- a/src/ios/OverAppBrowser.m +++ b/src/ios/OverAppBrowser.m @@ -41,7 +41,7 @@ - (void) open:(CDVInvokedUrlCommand *)command } if (self.overWebView != NULL) { - [self browserExit]; // reload it as parameters may have been changed + [self browserExit]; // reload it as parameters may have changed } CGFloat originx,originy,width; @@ -53,6 +53,9 @@ - (void) open:(CDVInvokedUrlCommand *)command if (argc > 3) { height = [[arguments objectAtIndex:4] floatValue]; } + if (argc > 4) { + isAutoFadeIn = [[arguments objectAtIndex:4] boolValue]; + } CGRect viewRect = CGRectMake( originx, @@ -92,11 +95,14 @@ - (void)fade:(CDVInvokedUrlCommand *)command { if (argc < 2) { return; } - + [self fadeToAlpha:[[arguments objectAtIndex:0] floatValue] duration:[[arguments objectAtIndex:1] floatValue]]; +} + +- (void)fadeToAlpha:(float)alpha duration:(float)duration { [UIView beginAnimations:nil context:NULL]; - [UIView setAnimationDuration:[[arguments objectAtIndex:1] floatValue]]; + [UIView setAnimationDuration: alpha]; [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; - [self.overWebView setAlpha:[[arguments objectAtIndex:0] floatValue]]; + [self.overWebView setAlpha: duration]; [UIView commitAnimations]; } @@ -222,11 +228,9 @@ - (void)webViewDidFinishLoad:(UIWebView*)theWebView return; } if (self.callbackId != nil && self.currentUrl != nil) { - [UIView beginAnimations:NULL context:NULL]; - [UIView setAnimationDuration:1.0]; // you can set this to whatever you like - /* put animations to be executed here, for example: */ - self.overWebView.alpha = 1; /* end animations to be executed */ - [UIView commitAnimations]; // execute the animations listed above + if (isAutoFadeIn) { + [self fadeToAlpha:1 duration:1.0]; + } // TODO: It would be more useful to return the URL the page is actually on (e.g. if it's been redirected). NSString* url = [self.currentUrl absoluteString];