Browse Source

Make vertial zooming faster and also framerate-independent.

master
Aleksey Olokhtonov 3 days ago
parent
commit
db277039df
  1. 2
      client/config.js
  2. 6
      client/webgl_draw.js
  3. 14
      client/webgl_listeners.js

2
client/config.js

@ -6,6 +6,8 @@ const config = { @@ -6,6 +6,8 @@ const config = {
ws_reconnect_timeout: 2000,
brush_preview_timeout: 1000,
second_finger_timeout: 500,
animation_decay: 16,
vertical_zoom_speed_multiplier: 3,
debug_print: false,
draw_bvh: false,
draw_fullnodes: false,

6
client/webgl_draw.js

@ -641,7 +641,11 @@ function exp_decay(a, b, decay, dt) { @@ -641,7 +641,11 @@ function exp_decay(a, b, decay, dt) {
}
function update_canvas_zoom(state, current, target, dt) {
const decay = 16;
let decay = config.animation_decay;
if (state.zoomdown) {
decay *= config.vertical_zoom_speed_multiplier; // to make it feel more responsive at fast speed
}
if (Math.abs(1.0 - current / target) > 0.01) {
state.canvas.zoom = exp_decay(state.canvas.zoom, target, decay, dt / 1000.0);

14
client/webgl_listeners.js

@ -368,18 +368,8 @@ function pointermove(e, state, context) { @@ -368,18 +368,8 @@ function pointermove(e, state, context) {
}
if (state.zooming) {
const zooming_in = e.movementY > 0;
const zooming_out = e.movementY < 0;
let zoom_level = null;
if (zooming_in) {
zoom_level = state.canvas.zoom_level + 1
} else if (zooming_out) {
zoom_level = state.canvas.zoom_level - 1;
} else {
return;
}
const zoom_level_increment = Math.round(Math.sign(e.movementY) * Math.sqrt(Math.abs(e.movementY)));
let zoom_level = state.canvas.zoom_level + zoom_level_increment;
if (zoom_level < config.min_zoom_level || zoom_level > config.max_zoom_level) {
return;

Loading…
Cancel
Save