Does anybody have an idea how to make the WebView pannable in JavaFX? I know, that WebView is a child of the ScrollPane in JavaFX, and it is possible to make a ScrollPane pannable easily. But I have no idea how to make it pannable with a simple WebView.
If you have any ideas, please let me know. Maybe with Javascript, but how? Thanks in advance!
Making a site srollable by mouse dragging is a html thing so first remove the scrollbar from the <body>
by adding following css to the site:
body {
overflow-x: hidden;
overflow-y: hidden;
}
(if you don't know how to add css to a webview see this)
Then to enable the scrolling by dragging it you must use javascript. (see this question but it uses jquery).
OR
you can use this library (link) i found.
then add this to the html:
<script type="text/javascript" src="https://cdn.rawgit.com/asvd/dragscroll/master/dragscroll.js" />
and
also add a class named dragscroll
to whatever you want to make scrollable by drag (in your case <body>
).
(if you have trouble with adding elements or attributes i can recommend you JSoup as html parser)