From: Russ Cox Date: Tue, 22 Mar 2011 06:04:59 +0000 (-0400) Subject: gopprof: fix bug: do not rotate 180 degrees for large scrolls X-Git-Tag: weekly.2011-03-28~74 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=1da382c871fbbe096f9eaf5a19a499fb83bf4dc5;p=gostls13.git gopprof: fix bug: do not rotate 180 degrees for large scrolls R=r CC=golang-dev https://golang.org/cl/4273088 --- diff --git a/src/cmd/prof/gopprof b/src/cmd/prof/gopprof index c7b242dec7..e391f36a0b 100755 --- a/src/cmd/prof/gopprof +++ b/src/cmd/prof/gopprof @@ -1896,6 +1896,7 @@ sub SvgJavascript { // SVGPan // http://www.cyberz.org/blog/2009/12/08/svgpan-a-javascript-svg-panzoomdrag-library/ // Local modification: if(true || ...) below to force panning, never moving. +// Local modification: add clamping to fix bug in handleMouseWheel. /** * SVGPan library 1.2 @@ -2038,6 +2039,15 @@ function handleMouseWheel(evt) { var z = 1 + delta; // Zoom factor: 0.9/1.1 + // Clamp to reasonable values. + // The 0.1 check is important because + // a very large scroll can turn into a + // negative z, which rotates the image 180 degrees. + if(z < 0.1) + z = 0.1; + if(z > 10.0) + z = 10.0; + var g = svgDoc.getElementById("viewport"); var p = getEventPoint(evt);