feat(ZoomScroll): add #reset to revert view to default

Closes #33
This commit is contained in:
Nico Rehwaldt 2014-04-14 15:09:45 +02:00
parent 8b1840d633
commit e3266af25b
1 changed files with 8 additions and 2 deletions

View File

@ -2,6 +2,7 @@ var mousewheel = require('./mousewheel');
var bpmnModule = require('../../di').defaultModule;
function ZoomScroll(events, canvas) {
var RANGE = { min: 0.2, max: 4 };
@ -13,6 +14,10 @@ function ZoomScroll(events, canvas) {
return Math.max(RANGE.min, Math.min(RANGE.max, scale));
}
function reset() {
canvas.zoom('fit-viewport');
}
function zoom(direction, position) {
var currentZoom = canvas.zoom();
@ -22,7 +27,7 @@ function ZoomScroll(events, canvas) {
}
function initMouseWheel(element) {
function init(element) {
mousewheel(element).on('mousewheel', function(event) {
@ -51,11 +56,12 @@ function ZoomScroll(events, canvas) {
}
events.on('canvas.init', function(e) {
initMouseWheel(e.paper.node);
init(e.paper.node);
});
// API
this.zoom = zoom;
this.reset = reset;
}