當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript dom.getDomNodePosition函數代碼示例

本文整理匯總了TypeScript中vs/base/browser/dom.getDomNodePosition函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript getDomNodePosition函數的具體用法?TypeScript getDomNodePosition怎麽用?TypeScript getDomNodePosition使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了getDomNodePosition函數的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: _layoutBoxInPage

	private _layoutBoxInPage(position: editorCommon.IEditorPosition, domNode: HTMLElement, ctx: IRenderingContext): IBoxLayoutResult {
		let visibleRange = ctx.visibleRangeForPosition(position);

		if (!visibleRange) {
			return null;
		}

		let left0 = visibleRange.left - ctx.viewportLeft;

		let width = domNode.clientWidth,
			height = domNode.clientHeight;

		if (left0 + width < 0 || left0 > this._contentWidth) {
			return null;
		}

		let aboveTop = visibleRange.top - height,
			belowTop = visibleRange.top + this._context.configuration.editor.lineHeight,
			left = left0 + this._contentLeft;

		let domNodePosition = dom.getDomNodePosition(this._viewDomNode);
		let absoluteAboveTop = domNodePosition.top + aboveTop - document.body.scrollTop - document.documentElement.scrollTop,
			absoluteBelowTop = domNodePosition.top + belowTop - document.body.scrollTop - document.documentElement.scrollTop,
			absoluteLeft = domNodePosition.left + left - document.body.scrollLeft - document.documentElement.scrollLeft;

		let INNER_WIDTH = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth,
			INNER_HEIGHT = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;

		// Leave some clearance to the bottom
		let BOTTOM_PADDING = 22;

		let fitsAbove = (absoluteAboveTop >= 0),
			fitsBelow = (absoluteBelowTop + height <= INNER_HEIGHT - BOTTOM_PADDING);

		if (absoluteLeft + width + 20 > INNER_WIDTH) {
			let delta = absoluteLeft - (INNER_WIDTH - width - 20);
			absoluteLeft -= delta;
			left -= delta;
		}
		if (absoluteLeft < 0) {
			let delta = absoluteLeft;
			absoluteLeft -= delta;
			left -= delta;
		}

		return {
			aboveTop: aboveTop,
			fitsAbove: fitsAbove,
			belowTop: belowTop,
			fitsBelow: fitsBelow,
			left: left
		};
	}
開發者ID:1424667164,項目名稱:vscode,代碼行數:53,代碼來源:contentWidgets.ts

示例2: _onMouseDown

	private _onMouseDown(e: IMouseEvent): void {
		let domNodePosition = DomUtils.getDomNodePosition(this.domNode.domNode);
		let desiredSliderPosition = this._mouseDownRelativePosition(e, domNodePosition) - this._scrollbarState.getArrowSize() - this._scrollbarState.getSliderSize() / 2;
		this.setDesiredScrollPosition(this._scrollbarState.convertSliderPositionToScrollPosition(desiredSliderPosition));
		this._sliderMouseDown(e);
	}
開發者ID:yxbdali,項目名稱:vscode,代碼行數:6,代碼來源:abstractScrollbar.ts


注:本文中的vs/base/browser/dom.getDomNodePosition函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。