added zoom with scrollwheel and alt key
parent
c13ac3cb44
commit
053b6a8731
1
Makefile
1
Makefile
|
@ -32,6 +32,7 @@ JS_FILES=\
|
|||
locale/locale.js \
|
||||
jquery-ui/jquery-ui-1.8.17.custom.min.js \
|
||||
jgraduate/jpicker.min.js \
|
||||
mousewheel.js \
|
||||
|
||||
CSS_FILES=\
|
||||
jgraduate/css/jPicker.css \
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
/*! Copyright (c) 2011 Brandon Aaron (http://brandonaaron.net)
|
||||
* Licensed under the MIT License (LICENSE.txt).
|
||||
*
|
||||
* Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
|
||||
* Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
|
||||
* Thanks to: Seamus Leahy for adding deltaX and deltaY
|
||||
*
|
||||
* Version: 3.0.6
|
||||
*
|
||||
* Requires: 1.2.2+
|
||||
*/
|
||||
|
||||
(function($) {
|
||||
|
||||
var types = ['DOMMouseScroll', 'mousewheel'];
|
||||
|
||||
if ($.event.fixHooks) {
|
||||
for ( var i=types.length; i; ) {
|
||||
$.event.fixHooks[ types[--i] ] = $.event.mouseHooks;
|
||||
}
|
||||
}
|
||||
|
||||
$.event.special.mousewheel = {
|
||||
setup: function() {
|
||||
if ( this.addEventListener ) {
|
||||
for ( var i=types.length; i; ) {
|
||||
this.addEventListener( types[--i], handler, false );
|
||||
}
|
||||
} else {
|
||||
this.onmousewheel = handler;
|
||||
}
|
||||
},
|
||||
|
||||
teardown: function() {
|
||||
if ( this.removeEventListener ) {
|
||||
for ( var i=types.length; i; ) {
|
||||
this.removeEventListener( types[--i], handler, false );
|
||||
}
|
||||
} else {
|
||||
this.onmousewheel = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$.fn.extend({
|
||||
mousewheel: function(fn) {
|
||||
return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel");
|
||||
},
|
||||
|
||||
unmousewheel: function(fn) {
|
||||
return this.unbind("mousewheel", fn);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
function handler(event) {
|
||||
var orgEvent = event || window.event, args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true, deltaX = 0, deltaY = 0;
|
||||
event = $.event.fix(orgEvent);
|
||||
event.type = "mousewheel";
|
||||
|
||||
// Old school scrollwheel delta
|
||||
if ( orgEvent.wheelDelta ) { delta = orgEvent.wheelDelta/120; }
|
||||
if ( orgEvent.detail ) { delta = -orgEvent.detail/3; }
|
||||
|
||||
// New school multidimensional scroll (touchpads) deltas
|
||||
deltaY = delta;
|
||||
|
||||
// Gecko
|
||||
if ( orgEvent.axis !== undefined && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
|
||||
deltaY = 0;
|
||||
deltaX = -1*delta;
|
||||
}
|
||||
|
||||
// Webkit
|
||||
if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY/120; }
|
||||
if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = -1*orgEvent.wheelDeltaX/120; }
|
||||
|
||||
// Add event and delta to the front of the arguments
|
||||
args.unshift(event, delta, deltaX, deltaY);
|
||||
|
||||
return ($.event.dispatch || $.event.handle).apply(this, args);
|
||||
}
|
||||
|
||||
})(jQuery);
|
|
@ -48,6 +48,7 @@
|
|||
<script type="text/javascript" src="contextmenu.js"></script>
|
||||
<script type="text/javascript" src="jquery-ui/jquery-ui-1.8.17.custom.min.js"></script>
|
||||
<script type="text/javascript" src="jgraduate/jpicker.min.js"></script>
|
||||
<script type="text/javascript" src="mousewheel.js"></script>
|
||||
<!--{endif}-->
|
||||
|
||||
<!-- you can load extensions here -->
|
||||
|
|
|
@ -2072,8 +2072,26 @@
|
|||
$('input').blur();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$('.menu_item').live('click', function(e){blinker(e)});
|
||||
$("svg, body").on('click', function(e){closer(e)});
|
||||
var accumulatedDelta = 0
|
||||
var zoomSteps = [6, 12, 16, 33, 50, 66, 100, 150, 200, 300, 400, 600, 800, 1200]
|
||||
$('#workarea').on('mousewheel', function(e, delta, deltaX, deltaY){
|
||||
if (e.altKey) {
|
||||
e.preventDefault();
|
||||
var currentZoom = svgCanvas.getZoom()*100;
|
||||
var arr_length = zoomSteps.length;
|
||||
for (i=0; i<arr_length; i++) {
|
||||
var max = Math.min(arr_length, i+1);
|
||||
if (deltaY > 0) zoom = (zoomSteps[i] <= currentZoom) ? zoomSteps[max] : zoom;
|
||||
if (deltaY < 0) zoom = (zoomSteps[i] < currentZoom) ? zoomSteps[i] : zoom;
|
||||
}
|
||||
if (zoom) changeZoom({value: zoom});
|
||||
}
|
||||
})
|
||||
$('.menu_title').on('click', function() {$("#menu_bar").toggleClass('active');});
|
||||
$('.menu_title').on('mouseover', function() {
|
||||
menus.removeClass('open');
|
||||
|
@ -2695,6 +2713,13 @@
|
|||
updateWireFrame();
|
||||
}
|
||||
|
||||
var minimizeModal = function() {
|
||||
|
||||
if (window.self != window.top) { //we're in an iframe
|
||||
top.exports.setEditorFocus(false);
|
||||
}
|
||||
}
|
||||
|
||||
var clickRulers = function() {
|
||||
var rulers = !$('#tool_rulers').hasClass('push_button_pressed');
|
||||
if (rulers) {
|
||||
|
@ -4057,7 +4082,7 @@
|
|||
{key: modKey + 'z', fn: clickUndo},
|
||||
{key: modKey + 'shift+z', fn: clickRedo},
|
||||
{key: modKey + 'y', fn: clickRedo},
|
||||
|
||||
{key: 'esc', fn: minimizeModal},
|
||||
{key: modKey+'x', fn: cutSelected},
|
||||
{key: modKey+'c', fn: copySelected},
|
||||
{key: modKey+'v', fn: pasteInCenter}
|
||||
|
@ -4498,13 +4523,13 @@
|
|||
var title_show = document.getElementById("title_show");
|
||||
var offset_x = 66;
|
||||
var offset_y = 48;
|
||||
$("#workarea").unbind("mousemove.rulers").bind("mousemove.rulers", function(e){
|
||||
e.stopPropagation();
|
||||
ruler_x_cursor.style.left = (e.pageX-offset_x+workarea.scrollLeft) + "px";
|
||||
ruler_y_cursor.style.top = (e.pageY-offset_y+workarea.scrollTop) + "px";
|
||||
var title = e.target.getAttribute("title");
|
||||
if (typeof title != 'undefined' && title) title_show.innerHTML(title);
|
||||
})
|
||||
if (svgedit.browser.isTouch()) {
|
||||
$("#workarea").unbind("mousemove.rulers").bind("mousemove.rulers", function(e){
|
||||
e.stopPropagation();
|
||||
ruler_x_cursor.style.left = (e.pageX-offset_x+workarea.scrollLeft) + "px";
|
||||
ruler_y_cursor.style.top = (e.pageY-offset_y+workarea.scrollTop) + "px";
|
||||
})
|
||||
}
|
||||
if(!zoom) zoom = svgCanvas.getZoom();
|
||||
if(!scanvas) scanvas = $("#svgcanvas");
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue