szn-options.js
function scrollToOption(instance, optionIndex) {
    const ui = instance._root
    if (ui.clientHeight >= ui.scrollHeight) {
      return
    }

    const uiBounds = ui.getBoundingClientRect()
    const options = instance._root.querySelectorAll('[data-szn-options--option]')
    const optionBounds = options[optionIndex].getBoundingClientRect()
    if (optionBounds.top >= uiBounds.top && optionBounds.bottom <= uiBounds.bottom) {
      return
    }

    const delta = optionBounds.top < uiBounds.top ?
      optionBounds.top - uiBounds.top
      :
      optionBounds.bottom - uiBounds.bottom
    ui.scrollTop += delta
  }
function scrollToOption(instance, optionIndex) {
    const ui = instance._root
    if (ui.clientHeight >= ui.scrollHeight) {
      return
    }

    const uiBounds = ui.getBoundingClientRect()
    const options = instance._root.querySelectorAll('[data-szn-options--option]')
    const optionBounds = options[optionIndex].getBoundingClientRect()
    if (optionBounds.top >= uiBounds.top && optionBounds.bottom <= uiBounds.bottom) {
      return
    }

    const delta = optionBounds.top < uiBounds.top ?
      optionBounds.top - uiBounds.top
      :
      optionBounds.bottom - uiBounds.bottom
    ui.scrollTop += delta
  }
function scrollToOption ( instance , optionIndex ) { const ui = instance . _root if ( ui . clientHeight >= ui . scrollHeight ) { return } const uiBounds = ui . getBoundingClientRect ( ) const options = instance . _root . querySelectorAll ( '[data-szn-options--option]' ) const optionBounds = options [ optionIndex ] . getBoundingClientRect ( ) if ( optionBounds . top >= uiBounds . top && optionBounds . bottom <= uiBounds . bottom ) { return } const delta = optionBounds . top < uiBounds . top ? optionBounds . top - uiBounds . top : optionBounds . bottom - uiBounds . bottom ui . scrollTop += delta }
Scrolls, only if necessary, the UI of the provided szn-options element to make the option at the specified index
fully visible.

@param {SznElements.SznOptions} instance The szn-options element instance.
@param {number} optionIndex The index of the option to select. The index must be a non-negative integer and cannot
be greater than the total number of options.
Scrolls only if necessary the UI of the provided szn - options element to make the option at the specified index fully visible .