I have an eBook with dir=rtl and I’m using the following css to split the content of the html into columns:
#book {
width:350px;
height:750px;
margin-left:25px;
margin-right:25px;
-webkit-column-count:auto;
-webkit-column-width:350px;
-webkit-column-gap:50px;
text-align:justify;
word-wrap: break-word;
}
I use the following line to get the Webview’s Content Width to calculate the number of columns produced:
[myWKWebView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('html')[0].scrollWidth;"]
I use the following to scroll through the WebView horizontally:
[myWKWebView evaluateJavaScript:[NSString stringWithFormat:@"window.scrollTo(%d,0);",xPosition]];
All the above code works perfectly well, until I introduce the direction to the css:
direction:rtl;
Upon adding the direction to the css, scrollWidth stops giving the correct measurement and scrollTo function ceases to work.
I use the direction in the css, to order the columns from right to left.
Is there an alternative that doesn’t affect the scrolling feature and the scrollWidth?
Kindly note, this is the code used to initialize the WebView:
WKWebViewConfiguration *theConfiguration = [[WKWebViewConfiguration alloc] init];
theConfiguration.selectionGranularity = WKSelectionGranularityCharacter;
[theConfiguration.preferences setValue:@"TRUE" forKey:@"allowFileAccessFromFileURLs"];
theConfiguration.preferences.javaScriptEnabled = true;
myWKWebView = [[WKWebView alloc] initWithFrame:self.view.frame configuration:theConfiguration];
myWKWebView.UIDelegate = self;
myWKWebView.userInteractionEnabled = true;
myWKWebView.contentMode = UIViewContentModeScaleAspectFit;
myWKWebView.autoresizesSubviews = true;
myWKWebView.scrollView.scrollEnabled = true;
myWKWebView.multipleTouchEnabled = true;
[self.view addSubview: myWKWebView];