_handleTooltipRendered() {
		const {tooltipSource, tooltipTarget} = this.refs;
		const {element} = tooltipSource;
		const suggestedPosition = Align.align(element, tooltipTarget, Align.Right);

		this.position = POSITIONS[suggestedPosition];
	}
示例#2
0
	/**
	 * Synchronization logic for `expanded` state.
	 * @param {boolean} expanded
	 */
	syncExpanded(expanded) {
		if (expanded && this.alignElementSelector) {
			var alignElement = this.element.querySelector(this.alignElementSelector);
			if (alignElement) {
				var bodyElement = this.element.querySelector('.dropdown-menu');
				this.alignedPosition = Align.align(bodyElement, alignElement, this.position);
			}
		}
	}
示例#3
0
 /**
  * Validator for the `position` state.
  * @param {string|number} position
  * @return {boolean}
  * @protected
  */
 validatePosition_(position) {
   if (Align.isValidPosition(position)) {
     return true;
   }
   switch (position.toLowerCase()) {
   case 'up':
   case 'down':
     return true;
   default:
     return false;
   }
 }
示例#4
0
const getAlignPosition = (source, target, suggestedPosition) => {
	if (!suggestedPosition) {
		suggestedPosition = Align.TopCenter;
	}

	const position = Align.align(source, target, suggestedPosition);

	let returnedPositon = POSITIONS[position];

	if (!returnedPositon) {
		returnedPositon = 'left';
	}

	return returnedPositon;
};
示例#5
0
	/**
	 * Aligns main element to the input element.
	 */
	align() {
		this.element.style.width = this.inputElement.offsetWidth + 'px';
		var position = Align.align(this.element, this.inputElement, Align.Bottom, this.autoBestAlign);

		dom.removeClasses(this.element, this.positionCss_);
		switch (position) {
			case Align.Top:
			case Align.TopLeft:
			case Align.TopRight:
				this.positionCss_ = 'autocomplete-top';
				break;
			case Align.Bottom:
			case Align.BottomLeft:
			case Align.BottomRight:
				this.positionCss_ = 'autocomplete-bottom';
				break;
			default:
				this.positionCss_ = null;

		}
		dom.addClasses(this.element, this.positionCss_);
	}