Skip to content

Commit

Permalink
Fix wheel zoom
Browse files Browse the repository at this point in the history
  • Loading branch information
evgenyneu committed Aug 6, 2020
1 parent 0812a76 commit e6a1f42
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion js/trajectories.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* @return {object} Trajectory state object
*/
export function init(positions, size=5000) {
export function init(positions, size=10000) {
let trajectories1 = Array(size * 3).fill(0);
let trajectories2 = Array(size * 3).fill(0);

Expand Down
11 changes: 10 additions & 1 deletion js/ui/zoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,18 @@ function distanceBetweenFingers(e) {
}



/**
* User is rolling the mouse wheel, we need to zoom in/out
*/
function onWheel(state, e, currentParams) {
e.preventDefault();
currentParams.cameraDistance += e.deltaY / 100 * currentParams.cameraDistance;

// The amount of wheel scroll, deltaY can vary between system.
// We want to normalise it by using the sign
const delta = Math.sign(e.deltaY);

currentParams.cameraDistance += delta / 5 * currentParams.cameraDistance;

if (currentParams.cameraDistance > state.maxCameraDistance) {
currentParams.cameraDistance = state.maxCameraDistance;
Expand Down

0 comments on commit e6a1f42

Please sign in to comment.