Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
dom-scroll-into-view
Advanced tools
The 'dom-scroll-into-view' npm package provides utilities to smoothly scroll a DOM element into view within its container. It offers customizable options to control the alignment and behavior of the scrolling action.
Basic Scroll Into View
This feature allows you to scroll a specific DOM element into view within its container. The example demonstrates how to scroll an element with the ID 'targetElement' into view within the document body.
const scrollIntoView = require('dom-scroll-into-view');
const element = document.getElementById('targetElement');
scrollIntoView(element, document.body);
Custom Alignment
This feature allows you to customize the alignment of the element when it is scrolled into view. The example shows how to align the element with the top of the container.
const scrollIntoView = require('dom-scroll-into-view');
const element = document.getElementById('targetElement');
scrollIntoView(element, document.body, { alignWithTop: true });
Smooth Scrolling
This feature enables smooth scrolling when bringing an element into view. The example demonstrates how to scroll the element smoothly into view within the document body.
const scrollIntoView = require('dom-scroll-into-view');
const element = document.getElementById('targetElement');
scrollIntoView(element, document.body, { behavior: 'smooth' });
The 'scroll-into-view-if-needed' package provides similar functionality to 'dom-scroll-into-view' but with additional options for controlling the scrolling behavior. It offers more granular control over when and how the scrolling should occur, including options for center alignment and ensuring the element is fully visible.
The 'smooth-scroll-into-view-if-needed' package extends the functionality of 'scroll-into-view-if-needed' by adding smooth scrolling capabilities. It provides a more modern and user-friendly scrolling experience, similar to 'dom-scroll-into-view' but with enhanced smooth scrolling options.
scroll node in contain to make node visible
import scrollIntoView from 'dom-scroll-into-view';
scrollIntoView(source,container,config);
npm install
npm start
http://localhost:8000/examples/
online example: http://yiminghe.github.io/dom-scroll-into-view/
name | type | default | description |
---|---|---|---|
source | HTMLElement | node wanted to show | |
container | HTMLElement | ||
config.alignWithLeft | Boolean | whether align with left edge | |
config.alignWithTop | Boolean | whether align with top edge | |
config.offsetTop | Number | ||
config.offsetLeft | Number | ||
config.offsetBottom | Number | ||
config.offsetRight | Number | ||
config.allowHorizontalScroll | Boolean | whether allow horizontal scroll container | |
config.onlyScrollIfNeeded | Boolean | whether scroll container when source is visible |
dom-scroll-into-view is released under the MIT license.
FAQs
scroll dom node into view automatically
The npm package dom-scroll-into-view receives a total of 256,956 weekly downloads. As such, dom-scroll-into-view popularity was classified as popular.
We found that dom-scroll-into-view demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.