mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 18:17:20 +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:
parent
091864ddaf
commit
fddc5d4ee6
@ -19,6 +19,7 @@ var ClassicStoryView = function(listWidget) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
ClassicStoryView.prototype.navigateTo = function(historyInfo) {
|
ClassicStoryView.prototype.navigateTo = function(historyInfo) {
|
||||||
|
var duration = $tw.utils.getAnimationDuration()
|
||||||
var listElementIndex = this.listWidget.findListItem(0,historyInfo.title);
|
var listElementIndex = this.listWidget.findListItem(0,historyInfo.title);
|
||||||
if(listElementIndex === undefined) {
|
if(listElementIndex === undefined) {
|
||||||
return;
|
return;
|
||||||
@ -29,13 +30,18 @@ ClassicStoryView.prototype.navigateTo = function(historyInfo) {
|
|||||||
if(!(targetElement instanceof Element)) {
|
if(!(targetElement instanceof Element)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(duration) {
|
||||||
// Scroll the node into view
|
// Scroll the node into view
|
||||||
this.listWidget.dispatchEvent({type: "tm-scroll", target: targetElement});
|
this.listWidget.dispatchEvent({type: "tm-scroll", target: targetElement});
|
||||||
|
} else {
|
||||||
|
targetElement.scrollIntoView();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ClassicStoryView.prototype.insert = function(widget) {
|
ClassicStoryView.prototype.insert = function(widget) {
|
||||||
var targetElement = widget.findFirstDomNode(),
|
var duration = $tw.utils.getAnimationDuration();
|
||||||
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)
|
// Abandon if the list entry isn't a DOM element (it might be a text node)
|
||||||
if(!(targetElement instanceof Element)) {
|
if(!(targetElement instanceof Element)) {
|
||||||
return;
|
return;
|
||||||
@ -66,11 +72,13 @@ ClassicStoryView.prototype.insert = function(widget) {
|
|||||||
{marginBottom: currMarginBottom + "px"},
|
{marginBottom: currMarginBottom + "px"},
|
||||||
{opacity: "1.0"}
|
{opacity: "1.0"}
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ClassicStoryView.prototype.remove = function(widget) {
|
ClassicStoryView.prototype.remove = function(widget) {
|
||||||
|
var duration = $tw.utils.getAnimationDuration();
|
||||||
|
if(duration) {
|
||||||
var targetElement = widget.findFirstDomNode(),
|
var targetElement = widget.findFirstDomNode(),
|
||||||
duration = $tw.utils.getAnimationDuration(),
|
|
||||||
removeElement = function() {
|
removeElement = function() {
|
||||||
widget.removeChildDomNodes();
|
widget.removeChildDomNodes();
|
||||||
};
|
};
|
||||||
@ -103,6 +111,9 @@ ClassicStoryView.prototype.remove = function(widget) {
|
|||||||
{marginBottom: (-currHeight) + "px"},
|
{marginBottom: (-currHeight) + "px"},
|
||||||
{opacity: "0.0"}
|
{opacity: "0.0"}
|
||||||
]);
|
]);
|
||||||
|
} else {
|
||||||
|
widget.removeChildDomNodes();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.classic = ClassicStoryView;
|
exports.classic = ClassicStoryView;
|
||||||
|
Loading…
Reference in New Issue
Block a user