MCPcopy Create free account
hub / github.com/TruthHun/BookStack / fromCoordSystem

Function fromCoordSystem

static/mergely/lib/codemirror.js:2804–2819  ·  view source on GitHub ↗
(cm, coords, context)

Source from the content-addressed store, hash-verified

2802 // Coverts a box from "div" coords to another coordinate system.
2803 // Context may be "window", "page", "div", or "local"/null.
2804 function fromCoordSystem(cm, coords, context) {
2805 if (context == "div") return coords;
2806 var left = coords.left, top = coords.top;
2807 // First move into "page" coordinate system
2808 if (context == "page") {
2809 left -= pageScrollX();
2810 top -= pageScrollY();
2811 } else if (context == "local" || !context) {
2812 var localBox = cm.display.sizer.getBoundingClientRect();
2813 left += localBox.left;
2814 top += localBox.top;
2815 }
2816
2817 var lineSpaceBox = cm.display.lineSpace.getBoundingClientRect();
2818 return {left: left - lineSpaceBox.left, top: top - lineSpaceBox.top};
2819 }
2820
2821 function charCoords(cm, pos, context, lineObj, bias) {
2822 if (!lineObj) lineObj = getLine(cm.doc, pos.line);

Callers 1

codemirror.jsFile · 0.70

Calls 2

pageScrollXFunction · 0.70
pageScrollYFunction · 0.70

Tested by

no test coverage detected