Socket
Socket
Sign inDemoInstall

compute-scroll-into-view

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

compute-scroll-into-view

The engine that powers scroll-into-view-if-needed


Version published
Weekly downloads
4.7M
decreased by-3.66%
Maintainers
1
Weekly downloads
 
Created

What is compute-scroll-into-view?

The compute-scroll-into-view npm package is a utility that calculates the scroll position necessary to make an element visible within its container. This is useful for smoothly scrolling items into view, especially in custom scrolling interfaces where the default browser behavior does not suffice.

What are compute-scroll-into-view's main functionalities?

Compute scroll position

This feature calculates the necessary scroll positions to bring an element into view within its container. The function returns an array of actions that can be applied to achieve the desired scroll effect. Each action specifies the element to scroll and the new top and left scroll positions.

import computeScrollIntoView from 'compute-scroll-into-view';
const element = document.getElementById('targetElement');
const actions = computeScrollIntoView(element, {
  scrollMode: 'if-needed',
  block: 'nearest',
  inline: 'nearest'
});
actions.forEach(({ el, top, left }) => {
  el.scrollTop = top;
  el.scrollLeft = left;
});

Other packages similar to compute-scroll-into-view

Keywords

FAQs

Package last updated on 10 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc