1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-08-07 11:40:36 +00:00
TiddlyWiki5/core/modules/widgets/list/listviews/scroller.js
Jeremy Ruston 551ebdc005 Major refactoring of rendering mechanism
We now use a fake DOM implementation on the server to let us share more
rendering code between the text output vs. DOM output paths.
2013-05-17 10:12:25 +01:00

32 lines
851 B
JavaScript

/*\
title: $:/core/modules/widgets/list/listviews/scroller.js
type: application/javascript
module-type: listview
A list view that scrolls to newly inserted elements
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
var ScrollerListView = function(listWidget) {
this.listWidget = listWidget;
}
ScrollerListView.prototype.navigateTo = function(historyInfo) {
var listElementIndex = this.listWidget.findListElementByTitle(0,historyInfo.title),
listElementNode = this.listWidget.children[listElementIndex],
targetElement = listElementNode.domNode;
// Scroll the node into view
var scrollEvent = this.listWidget.renderer.renderTree.document.createEvent("Event");
scrollEvent.initEvent("tw-scroll",true,true);
targetElement.dispatchEvent(scrollEvent);
};
exports.scroller = ScrollerListView;
})();