Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
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
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
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.