Allowed zooming in to any element with the data-tw-zoom attribute

print-window-tiddler
Jeremy Ruston 2012-11-27 22:27:53 +00:00
rodzic a3c6cfdd78
commit 5fd3000838
1 zmienionych plików z 23 dodań i 13 usunięć

Wyświetl plik

@ -63,6 +63,10 @@ exports.executeMacro = function() {
return this.outerFrame;
};
exports.postRenderInDom = function() {
this.zoomAll();
};
/*
Bring a dom node into view by setting the viewport (translation and scale factors) appropriately.
@ -95,19 +99,25 @@ exports.zoomAll = function() {
var node = nodes[c];
if(node.getAttribute && node.getAttribute("data-tw-zoom")) {
var zoom = JSON.parse(node.getAttribute("data-tw-zoom"));
if(zoom) {
if(zoom.x < bounds.left) {
bounds.left = zoom.x;
}
if(zoom.y < bounds.top) {
bounds.top = zoom.y;
}
if((zoom.x + zoom.w) > bounds.right) {
bounds.right = zoom.x + zoom.w;
}
if((zoom.y + zoom.h) > bounds.bottom) {
bounds.bottom = zoom.y + zoom.h;
}
if(zoom === true) {
zoom = {
x: node.offsetLeft,
y: node.offsetTop,
w: node.scrollWidth,
h: node.scrollHeight
};
}
if(zoom.x < bounds.left) {
bounds.left = zoom.x;
}
if(zoom.y < bounds.top) {
bounds.top = zoom.y;
}
if((zoom.x + zoom.w) > bounds.right) {
bounds.right = zoom.x + zoom.w;
}
if((zoom.y + zoom.h) > bounds.bottom) {
bounds.bottom = zoom.y + zoom.h;
}
}
if(node.hasChildNodes()) {