Android-Horizontal-Swipe-WebView icon indicating copy to clipboard operation
Android-Horizontal-Swipe-WebView copied to clipboard

Last page issue

Open vaziliybober opened this issue 7 years ago • 5 comments

When I swipe to the last page, it doesn't scroll to the end of it. I have to make about 3 swiping moves to see the whole last page. And then, after I swipe back, it goes back for 3 pages instead of 1.

Thank you for your work.

vaziliybober avatar May 10 '18 13:05 vaziliybober

when you test with long text, the javascript syntax return wrong page count.

paulsenjs avatar May 21 '18 04:05 paulsenjs

Did you find any solution for it @vaziliybober and @paulsenjs ???

Jothi-Vtech avatar May 06 '19 06:05 Jothi-Vtech

No, @Jothi-Vtech. I decided not to use this code. And I didn't find an alternative, so I just don't use the animation, which isn't a big loss. You get used to it immediately.

vaziliybober avatar May 06 '19 09:05 vaziliybober

@vaziliybober I found a solution for this,

  this.setWebViewClient(new WebViewClient() {
        public void onPageFinished(@NonNull WebView view, @NonNull String url) {

            String varMySheet = "var mySheet = document.styleSheets[0];";

            String addCSSRule = "function addCSSRule(selector, newRule) {"
                    + "ruleIndex = mySheet.cssRules.length;"
                    + "mySheet.insertRule(selector + '{' + newRule + ';}', ruleIndex);"
                    + "}";

            String insertRule1 = "addCSSRule('html', 'padding: 0px; height: "
                    + (view.getMeasuredHeight() /  context.getResources().getDisplayMetrics().density)
                    + "px; -webkit-column-gap: 0px; -webkit-column-width: "
                    + view.getMeasuredWidth() + "px;')";

            view.loadUrl("javascript:" + varMySheet);
            view.loadUrl("javascript:" + addCSSRule);
            view.loadUrl("javascript:" + insertRule1);

        }
    });

This worked for me. Instead of that customized webview, I tried this. I think it's too late but it may help someone :)

Jothi-Vtech avatar May 11 '19 10:05 Jothi-Vtech

@Jothi-Vtech So you just replaced the webViewClient code in the original source (the one that calls injectJavascript ) with this? It doesn't seem to work for me, I tried a simple long HTML text and this breaks horizontal scroll completely.

DanielNovak avatar Apr 15 '20 20:04 DanielNovak