![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
@uvarov.frontend/vanilla-sticky
Advanced tools
Vanilla JS sticky block without using extra packages.
Vanilla JS sticky block without using extra packages. DEMO
Get vanilla-sticky in one of the following ways:
npm install @uvarov.frontend/vanilla-sticky
Then import it in your javascript file
import VanillaSticky from '@uvarov.frontend/vanilla-sticky';
It’s possible to manually include the necessary <script>
tags in the end body of your HTML page and then initialize a calendar via browser globals.
CDN
<script src="https://cdn.jsdelivr.net/npm/@uvarov.frontend/vanilla-sticky@1.0.0/vanilla-sticky.min.js"></script>
or locally
<script src="./js/vanilla-sticky.min.js"></script>
The HTMLElement
option is mandatory, all other options are optional.
Name | Default | Description |
---|---|---|
HTMLElement | — | DOM object |
position | auto | Specifies which edge the block will stick to. Available options: 'auto', 'top', 'bottom'. |
stretch | true | Stretch the content to the full height of the screen minus the indents if the content is less than the height of the screen. |
resize | true | Recalculate the height of the content and its location each time the screen height changes. |
indents.top | 0 | Specify the top indents after which the block will stick. |
indents.bottom | 0 | Specify the bottom indents after which the block will stick. |
window.min | null | The minimum screen width after which the module stops working. |
window.max | null | The maximum screen width after which the module stops working. |
const sidebar = new VanillaSticky({
HTMLElement: document.querySelector('.sidebar'),
position: 'bottom',
stretch: false,
resize: true,
indents: {
top: 70,
bottom: 10,
},
window: {
min: 1200,
max: null,
},
});
sidebar.init();
Change settings and update:
sidebar.position = 'top';
sidebar.stretch = true;
sidebar.indents.top = 30;
sidebar.indents.bottom = 20;
sidebar.update();
MIT License
Yuri Uvarov (uvarov.frontend@gmail.com)
FAQs
Vanilla JS sticky block without using extra packages.
The npm package @uvarov.frontend/vanilla-sticky receives a total of 2 weekly downloads. As such, @uvarov.frontend/vanilla-sticky popularity was classified as not popular.
We found that @uvarov.frontend/vanilla-sticky 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
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.