emscripten-core/emscripten

Mouse scroll delta is not scaled properly

Open

#6,283 创建于 2018年2月26日

在 GitHub 查看
 (26 评论) (9 反应) (0 负责人)C++ (3,519 fork)batch import
good first bughelp wanted

仓库指标

Star
 (27,361 star)
PR 合并指标
 (平均合并 19天 10小时) (30 天内合并 147 个 PR)

描述

I've done some digging and I think this is true for all scrolling in all libraries.

Using GLFW to listen to scroll events (glfwSetScrollCallback) gives me two doubles: Y and X delta. These are majorly differing between Firefox and Chrome (because as I have found, you should scale the delta according to if you get PIXELS or LINES).

In library_glfw.js, glfwInit function you listen to 'wheel' event (and others), handler is GLFW.onMouseWheel. There you call Browser.getMouseWheelDelta which for the 'wheel' event simply returns deltaY. Then this delta is just passed up to GLFW handlers.

What needs to be done is to properly handle the WheelEvent.deltaMode which can be DOM_DELTA_PIXEL or DOM_DELTA_LINE or even DOM_DELTA_PAGE.

When Firefox gives delta in LINES and Chrome gives delta in PIXELS there's a major inconsistency for apps run in those two browsers. Browser.getMouseWheelDelta is used by all libraries it seems to this issue should affect all scrolling.

贡献者指南