当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript IRenderingContext.visibleRangeForPosition方法代码示例

本文整理汇总了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
		};
	}
开发者ID:pk-codebox-evo,项目名称:ide-microsoft-vscode,代码行数:43,代码来源:contentWidgets.ts

示例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);
			}
		};
开发者ID:yuit,项目名称:vscode,代码行数:20,代码来源:contentWidgets.ts


注:本文中的vs/editor/common/view/renderingContext.IRenderingContext.visibleRangeForPosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。