Skip to content

Commit

Permalink
dynanode: set only intrinsic height and only if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
BurningTreeC committed Mar 26, 2024
1 parent 5d17fed commit 30f822d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
32 changes: 21 additions & 11 deletions TiddlyFlex/files/modules/widgets/dynanode.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,11 @@ DynaNodeWidget.prototype.render = function(parent,nextSibling) {
self.dynanodeElements.push(entry);
}
var target = entry.target ? entry.target : entry;
if(entry.target && entry.target.getAttribute("data-tiddler-title") && entry.target.getAttribute("data-tiddler-title") === "New Tiddler") {
console.log(entry.borderBoxSize);
}
var rect;
if(entry.target) {
rect = {
width: entry.borderBoxSize[0].inlineSize,
height: entry.borderBoxSize[0].blockSize
width: entry.contentBoxSize[0].inlineSize,
height: entry.contentBoxSize[0].blockSize
}
}
self.checkVisibility(target,rect);
Expand Down Expand Up @@ -236,14 +233,27 @@ DynaNodeWidget.prototype.checkVisibility = function(element,rect) {
newValue = currValue;
var elementRect = element.getBoundingClientRect();

var height,
oldHeight;
if(rect) {
$tw.utils.setStyle(element,[
{ containIntrinsicSize: `${rect.width}px ${rect.height}px` }
]);
height = rect.height;
oldHeight = this.spaced.get(element);
if(!oldHeight || (oldHeight !== height)) {
this.spaced.set(element,height);
$tw.utils.setStyle(element,[
{ containIntrinsicHeight: `${rect.height}px` }
]);
}
} else {
$tw.utils.setStyle(element,[
{ containIntrinsicSize: `${elementRect.width}px ${elementRect.height}px` }
]);
var computedStyle = this.domNode.ownerDocument.defaultView.getComputedStyle(element);
height = elementRect.height - (parseFloat(computedStyle.paddingTop) + parseFloat(computedStyle.paddingBottom) + parseFloat(computedStyle.borderTopWidth) + parseFloat(computedStyle.borderBottomWidth));
oldHeight = this.spaced.get(element);
if(!oldHeight || (oldHeight !== height)) {
this.spaced.set(element,height);
$tw.utils.setStyle(element,[
{ containIntrinsicHeight: `${elementRect.height}px` }
]);
}
}

// Within viewport
Expand Down
2 changes: 1 addition & 1 deletion TiddlyFlex/plugin.info
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "TiddlyFlex",
"plugin-type": "plugin",
"author": "Simon Huber",
"version": "0.0.169",
"version": "0.0.170",
"core-version": ">=5.3.3",
"source": "https://github.com/BurningTreeC/TiddlyFlex",
"list": "readme license"
Expand Down

0 comments on commit 30f822d

Please sign in to comment.