mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-02-09 07:30:01 +00:00
Allowed zooming in to any element with the data-tw-zoom attribute
This commit is contained in:
parent
a3c6cfdd78
commit
5fd3000838
@ -63,6 +63,10 @@ exports.executeMacro = function() {
|
|||||||
return this.outerFrame;
|
return this.outerFrame;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.postRenderInDom = function() {
|
||||||
|
this.zoomAll();
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Bring a dom node into view by setting the viewport (translation and scale factors) appropriately.
|
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];
|
var node = nodes[c];
|
||||||
if(node.getAttribute && node.getAttribute("data-tw-zoom")) {
|
if(node.getAttribute && node.getAttribute("data-tw-zoom")) {
|
||||||
var zoom = JSON.parse(node.getAttribute("data-tw-zoom"));
|
var zoom = JSON.parse(node.getAttribute("data-tw-zoom"));
|
||||||
if(zoom) {
|
if(zoom === true) {
|
||||||
if(zoom.x < bounds.left) {
|
zoom = {
|
||||||
bounds.left = zoom.x;
|
x: node.offsetLeft,
|
||||||
}
|
y: node.offsetTop,
|
||||||
if(zoom.y < bounds.top) {
|
w: node.scrollWidth,
|
||||||
bounds.top = zoom.y;
|
h: node.scrollHeight
|
||||||
}
|
};
|
||||||
if((zoom.x + zoom.w) > bounds.right) {
|
}
|
||||||
bounds.right = zoom.x + zoom.w;
|
if(zoom.x < bounds.left) {
|
||||||
}
|
bounds.left = zoom.x;
|
||||||
if((zoom.y + zoom.h) > bounds.bottom) {
|
}
|
||||||
bounds.bottom = zoom.y + zoom.h;
|
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()) {
|
if(node.hasChildNodes()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user