flutter-webview-windows icon indicating copy to clipboard operation
flutter-webview-windows copied to clipboard

the scroll event in the webview page inside doesn't work

Open angle222 opened this issue 2 years ago • 6 comments

image how to fix it? @jnschulze

angle222 avatar May 23 '22 07:05 angle222

I have the same issue, anyone can resolve it?

fly01587 avatar May 26 '22 03:05 fly01587

I have the same issue, anyone can resolve it?

The source code of loading WebView is C++,Some people also pointed out this problem,but the author doesn't seem to think this is a bug, please checked the issue #28

angle222 avatar May 26 '22 09:05 angle222

also in #182

newproplus avatar Dec 04 '22 11:12 newproplus

there is a workaround ,it's work for me. in flutter side,catch the mouse position when mouse move ,send mouse positioin to webview when mosuse scroll. In webview, find the element by position which send from flutter, and then judge the element can scroll or not, if it can scroll ,handle the scorll event, if not, post the event to it's parent element ,do the same thing. if there is no element can hanlde the scroll event ,drop it. here is the code:

//init js method when webview page init _initScrollJs(){ _wController.executeScript( """ function eleCanScroll(ele) { if (ele.scrollTop > 0) { return ele; } else { ele.scrollTop++; const top = ele.scrollTop; top && (ele.scrollTop = 0); if(top > 0){ return ele; }else{ //if ele can't scroll ,find it's parent. return eleCanScroll( ele.parentElement); } } } """); }

//when mouse scroll ,accept the mouse position _setWebViewScroll(double x,double y,double dx,double dy){ print('_setWebViewScroll------$x----$y-------$dx---------$dy'); _wController.executeScript(""" var el = document.elementFromPoint($x,$y); //get the scroll element var el2 = eleCanScroll(el); //handle scroll el2.scrollBy($dx,$dy); """); }

//on flutter, listen the mouse move and scroll event

Listener( onPointerSignal: (signal){ if (signal is PointerScrollEvent) { _setWebViewScroll(pageKey: GlobalValues.currentShowPrgPageKey,x:GlobalValues.pointX,y: GlobalValues.pointY,dx: signal.scrollDelta.dx,dy: signal.scrollDelta.dy); } }, onPointerHover: (ev) { GlobalValues.pointX = ev.localPosition.dx; GlobalValues.pointY = ev.localPosition.dy; }, child :'your webview page' )

NickYoung-max avatar May 29 '23 07:05 NickYoung-max

@jnschulze

https://www.w3.org/WAI/WCAG22/Understanding/dragging-movements

aayushagr avatar Nov 17 '23 05:11 aayushagr