New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@uvarov.frontend/vanilla-sticky

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@uvarov.frontend/vanilla-sticky

Vanilla JS sticky block without using extra packages.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

Vanilla JS Sticky v1.0.0

Vanilla JS sticky block without using extra packages. DEMO

Initialize

Get vanilla-sticky in one of the following ways:

NPM

npm install @uvarov.frontend/vanilla-sticky

Then import it in your javascript file

import VanillaSticky from '@uvarov.frontend/vanilla-sticky';

or Script tag

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>

API

The HTMLElement option is mandatory, all other options are optional.

NameDefaultDescription
HTMLElementDOM object
positionautoSpecifies which edge the block will stick to. Available options: 'auto', 'top', 'bottom'.
stretchtrueStretch the content to the full height of the screen minus the indents if the content is less than the height of the screen.
resizetrueRecalculate the height of the content and its location each time the screen height changes.
indents.top0Specify the top indents after which the block will stick.
indents.bottom0Specify the bottom indents after which the block will stick.
window.minnullThe minimum screen width after which the module stops working.
window.maxnullThe maximum screen width after which the module stops working.

Usage example

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();

License

MIT License

Author

Yuri Uvarov (uvarov.frontend@gmail.com)

Keywords

FAQs

Package last updated on 14 Jun 2022

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