Fixed: touch scrolling events to scrollviews also scrolled the document body (#2750)

This commit is contained in:
daboe01 authored and Martin Carlberg committed 2018-08-20 11:05:13 +02:00
1 parent 78524cdde7
commit fa6177b56d
1 file changed
+12 -5
+12 -5
View File
@@ -427,10 +427,10 @@ _CPPlatformWindowWillCloseNotification = @"_CPPlatformWindowWillCloseNotificatio
theDocument.addEventListener("keydown", keyEventCallback, NO);
theDocument.addEventListener("keypress", keyEventCallback, NO);
theDocument.addEventListener("touchstart", touchEventCallback, NO);
theDocument.addEventListener("touchend", touchEventCallback, NO);
theDocument.addEventListener("touchmove", touchEventCallback, NO);
theDocument.addEventListener("touchcancel", touchEventCallback, NO);
theDocument.addEventListener("touchstart", touchEventCallback, {passive: false});
theDocument.addEventListener("touchend", touchEventCallback, {passive: false});
theDocument.addEventListener("touchmove", touchEventCallback, {passive: false});
theDocument.addEventListener("touchcancel", touchEventCallback, {passive: false});
_DOMWindow.addEventListener("DOMMouseScroll", scrollEventCallback, NO);
_DOMWindow.addEventListener("wheel", scrollEventCallback, NO);
@@ -1180,6 +1180,12 @@ _CPPlatformWindowWillCloseNotification = @"_CPPlatformWindowWillCloseNotificatio
// two fingers->simulate scrolling events
if (aDOMEvent.touches && aDOMEvent.touches.length == 2)
{
if (aDOMEvent.preventDefault)
aDOMEvent.preventDefault();
if (aDOMEvent.stopPropagation)
aDOMEvent.stopPropagation();
switch (aDOMEvent.type)
{
case CPDOMEventTouchStart:
@@ -1199,7 +1205,8 @@ _CPPlatformWindowWillCloseNotification = @"_CPPlatformWindowWillCloseNotificatio
return;
}
}
// handle other touch cases specifically
// cancel other touch cases preventively
if (aDOMEvent.preventDefault)
aDOMEvent.preventDefault();