Bureaucrats, Check users, Interface administrators, Moderators, Suppressors, Administrators, Widget editors
1,054
edits
No edit summary Tag: Manual revert |
No edit summary Tag: Reverted |
||
Line 8: | Line 8: | ||
try { | try { | ||
window.zoomMap = svgPanZoom('#Layer_1', { | window.zoomMap = svgPanZoom('#Layer_1', { | ||
var beforePan | |||
beforePan = function(oldPan, newPan){ | |||
var stopHorizontal = false | |||
stopVertical = false | |||
} | gutterWidth = 100 | ||
gutterHeight = 100 | |||
// Computed variables | |||
sizes = this.getSizes() | |||
leftLimit = -((sizes.viewBox.x + sizes.viewBox.width) * sizes.realZoom) + gutterWidth | |||
rightLimit = sizes.width - gutterWidth - (sizes.viewBox.x * sizes.realZoom) | |||
topLimit = -((sizes.viewBox.y + sizes.viewBox.height) * sizes.realZoom) + gutterHeight | |||
bottomLimit = sizes.height - gutterHeight - (sizes.viewBox.y * sizes.realZoom) | |||
customPan = {} | |||
customPan.x = Math.max(leftLimit, Math.min(rightLimit, newPan.x)) | |||
customPan.y = Math.max(topLimit, Math.min(bottomLimit, newPan.y)) | |||
return customPan | |||
} | |||
// Expose to window namespace for testing purposes | |||
window.panZoom = svgPanZoom('#limit-svg', { | |||
zoomEnabled: true | |||
controlIconsEnabled: true | |||
fit: 1 | |||
center: 1 | |||
beforePan: beforePan | |||
}); | |||
// panZoom.setBeforePan(beforePan) | |||
}; | |||
var svgObject = document.getElementById("Layer_1"); | var svgObject = document.getElementById("Layer_1"); | ||
// Dynamically set size to parent | // Dynamically set size to parent |