From a91c07c68d48dd1d23570cc7db0664e9cfaf4d5e Mon Sep 17 00:00:00 2001 From: Denis Knauf Date: Sun, 18 Mar 2012 09:53:05 +0100 Subject: [PATCH] simple.html: zoom-buttons in header (+,-), auto-resize-code-textfield, UI-class. openjscad.js: mousewheel-zoom --- openjscad.js | 14 ++++- simple.html | 158 +++++++++++++++++++++++++++++++-------------------- 2 files changed, 109 insertions(+), 63 deletions(-) diff --git a/openjscad.js b/openjscad.js index 1039ca7..6a6d73d 100644 --- a/openjscad.js +++ b/openjscad.js @@ -94,6 +94,9 @@ OpenJsCad.Viewer = function(containerelement, width, height, initialdepth) { gl.onmousemove = function(e) { _this.onMouseMove(e); }; + gl.onmousewheel = function(e) { + _this.onMouseWheel(e); + } gl.ondraw = function() { _this.onDraw(); }; @@ -116,10 +119,19 @@ OpenJsCad.Viewer.prototype = { return !!this.gl; }, + onMouseWheel: function(e) { + e.preventDefault(); + console.log( 'mousewheel', e); + var factor = 1e-2; + this.viewpointZ *= Math.pow(2,factor * e.wheelDeltaY); + this.onDraw(); + return false; + }, + onMouseMove: function(e) { if (e.dragging) { e.preventDefault(); - if(e.altKey) + if(e.altKey||e.ctrlKey||e.metaKey) { var factor = 1e-2; this.viewpointZ *= Math.pow(2,factor * e.deltaY); diff --git a/simple.html b/simple.html index 0833bce..4b51b90 100644 --- a/simple.html +++ b/simple.html @@ -39,36 +39,105 @@ left: 0; border-bottom: 1px solid black; background: #bbb; - height: 1.2em; + height: 1.9em; } header > * { display: inline-block; } body { - margin: 1.3em 0 0 0; + margin: 2em 0 0 0; padding: 0; } - + - OpenJsCad + OpenJsCad
- Update + + + + +