Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [orion-dev] Why is ruler offset by lineHeight ?

Every ruler div has one extra div at the top (firstChild before any lines). This div is used to determine the width of the ruler. Its height is "lineHeight".  The ruler is offset by "lineHeight" to hide this div above the editor.

Why do you need to set of the ruler div?


var widthDiv;
                                                                   var child = div.firstChild;
                                                                   if (child) {
                                                                                    widthDiv = child;
                                                                                    child = child.nextSibling;
                                                                   } else {
                                                                                    widthDiv = parentDocument.createElement("DIV");
                                                                           = "hidden";
                                                                   var lineIndex;
                                                                   if (div.rulerChanged) {
                                                                                    if (widthDiv) {
                                                                                                     lineIndex = -1;
                                                                                                     this._applyStyle(ruler.getStyle(lineIndex), widthDiv);
                                                                                                     widthDiv.innerHTML = ruler.getHTML(lineIndex);
                                                                                                     widthDiv.lineIndex = lineIndex;
                                                                                            = (lineHeight + + "px";

From: John J Barton <johnjbarton@xxxxxxxxxxxxxxx>
To: Orion developer discussions <orion-dev@xxxxxxxxxxx>
Date: 08/18/2011 12:29 PM
Subject: [orion-dev] Why is ruler offset by lineHeight ?
Sent by: orion-dev-bounces@xxxxxxxxxxx

I'm trying to implement a custom annotation. My marker ends up too high. I tracked this down to the containing div having an offset of -lineHeight:

function _updateRulerSize(divRuler) {
 if (!divRuler) { return; }
 var rulerHeight = clientHeight + + viewPad.bottom;
 var cells = divRuler.firstChild.rows[0].cells;
 for (var i = 0; i < cells.length; i++) {
   var div = cells[i].firstChild;
   var offset = lineHeight;
   if (div._ruler.getOverview() === "page") { offset += partialY; } = -offset + "px";
-------------------^^^^^^^^^^^^^^^^ = (rulerHeight + offset) + "px";
   div = div.nextSibling;
 } = rulerHeight + "px";

Does anyone know why this offset is applied? It overwrites my setting.

I guess the workaround is to offset all of the markers. That means I would need to know the lineHeight, but it seems to be private, _getLineHeight(). Any hints?

orion-dev mailing list

Back to the top