mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-06-03 23:24:07 +00:00
Make the zoomin storyview visualisation properly track the title node
This commit is contained in:
parent
d8a5dfc862
commit
8fbae4435f
@ -27,10 +27,6 @@ var ZoominListView = function(listWidget) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function findTitleWidget() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
ZoominListView.prototype.navigateTo = function(historyInfo) {
|
ZoominListView.prototype.navigateTo = function(historyInfo) {
|
||||||
var duration = $tw.utils.getAnimationDuration(),
|
var duration = $tw.utils.getAnimationDuration(),
|
||||||
listElementIndex = this.listWidget.findListItem(0,historyInfo.title);
|
listElementIndex = this.listWidget.findListItem(0,historyInfo.title);
|
||||||
@ -56,8 +52,8 @@ ZoominListView.prototype.navigateTo = function(historyInfo) {
|
|||||||
height: window.innerHeight/8
|
height: window.innerHeight/8
|
||||||
};
|
};
|
||||||
// Try to find the title node in the target tiddler
|
// Try to find the title node in the target tiddler
|
||||||
var titleWidget = findTitleWidget(listItemWidget) || listItemWidget,
|
var titleDomNode = findTitleDomNode(listItemWidget) || listItemWidget.findFirstDomNode(),
|
||||||
zoomBounds = titleWidget.findFirstDomNode().getBoundingClientRect();
|
zoomBounds = titleDomNode.getBoundingClientRect();
|
||||||
// Compute the transform for the target tiddler to make the title lie over the source rectange
|
// Compute the transform for the target tiddler to make the title lie over the source rectange
|
||||||
var targetBounds = targetElement.getBoundingClientRect(),
|
var targetBounds = targetElement.getBoundingClientRect(),
|
||||||
scale = sourceBounds.width / zoomBounds.width,
|
scale = sourceBounds.width / zoomBounds.width,
|
||||||
@ -103,6 +99,18 @@ ZoominListView.prototype.navigateTo = function(historyInfo) {
|
|||||||
// $tw.pageScroller.scrollIntoView(targetElement);
|
// $tw.pageScroller.scrollIntoView(targetElement);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
Find the first child DOM node of a widget that has the class "title"
|
||||||
|
*/
|
||||||
|
function findTitleDomNode(widget,targetClass) {
|
||||||
|
targetClass = targetClass || "title";
|
||||||
|
var domNode = widget.findFirstDomNode();
|
||||||
|
if(domNode && domNode.querySelector) {
|
||||||
|
return domNode.querySelector("." + targetClass);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
ZoominListView.prototype.insert = function(widget) {
|
ZoominListView.prototype.insert = function(widget) {
|
||||||
var targetElement = widget.findFirstDomNode();
|
var targetElement = widget.findFirstDomNode();
|
||||||
// Make the newly inserted node position absolute and hidden
|
// Make the newly inserted node position absolute and hidden
|
||||||
|
Loading…
x
Reference in New Issue
Block a user