简体   繁体   English

JavaScript scrollBy(x,y) 不适用于 Android WebView 中的样式列宽

[英]JavaScript scrollBy(x,y) does not work with style column-width in Android WebView

I am displaying Epubs in an Android WebView.我在 Android WebView 中显示 Epubs。 To make it scroll horizontal, I have added these css rules:为了使其水平滚动,我添加了这些 css 规则:

    $("html").css("padding", 0);
    $("html").css("margin", 0);
    $("html").css("width", document.documentElement.clientWidth);
    $("body").css("padding", 0);
    $("body").css("margin", 0);
    $("body").css("height", document.documentElement.clientHeight);
    $("body").css("column-gap", 0);
    $("body").css("column-width", document.documentElement.clientWidth);

This works fine, but if I start scrolling pages by using这工作正常,但如果我开始使用滚动页面

window.scrollBy(document.documentElement.clientWidth, 0)

It always stops working 3 pages before the end of the xhtml file.它总是在 xhtml 文件结束前 3 页停止工作。 window.scrollBy and window.scrollTo stops working, nothing happens. window.scrollBy 和 window.scrollTo 停止工作,没有任何反应。 This is on all epubs I have tested on.这是在我测试过的所有 epub 上。 Nothing works.什么都行不通。 If I scroll using the Android WebView#scrollTo(x,y) it works without any issues.如果我使用 Android WebView#scrollTo(x,y) 滚动,它可以正常工作。 But I need to use JavaScript for scrolling because of some special requirements.但是由于一些特殊要求,我需要使用 JavaScript 进行滚动。 It seems that JavScript has the incorrect scrolling width, but I have no idea how to solve it.似乎 JavaScript 的滚动宽度不正确,但我不知道如何解决。 Help is very much appreciated非常感谢帮助

在标题中设置视口修复了这个问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM