maybeScrollItemIntoView: function maybeScrollItemIntoView() {
   if (this.state.isOpen === true && this.state.highlightedIndex !== null) {
     var itemNode = this.refs['item-' + this.state.highlightedIndex];
     var menuNode = this.refs.menu;
     scrollIntoView(itemNode, menuNode, { onlyScrollIfNeeded: true });
   }
 },
Example #2
0
				this.props.setTimeout( () => {
					// We need a generic way to access the panel's container
					// eslint-disable-next-line react/no-find-dom-node
					scrollIntoView( findDOMNode( this.panels[ panel ] ), this.inserterResults.current, {
						alignWithTop: true,
					} );
				} );
Example #3
0
$('#scrollIntoView')[0].onclick = () => {
  scrollIntoView($('#ex1')[0], $('#container')[0], {
    alignWithLeft: transformValue($('#alignWithLeft').val()),
    alignWithTop: transformValue($('#alignWithTop').val()),
    allowHorizontalScroll: transformValue($('#allowHorizontalScroll').val()),
    onlyScrollIfNeeded: transformValue($('#onlyScrollIfNeeded').val()),
    offsetTop: parseInt($('#offsetTop').val()) || 0,
    offsetLeft: parseInt($('#offsetLeft').val()) || 0,
  });
};
Example #4
0
 maybeScrollItemIntoView() {
   if (this.state.isOpen === true && this.state.highlightedIndex !== null) {
     const itemNode = this.refs[`item-${this.state.highlightedIndex}`];
     const menuNode = this.refs.menu;
     if (itemNode) {
       scrollIntoView(
         findDOMNode(itemNode),
         findDOMNode(menuNode),
         { onlyScrollIfNeeded: true },
       );
     }
   }
 }
	componentDidUpdate() {
		// only have to worry about scrolling selected suggestion into view
		// when already expanded
		if ( this.props.selectedIndex > -1 && this.props.scrollIntoView ) {
			this.scrollingIntoView = true;
			scrollIntoView( this.list.children[ this.props.selectedIndex ], this.list, {
				onlyScrollIfNeeded: true,
			} );

			setTimeout( () => {
				this.scrollingIntoView = false;
			}, 100 );
		}
	}
Example #6
0
	componentDidUpdate() {
		const { showSuggestions, selectedSuggestion } = this.state;
		// only have to worry about scrolling selected suggestion into view
		// when already expanded
		if ( showSuggestions && selectedSuggestion !== null && ! this.scrollingIntoView ) {
			this.scrollingIntoView = true;
			scrollIntoView( this.suggestionNodes[ selectedSuggestion ], this.listNode, {
				onlyScrollIfNeeded: true,
			} );

			setTimeout( () => {
				this.scrollingIntoView = false;
			}, 100 );
		}
	}
Example #7
0
  this.scrollActiveItemToView = function () {
    // scroll into view
    var itemComponent = findDOMNode(_this3.firstActiveItem);
    var props = _this3.props;

    if (itemComponent) {
      var scrollIntoViewOpts = {
        onlyScrollIfNeeded: true
      };
      if ((!props.value || props.value.length === 0) && props.firstActiveValue) {
        scrollIntoViewOpts.alignWithTop = true;
      }

      scrollIntoView(itemComponent, findDOMNode(_this3.menuRef), scrollIntoViewOpts);
    }
  };
Example #8
0
	/**
	 * Ensures that if a multi-selection exists, the extent of the selection is
	 * visible within the nearest scrollable container.
	 *
	 * @return {void}
	 */
	scrollIntoView() {
		const { extentClientId } = this.props;
		if ( ! extentClientId ) {
			return;
		}

		const extentNode = getBlockDOMNode( extentClientId );
		if ( ! extentNode ) {
			return;
		}

		const scrollContainer = getScrollContainer( extentNode );

		// If there's no scroll container, it follows that there's no scrollbar
		// and thus there's no need to try to scroll into view.
		if ( ! scrollContainer ) {
			return;
		}

		scrollIntoView( extentNode, scrollContainer, {
			onlyScrollIfNeeded: true,
		} );
	}
Example #9
0
 _this.rafInstance = raf(function () {
   scrollIntoView(itemComponent, findDOMNode(_this.menuRef), scrollIntoViewOpts);
 });
Example #10
0
    if (this.state.isOpen && this._performAutoCompleteOnUpdate) {
      this._performAutoCompleteOnUpdate = false
      this.maybeAutoCompleteText()
    }

    this.maybeScrollItemIntoView()
  },

  maybeScrollItemIntoView () {
    if (this.state.isOpen === true && this.state.highlightedIndex !== null) {
      var itemNode = this.refs[`item-${this.state.highlightedIndex}`]
      var menuNode = this.refs.menu
      scrollIntoView(
        findDOMNode(itemNode),
        findDOMNode(menuNode),
        { onlyScrollIfNeeded: true }
      )
    }
  },

  handleKeyDown (event) {
    if (this.keyDownHandlers[event.key])
      this.keyDownHandlers[event.key].call(this, event)
    else {
      const { selectionStart, value } = event.target
      if (value === this.props.value)
        // Nothing changed, no need to do anything. This also prevents
        // our workaround below from nuking user-made selections
        return
      this.setState({
    if (this.state.isOpen === true && prevState.isOpen === false)
      this.setMenuPositions()

    if (this.state.isOpen && this._performAutoCompleteOnUpdate) {
      this._performAutoCompleteOnUpdate = false
      this.maybeAutoCompleteText()
    }

    this.maybeScrollItemIntoView()
  },

  maybeScrollItemIntoView () {
    if (this.state.isOpen === true && this.state.highlightedIndex !== null) {
      var itemNode = this.refs[`item-${this.state.highlightedIndex}`]
      var menuNode = this.refs.menu
      scrollIntoView(itemNode, menuNode, { onlyScrollIfNeeded: true })
    }
  },

  handleKeyDown (event) {
    if (this.keyDownHandlers[event.key])
      this.keyDownHandlers[event.key].call(this, event)
    else {
      const { selectionStart, value } = event.target
      if (value === this.state.value)
        // Nothing changed, no need to do anything. This also prevents
        // our workaround below from nuking user-made selections
        return
      this.setState({
        highlightedIndex: null,
        isOpen: true