From 8fbae4435fd7ce7af7b6e432f33de7b84109ee2e Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Fri, 8 Nov 2013 12:36:30 +0000 Subject: [PATCH] Make the zoomin storyview visualisation properly track the title node --- core/modules/storyviews/zoomin.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/core/modules/storyviews/zoomin.js b/core/modules/storyviews/zoomin.js index 495090bb2..9aec224e4 100644 --- a/core/modules/storyviews/zoomin.js +++ b/core/modules/storyviews/zoomin.js @@ -27,10 +27,6 @@ var ZoominListView = function(listWidget) { }); } -function findTitleWidget() { - return null; -} - ZoominListView.prototype.navigateTo = function(historyInfo) { var duration = $tw.utils.getAnimationDuration(), listElementIndex = this.listWidget.findListItem(0,historyInfo.title); @@ -56,8 +52,8 @@ ZoominListView.prototype.navigateTo = function(historyInfo) { height: window.innerHeight/8 }; // Try to find the title node in the target tiddler - var titleWidget = findTitleWidget(listItemWidget) || listItemWidget, - zoomBounds = titleWidget.findFirstDomNode().getBoundingClientRect(); + var titleDomNode = findTitleDomNode(listItemWidget) || listItemWidget.findFirstDomNode(), + zoomBounds = titleDomNode.getBoundingClientRect(); // Compute the transform for the target tiddler to make the title lie over the source rectange var targetBounds = targetElement.getBoundingClientRect(), scale = sourceBounds.width / zoomBounds.width, @@ -103,6 +99,18 @@ ZoominListView.prototype.navigateTo = function(historyInfo) { // $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) { var targetElement = widget.findFirstDomNode(); // Make the newly inserted node position absolute and hidden