Merge pull request #164 from BCM28/master

Fix zooming in and out
This commit is contained in:
Max Robinson
2024-07-20 14:19:12 -05:00
committed by GitHub

View File

@@ -23,10 +23,13 @@ class EnvironmentController extends CanvasController{
el.onwheel = function zoom(event) {
event.preventDefault();
var sign = -Math.sign(event.deltaY);
// Restrict scale
scale = Math.max(0.5, this.scale+(sign*zoom_speed));
var sign = Math.sign(event.deltaY);
// Update the scale by multiplying it with the zoom speed raised to the power of the scroll direction (positive or negative)
scale *= Math.pow(zoom_speed, sign);
// Make sure the scale doesn't go below a minimum value or above a maximum value
scale = Math.min(64, Math.max(Math.pow(2, -10), scale));
var cur_top = parseInt($('#env-canvas').css('top'));
var cur_left = parseInt($('#env-canvas').css('left'));