From b674769ef8921196a79cbb61ee7f412a3bdf22ab Mon Sep 17 00:00:00 2001 From: casperlamboo Date: Wed, 10 Jan 2018 14:19:57 +0100 Subject: [PATCH] normalize mouse wheel --- package-lock.json | 5 +++++ package.json | 1 + src/d2/EventGroup.js | 3 ++- src/d3/EventScene.js | 3 ++- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 950584e..9d2f26e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8438,6 +8438,11 @@ "sort-keys": "1.1.2" } }, + "normalize-wheel": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/normalize-wheel/-/normalize-wheel-1.0.1.tgz", + "integrity": "sha1-rsiGr/2wRQcNhWRH32Ls+GFG7EU=" + }, "npm": { "version": "2.15.12", "resolved": "https://registry.npmjs.org/npm/-/npm-2.15.12.tgz", diff --git a/package.json b/package.json index c3076bd..d789a6f 100755 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "keycode": "^2.1.9", "lodash": "^4.17.4", "memoizee": "^0.3.9", + "normalize-wheel": "^1.0.1", "pouchdb": "^6.3.4", "proptypes": "^1.1.0", "raf": "^3.4.0", diff --git a/src/d2/EventGroup.js b/src/d2/EventGroup.js index 7779e08..b5b8900 100644 --- a/src/d2/EventGroup.js +++ b/src/d2/EventGroup.js @@ -2,6 +2,7 @@ import { Group, Utils } from 'cal'; import createListener from 'touch-events'; import bowser from 'bowser'; import { convertEvent, isMouseEvent } from '../utils/pointerUtils.js'; +import normalizeWheel from 'normalize-wheel'; const events = [ 'wheel', 'tap', @@ -64,7 +65,7 @@ export default class EventGroup extends Group { if (event.event) gestureEvent.position = _convertEvent(event.event); if (event.events) gestureEvent.positions = event.events.map(_convertEvent); if (event.preEvents) gestureEvent.preDrags = event.preEvents.map(_convertEvent); - if (event.event && event.event.deltaY !== undefined) gestureEvent.wheelDelta = event.event.deltaY; + if (event.event && event.event.deltaY !== undefined) gestureEvent.wheelDelta = normalizeWheel(event.event).pixelY; this.onEvent(gestureEvent); } diff --git a/src/d3/EventScene.js b/src/d3/EventScene.js index 9f5414c..e499e8a 100644 --- a/src/d3/EventScene.js +++ b/src/d3/EventScene.js @@ -3,6 +3,7 @@ import { Utils } from 'cal'; import createListener from 'touch-events'; import bowser from 'bowser'; import { convertEvent, isMouseEvent } from '../utils/pointerUtils.js'; +import normalizeWheel from 'normalize-wheel'; const events = ['wheel', 'tap', 'dragstart', 'drag', 'dragend', 'seconddragstart', 'seconddrag', 'seconddragend', 'multitouchstart', 'multitouch', 'multitouchend']; @@ -41,7 +42,7 @@ export class EventScene extends THREE.Scene { if (event.event) gestureEvent.position = _convertEvent(event.event); if (event.events) gestureEvent.positions = event.events.map(_convertEvent); if (event.preEvents) gestureEvent.preDrags = event.preEvents.map(_convertEvent); - if (event.event && event.event.deltaY !== undefined) gestureEvent.wheelDelta = event.event.deltaY; + if (event.event && event.event.deltaY !== undefined) gestureEvent.wheelDelta = normalizeWheel(event.event).pixelY; this.onEvent(gestureEvent); };