var svg = Snap("#svg").drag(); //zoom 移入停止 svg zoom var zoomFlag = true; var scale = 1; /* $(".box").hover(function(e){ zoomFlag = false; },function(){ zoomFlag = true; });*/ $(document).on("mousewheel DOMMouseScroll", function (e) { if (zoomFlag) { var delta = (e.originalEvent.wheelDelta && (e.originalEvent.wheelDelta > 0 ? 1 : -1)) || (e.originalEvent.detail && (e.originalEvent.detail > 0 ? -1 : 1)); var m = new Snap.Matrix(); var zoom = 0.08; if (delta > 0) { scale = scale + zoom; } else { if (scale == 1) { //return; } scale = scale - zoom; } console.log(scale); m.scale(scale, scale); svg.transform(m); } });