...
|
...
|
@@ -10,9 +10,9 @@ |
|
|
|
|
|
NSString *completeRPCURLPath = @"/yhwebviewprogressproxy/complete";
|
|
|
|
|
|
static const float YHWebViewProgressInitialValue = 0.7f;
|
|
|
static const float YHWebViewProgressInteractiveValue = 0.9f;
|
|
|
static const float YHWebViewProgressFinalProgressValue = 0.9f;
|
|
|
static const float YHWebViewProgressInitialValue = 0.94f;
|
|
|
static const float YHWebViewProgressInteractiveValue = 0.95f;
|
|
|
static const float YHWebViewProgressFinalProgressValue = 0.96f;
|
|
|
|
|
|
@interface YHWebViewProgress ()
|
|
|
@property (nonatomic) NSUInteger loadingCount;
|
...
|
...
|
@@ -53,10 +53,15 @@ static const float YHWebViewProgressFinalProgressValue = 0.9f; |
|
|
{
|
|
|
float progress = self.progress;
|
|
|
float maxProgress = self.interactive?YHWebViewProgressFinalProgressValue:YHWebViewProgressInteractiveValue;
|
|
|
if (self.loadingCount == 0) {
|
|
|
progress = maxProgress;
|
|
|
} else {
|
|
|
float remainPercent = (float)self.loadingCount/self.maxLoadCount;
|
|
|
float increment = (maxProgress-progress) * remainPercent;
|
|
|
progress += increment;
|
|
|
progress = fminf(progress, maxProgress);
|
|
|
}
|
|
|
|
|
|
[self setProgress:progress];
|
|
|
}
|
|
|
|
...
|
...
|
@@ -133,7 +138,7 @@ static const float YHWebViewProgressFinalProgressValue = 0.9f; |
|
|
|
|
|
self.loadingCount++;
|
|
|
|
|
|
self.maxLoadCount = fmax(self.loadingCount, self.loadingCount);
|
|
|
self.maxLoadCount = self.loadingCount;
|
|
|
|
|
|
[self startProgress];
|
|
|
}
|
...
|
...
|
@@ -172,8 +177,10 @@ static const float YHWebViewProgressFinalProgressValue = 0.9f; |
|
|
[self.webViewProxy webView:webView didFailLoadWithError:error];
|
|
|
}
|
|
|
|
|
|
_loadingCount--;
|
|
|
if (error && error.code != NSURLErrorCancelled) {
|
|
|
self.loadingCount--;
|
|
|
[self incrementProgress];
|
|
|
}
|
|
|
|
|
|
NSString *readyState = [webView stringByEvaluatingJavaScriptFromString:@"document.readyState"];
|
|
|
|
...
|
...
|
@@ -186,7 +193,7 @@ static const float YHWebViewProgressFinalProgressValue = 0.9f; |
|
|
|
|
|
BOOL isNotRedirect = _currentURL && [_currentURL isEqual:webView.request.mainDocumentURL];
|
|
|
BOOL complete = [readyState isEqualToString:@"complete"];
|
|
|
if ((complete && isNotRedirect) || error) {
|
|
|
if ((complete && isNotRedirect) || (error && error.code != NSURLErrorCancelled)) {
|
|
|
[self completeProgress];
|
|
|
}
|
|
|
}
|
...
|
...
|
|