1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 10:07:19 +00:00

Classic Storyview: Optimise for animation duration of zero (part 1)

Approximtely 50% speed improvement in tests opening a storyview with 8,000 entries.

(I've deferred the indentation adjustments until the next commit so that the git diffs are clearer)
This commit is contained in:
Jeremy Ruston 2019-05-02 21:20:24 +01:00
parent 091864ddaf
commit fddc5d4ee6

View File

@ -19,6 +19,7 @@ var ClassicStoryView = function(listWidget) {
};
ClassicStoryView.prototype.navigateTo = function(historyInfo) {
var duration = $tw.utils.getAnimationDuration()
var listElementIndex = this.listWidget.findListItem(0,historyInfo.title);
if(listElementIndex === undefined) {
return;
@ -29,13 +30,18 @@ ClassicStoryView.prototype.navigateTo = function(historyInfo) {
if(!(targetElement instanceof Element)) {
return;
}
// Scroll the node into view
this.listWidget.dispatchEvent({type: "tm-scroll", target: targetElement});
if(duration) {
// Scroll the node into view
this.listWidget.dispatchEvent({type: "tm-scroll", target: targetElement});
} else {
targetElement.scrollIntoView();
}
};
ClassicStoryView.prototype.insert = function(widget) {
var targetElement = widget.findFirstDomNode(),
duration = $tw.utils.getAnimationDuration();
var duration = $tw.utils.getAnimationDuration();
if(duration) {
var targetElement = widget.findFirstDomNode();
// Abandon if the list entry isn't a DOM element (it might be a text node)
if(!(targetElement instanceof Element)) {
return;
@ -66,11 +72,13 @@ ClassicStoryView.prototype.insert = function(widget) {
{marginBottom: currMarginBottom + "px"},
{opacity: "1.0"}
]);
}
};
ClassicStoryView.prototype.remove = function(widget) {
var duration = $tw.utils.getAnimationDuration();
if(duration) {
var targetElement = widget.findFirstDomNode(),
duration = $tw.utils.getAnimationDuration(),
removeElement = function() {
widget.removeChildDomNodes();
};
@ -103,6 +111,9 @@ ClassicStoryView.prototype.remove = function(widget) {
{marginBottom: (-currHeight) + "px"},
{opacity: "0.0"}
]);
} else {
widget.removeChildDomNodes();
}
};
exports.classic = ClassicStoryView;