Skip to content

Commit

Permalink
AutoFadeIn option in open method
Browse files Browse the repository at this point in the history
  • Loading branch information
appfeel committed Jun 25, 2015
1 parent dba68e0 commit 7b7ecb0
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/ios/OverAppBrowser.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand Down Expand Up @@ -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];
}

Expand Down Expand Up @@ -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];
Expand Down

0 comments on commit 7b7ecb0

Please sign in to comment.