My extension VisualDiffer contains two nsITreeViews that must synchronize scrolling, when user scrolls one the other tree moves the selection to the corresponding row.
Apparently XUL trees don’t have any event handler to intercept scrolling operations so I run the risk to became crazy.
After days spent to find a solution (using google) without result I’ve tried to use the DOMAttrModified event and amazingly it worked.
First I add a listener to the tree (VisualDiffer adds listeners to left and right trees)
document.getElementById(“left-tree”).addEventListener(“DOMAttrModified”,
function(event) { gFolderDiffer.onLeftScroll(event);}, false);
The onScroll simply checks if event.attrName is “curpos” and if it’s true the tree has been scrolled by user
onLeftScroll : function(event) { if (event.attrName == “curpos”) {
rightTreeView.treebox.scrollToRow(leftTreeView.treebox.getFirstVisibleRow());
}
}
This solution works fine but maybe exists a better way…
Amazon wish list