diff --git a/TiddlyFlex/files/modules/widgets/dynanode.js b/TiddlyFlex/files/modules/widgets/dynanode.js index c178c05..92007ac 100644 --- a/TiddlyFlex/files/modules/widgets/dynanode.js +++ b/TiddlyFlex/files/modules/widgets/dynanode.js @@ -109,7 +109,17 @@ DynaNodeWidget.prototype.render = function(parent,nextSibling) { self.dynanodeElements.push(entry); } var target = entry.target ? entry.target : entry; - self.checkVisibility(target); + 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 + } + } + self.checkVisibility(target,rect); } }; @@ -209,7 +219,7 @@ DynaNodeWidget.prototype.rectNotEQ = function(a,b) { !this.eqIsh(a.height, b.height)); }; -DynaNodeWidget.prototype.checkVisibility = function(element) { +DynaNodeWidget.prototype.checkVisibility = function(element,rect) { var domNodeWidth = this.domNode.offsetWidth, domNodeHeight = this.domNode.offsetHeight, domNodeBounds = this.domNode.getBoundingClientRect(); @@ -225,6 +235,17 @@ DynaNodeWidget.prototype.checkVisibility = function(element) { var currValue = this.stateMap.get(element), newValue = currValue; var elementRect = element.getBoundingClientRect(); + + if(rect) { + $tw.utils.setStyle(element,[ + { containIntrinsicSize: `${rect.width}px ${rect.height}px` } + ]); + } else { + $tw.utils.setStyle(element,[ + { containIntrinsicSize: `${elementRect.width}px ${elementRect.height}px` } + ]); + } + // Within viewport if(!(elementRect.left > domNodeRect.right || elementRect.right < domNodeRect.left || @@ -256,7 +277,7 @@ DynaNodeWidget.prototype.checkVisibility = function(element) { $tw.utils.removeClass(element,"tc-dynanode-hidden"); if(element.style["contain"] !== "content") { $tw.utils.setStyle(element,[ - { contain: "content" } + { contain: "size layout paint style" } ]); } } @@ -266,7 +287,7 @@ DynaNodeWidget.prototype.checkVisibility = function(element) { $tw.utils.removeClass(element,"tc-dynanode-near"); if(element.style["contain"] !== "content") { $tw.utils.setStyle(element,[ - { contain: "content" } + { contain: "size layout paint style" } ]); } } diff --git a/TiddlyFlex/files/modules/widgets/subclasses/transclude.js b/TiddlyFlex/files/modules/widgets/subclasses/transclude.js new file mode 100644 index 0000000..4e32391 --- /dev/null +++ b/TiddlyFlex/files/modules/widgets/subclasses/transclude.js @@ -0,0 +1,56 @@ +/*\ +title: $:/plugins/BTC/TiddlyFlex/modules/widgets/subclasses/transclude.js +type: application/javascript +module-type: widget-subclass + +Widget base class + +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +exports.baseClass = "transclude"; + +exports.constructor = function(parseTreeNode,options) { + this.initialise(parseTreeNode,options); +}; + +exports.prototype = {}; + +exports.prototype.findParentContainedElement = function() { + var widget = this; + while(widget) { + for(var i=0; i 0) || (this.transcludeVariableIsFunction && this.functionNeedsRefresh()) || (!this.transcludeVariable && changedTiddlers[this.transcludeTitle] && this.parserNeedsRefresh())) { + var containedElement = this.findParentContainedElement(); + this.refreshSelf(); + if(containedElement) { + $tw.utils.setStyle(containedElement,[ + { contain: null } + ]); + } + return true; + } else { + return this.refreshChildren(changedTiddlers); + } +}; + +})(); \ No newline at end of file diff --git a/TiddlyFlex/files/tiddlywiki.files b/TiddlyFlex/files/tiddlywiki.files index 106f9e1..166c28b 100644 --- a/TiddlyFlex/files/tiddlywiki.files +++ b/TiddlyFlex/files/tiddlywiki.files @@ -63,6 +63,13 @@ "title": "$:/plugins/BTC/TiddlyFlex/modules/widgets/subclasses/droppable.js", "module-type": "widget-subclass" } + },{ + "file": "modules/widgets/subclasses/transclude.js", + "fields": { + "type": "application/javascript", + "title": "$:/plugins/BTC/TiddlyFlex/modules/widgets/subclasses/transclude.js", + "module-type": "widget-subclass" + } } ] } \ No newline at end of file diff --git a/TiddlyFlex/plugin.info b/TiddlyFlex/plugin.info index 426a4cc..166e617 100644 --- a/TiddlyFlex/plugin.info +++ b/TiddlyFlex/plugin.info @@ -4,7 +4,7 @@ "name": "TiddlyFlex", "plugin-type": "plugin", "author": "Simon Huber", - "version": "0.0.168", + "version": "0.0.169", "core-version": ">=5.3.3", "source": "https://github.com/BurningTreeC/TiddlyFlex", "list": "readme license"