How to use the ember-power-select/utils/group-utils.indexOfOption function in ember-power-select

To help you get started, we’ve selected a few ember-power-select examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github miguelcobain / ember-paper / addon / components / paper-autocomplete.js View on Github external
scrollTo(option) {
      if (!document || !option) {
        return;
      }
      let publicAPI = this.get('publicAPI');
      let optionsList = document.getElementById(`ember-power-select-options-${publicAPI.uniqueId}`);

      if (!optionsList) {
        return;
      }

      let index = indexOfOption(publicAPI.results, option);
      if (index === -1) {
        return;
      }
      // Update the scroll index
      this.updateState({ scrollIndex: index });
    }
  }
github miguelcobain / ember-paper / addon / components / paper-autocomplete / component.js View on Github external
scrollTo(option, select) {
    let optionsList = document.getElementById(`ember-power-select-options-${this.publicAPI.uniqueId}`);
    if (!optionsList) {
      return;
    }

    optionsList = optionsList.parentNode;

    let index = indexOfOption(select.results, option);
    if (index === -1) {
      return;
    }

    let optionElement = optionsList.querySelector(`[data-option-index="${index}"]`);
    if (!optionElement) {
      return;
    }

    let optionTopScroll = optionElement.offsetTop;
    let optionBottomScroll = optionTopScroll + optionElement.offsetHeight;

    if (optionBottomScroll > optionsList.offsetHeight + optionsList.scrollTop) {
      optionsList.scrollTop = optionBottomScroll - optionsList.offsetHeight;
    } else if (optionTopScroll < optionsList.scrollTop) {
      optionsList.scrollTop = optionTopScroll;
github miguelcobain / ember-paper / addon / components / paper-select-menu-inner.js View on Github external
function advanceSelectableOption(options, currentOption, step) {
  let resultsLength = countOptions(options);
  let startIndex = Math.min(Math.max(indexOfOption(options, currentOption) + step, 0), resultsLength - 1);
  let { disabled, option } = optionAtIndex(options, startIndex);
  while (option && disabled) {
    let next = optionAtIndex(options, startIndex += step);
    disabled = next.disabled;
    option = next.option;
  }
  return option;
}