tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

result-list.js (767B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
      4 
      5 export function scrollList(resultList, index) {
      6  if (!resultList.hasOwnProperty(index)) {
      7    return;
      8  }
      9 
     10  const resultEl = resultList[index];
     11 
     12  const scroll = () => {
     13    // Avoid expensive DOM computations involved in scrollIntoView
     14    // https://nolanlawson.com/2018/09/25/accurately-measuring-layout-on-the-web/
     15    requestAnimationFrame(() => {
     16      setTimeout(() => {
     17        if (!resultEl.scrollIntoView) {
     18          return;
     19        }
     20        resultEl.scrollIntoView({ block: "nearest", behavior: "auto" });
     21      });
     22    });
     23  };
     24 
     25  scroll();
     26 }