1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-27 03:57:21 +00:00

DynaView: Add "data-dynaview-has-triggered" attribute

This commit is contained in:
Jermolene 2018-04-06 14:52:27 +01:00
parent bafe447e1c
commit 67bab83902

View File

@ -137,6 +137,10 @@ function setZoomClasses() {
function checkVisibility() {
var elements = document.querySelectorAll(".tc-dynaview-set-tiddler-when-visible");
$tw.utils.each(elements,function(element) {
// Bail if we've already triggered this element
if(element.getAttribute("data-dynaview-has-triggered") === "true") {
return;
}
// Check if the element is visible
var elementRect = element.getBoundingClientRect(),
viewportWidth = window.innerWidth || document.documentElement.clientWidth,
@ -163,6 +167,7 @@ function checkVisibility() {
if(tiddler && $tw.wiki.getTiddlerText(tiddler) !== value) {
$tw.wiki.addTiddler(new $tw.Tiddler({title: tiddler, text: value}));
}
element.setAttribute("data-dynaview-has-triggered",true);
}
});
}