本文整理汇总了TypeScript中vs/editor/common/view/renderingContext.IRenderingContext.visibleRangeForPosition方法的典型用法代码示例。如果您正苦于以下问题:TypeScript IRenderingContext.visibleRangeForPosition方法的具体用法?TypeScript IRenderingContext.visibleRangeForPosition怎么用?TypeScript IRenderingContext.visibleRangeForPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vs/editor/common/view/renderingContext.IRenderingContext
的用法示例。
在下文中一共展示了IRenderingContext.visibleRangeForPosition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: _layoutBoxInViewport
private _layoutBoxInViewport(position: Position, domNode: HTMLElement, ctx: IRenderingContext): IBoxLayoutResult {
let visibleRange = ctx.visibleRangeForPosition(position);
if (!visibleRange) {
return null;
}
let width = domNode.clientWidth;
let height = domNode.clientHeight;
// Our visible box is split horizontally by the current line => 2 boxes
// a) the box above the line
let aboveLineTop = visibleRange.top;
let heightAboveLine = aboveLineTop;
// b) the box under the line
let underLineTop = visibleRange.top + this._lineHeight;
let heightUnderLine = ctx.viewportHeight - underLineTop;
let aboveTop = aboveLineTop - height;
let fitsAbove = (heightAboveLine >= height);
let belowTop = underLineTop;
let fitsBelow = (heightUnderLine >= height);
// And its left
let actualLeft = visibleRange.left;
if (actualLeft + width > ctx.viewportLeft + ctx.viewportWidth) {
actualLeft = ctx.viewportLeft + ctx.viewportWidth - width;
}
if (actualLeft < ctx.viewportLeft) {
actualLeft = ctx.viewportLeft;
}
return {
aboveTop: aboveTop,
fitsAbove: fitsAbove,
belowTop: belowTop,
fitsBelow: fitsBelow,
left: actualLeft
};
}
示例2:
let fetchPlacement = () => {
if (placement) {
return;
}
const visibleRange = ctx.visibleRangeForPosition(position);
if (!visibleRange) {
return null;
}
const domNode = widgetData.domNode.domNode;
const width = domNode.clientWidth;
const height = domNode.clientHeight;
if (widgetData.allowEditorOverflow) {
placement = this._layoutBoxInPage(visibleRange, width, height, ctx);
} else {
placement = this._layoutBoxInViewport(visibleRange, width, height, ctx);
}
};