Return correct y/height relative to page size
774617
def y(value)
      return value if letter?

      width_ratio = value / PAGE_SIZES[:letter].height
      width_ratio * @page_size.height
    end
1335534
def y_pos(self, yval):
        ""
        off = self.y_coord.get_canvas_pos(self.size[1], yval,
                                          self.y_range[0], self.y_range[1])
        return self.loc[1] + off
898087
function getStartEndRowsFromBoardSize(boardSize) {
    const endRow = boardSize.y - 1;
    return {
        white: getStartEndRow(endRow, false),
        black: getStartEndRow(endRow, true)
    };
}
665823
function (node, win, offsetTop) {
        var getViewPaneSize = function () {
                var doc = win.document,
                    mode = doc.compatMode == 'CSS1Compat';
                return {
                    width:( mode ? doc.documentElement.clientWidth : doc.body.clientWidth ) || 0,
                    height:( mode ? doc.documentElement.clientHeight : doc.body.clientHeight ) || 0
                };
            },
            getScrollPosition = function (win) {
                if ('pageXOffset' in win) {
                    return {
                        x:win.pageXOffset || 0,
                        y:win.pageYOffset || 0
                    };
                }
                else {
                    var doc = win.document;
                    return {
                        x:doc.documentElement.scrollLeft || doc.body.scrollLeft || 0,
                        y:doc.documentElement.scrollTop || doc.body.scrollTop || 0
                    };
                }
            };
        var winHeight = getViewPaneSize().height, offset = winHeight * -1 + offsetTop;
        offset += (node.offsetHeight || 0);
        var elementPosition = domUtils.getXY(node);
        offset += elementPosition.y;
        var currentScroll = getScrollPosition(win).y;
        // offset += 50;
        if (offset > currentScroll || offset < currentScroll - winHeight) {
            win.scrollTo(0, offset + (offset < 0 ? -20 : 20));
        }
    }
1096586
def scroll_y(self, pixels, relative=True):
        '''
        
        '''
        if relative:
            self.offset.y += int(pixels)
        else:
            self.offset.y = int(pixels)
        self._update()
764871
def position_to_value(self, y):
        """"""
        vsb = self.editor.verticalScrollBar()
        return vsb.minimum()+max([0, (y-self.offset)/self.get_scale_factor()])
1220102
function getAdjustedSizes(_ref4) // or 'cover'
{
  var aspectRatio = _ref4.aspectRatio,
      height = _ref4.height,
      width = _ref4.width;
  var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'contain';

  var isValidNumber = function isValidNumber(value) {
    return isFinite(value) && value > 0;
  };

  if (isValidNumber(width) && isValidNumber(height)) {
    var adjustedWidth = height * aspectRatio;

    if (type === 'contain' && adjustedWidth > width || type === 'cover' && adjustedWidth < width) {
      height = width / aspectRatio;
    } else {
      width = height * aspectRatio;
    }
  } else if (isValidNumber(width)) {
    height = width / aspectRatio;
  } else if (isValidNumber(height)) {
    width = height * aspectRatio;
  }

  return {
    width: width,
    height: height
  };
}
250055
function (rect) {
			return Crafty.viewport._x + rect._x + rect._w > 0 && Crafty.viewport._y + rect._y + rect._h > 0 &&
				   Crafty.viewport._x + rect._x < Crafty.viewport.width && Crafty.viewport._y + rect._y < Crafty.viewport.height;
		}
629567
function() {
  var doc = document.documentElement;
  return {
    x: (window.pageXOffset || doc.scrollLeft) - (doc.clientLeft || 0),
    y: (window.pageYOffset || doc.scrollTop)  - (doc.clientTop || 0)
  };
}
180624
function ( includeMargin ) {
            var el = this.element(),
                margin = 0;
    
            if ( el === window ) {
                if ( window.outerWidth ) {
                    return window.outerWidth;
                } else {
                    return $B.measure.windowWidth();
                }
            } else if ( el === document ) {
                return $B.measure.documentWidth();
            } else if ( el === screen ) {
                return screen.width;
            } else {
                if ( includeMargin === true ) {
                    var marginL = parseFloat( $B(el).css('margin-left') ),
                        marginR = parseFloat( $B(el).css('margin-right') );
    
                    if ( marginL ) margin += marginL;
                    if ( marginR ) margin += marginR;
                }
    
                return el.offsetWidth + margin;
            }
        }
1219586
function(bounds, x, y)
	{
		return (bounds.x <= x && bounds.x + bounds.width >= x &&
				bounds.y <= y && bounds.y + bounds.height >= y);
	}
67405
function coordsChar(x, y) {
      var th = textHeight(), cw = charWidth(), heightPos = displayOffset + Math.floor(y / th);
      if (heightPos < 0) return {line: 0, ch: 0};
      var lineNo = lineAtHeight(doc, heightPos);
      if (lineNo >= doc.size) return {line: doc.size - 1, ch: getLine(doc.size - 1).text.length};
      var lineObj = getLine(lineNo), text = lineObj.text;
      var tw = options.lineWrapping, innerOff = tw ? heightPos - heightAtLine(doc, lineNo) : 0;
      if (x <= 0 && innerOff == 0) return {line: lineNo, ch: 0};
      var wrongLine = false;
      function getX(len) {
        var sp = measureLine(lineObj, len);
        if (tw) {
          var off = Math.round(sp.top / th);
          wrongLine = off != innerOff;
          return Math.max(0, sp.left + (off - innerOff) * scroller.clientWidth);
        }
        return sp.left;
      }
      var from = 0, fromX = 0, to = text.length, toX;
      // Guess a suitable upper bound for our search.
      var estimated = Math.min(to, Math.ceil((x + innerOff * scroller.clientWidth * .9) / cw));
      for (;;) {
        var estX = getX(estimated);
        if (estX <= x && estimated < to) estimated = Math.min(to, Math.ceil(estimated * 1.2));
        else {toX = estX; to = estimated; break;}
      }
      if (x > toX) return {line: lineNo, ch: to};
      // Try to guess a suitable lower bound as well.
      estimated = Math.floor(to * 0.8); estX = getX(estimated);
      if (estX < x) {from = estimated; fromX = estX;}
      // Do a binary search between these bounds.
      for (;;) {
        if (to - from <= 1) {
          var after = x - fromX < toX - x;
          return {line: lineNo, ch: after ? from : to, after: after};
        }
        var middle = Math.ceil((from + to) / 2), middleX = getX(middle);
        if (middleX > x) {to = middle; toX = middleX; if (wrongLine) toX += 1000; }
        else {from = middle; fromX = middleX;}
      }
    }
712082
def get_size(self):
        """"""
        attr = self._get_console_info()
        cols = attr['window']['right'] - attr['window']['left'] + 1
        lines = attr['window']['bottom'] - attr['window']['top'] + 1
        return cols, lines
360321
def height(self, container):
        """"""
        height = float(self.get_style('font_size', container))
        script_level = self.script_level(container)
        if script_level > -1:
            height *= self.position_size * (5 / 6)**script_level
        return height
44834
def text_height(text):
    """"""
    (d1, d2, ymin, ymax) = get_dimension(text)
    return (ymax - ymin, ymax)
271476
function() {

	var region = {
		width: this.get('offsetWidth'),
		height: this.get('offsetHeight')
	},

	box = this._node.getBoundingClientRect(),

	doc = document,
	docElem = doc.documentElement,
	body = doc.body,
	win = window,

	clientTop  = docElem.clientTop  || body.clientTop  || 0,
	clientLeft = docElem.clientLeft || body.clientLeft || 0,
	scrollTop  = win.pageYOffset || docElem.scrollTop  || body.scrollTop,
	scrollLeft = win.pageXOffset || docElem.scrollLeft || body.scrollLeft;

	region.top  = box.top  + scrollTop  - clientTop,
	region.left = box.left + scrollLeft - clientLeft;

	region.bottom = region.top + region.height;
	region.right = region.left + region.width;

	return region;
}
948525
function (node) {
		var r = this.getBoundingRect(node);

		var pageYOffset = (window.pageYOffset === undefined) ? document.documentElement.scrollTop : window.pageYOffset;
		var pageXOffset = (window.pageXOffset === undefined) ? document.documentElement.scrollLeft : window.pageXOffset;
		var rHeight = (r.height === undefined) ? (r.bottom - r.top) : r.height;
		var rWidth = (r.width === undefined) ? (r.right - r.left) : r.width;

		return {top: r.top + pageYOffset, left: r.left + pageXOffset, height: rHeight, width: rWidth};
	}