Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hc-sticky

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hc-sticky

Cross-browser plugin that makes any element on your page visible while you scroll

  • 2.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.4K
decreased by-6.23%
Maintainers
1
Weekly downloads
 
Created
Source

HC-Sticky

Cross-browser plugin that makes any element on your page visible while you scroll.

Usage

<script src="/path/to/hc-sticky.js"></script>

<script>
  // call this script just before closing </html> or after your #element
  var Sticky = new hcSticky('#element', {
    stickTo: '#content'
  });
</script>

jQuery

<script src="/path/to/hc-sticky.js"></script>

<script>
  jQuery(document).ready(function($) {
    $('#element').hcSticky({
      stickTo: '#content'
    });
  });
</script>

Options

HC Sticky has a wide range of options you can set to have a full controll over the sticky elements.

PropertyDefaultTypeDescription
top0intThe distance from the top of the Window at which to trigger HC-Sticky.
bottom0intThe distance from the bottom of the Window at which to attach HC-Sticky.
innerTop0intThe distance from the top inside of the sticky element at which to trigger HC-Sticky.
innerStickernullstring / element objectElement inside of the sticky element at which to attach HC-Sticky. This has higher priority than innerTop option.
bottomEnd0intThe distance from the bottom of the referring element at which to stop HC-Sticky.
stickTonull (parent element)string / element objectElement that represents the reference for height instead of height of the container.
followScrolltruebooleanWhen set to false, sticky content will not move with the page if it is bigger than Window.
stickyClass'sticky'stringHTML class that will be applied to sticky element while it is attached.
queriesnullobjectObject containing responsive breakpoints, on which you can tell HC Sticky what to do.
onStartnullfunctionCallback function fired when the element becomes attached.
onStopnullfunctionCallback function fired when the element stops floating.
onBeforeResizenullfunctionCallback function fired before sticky has been resized (happens after Window resize and before sticky reinit).
onResizenullfunctionCallback function fired after sticky has been resized (happens after Window resize and sticky reinit).
resizeDebounce100intLimit the rate at which the HC Sticky can fire on window resize.

Methods

Methods are used to control the plugin after initialization.

Example:

var Sticky = new hcSticky('#element', {
  stickTo: '#content'
});

Sticky.update({
  top: 20
});
MethodAcceptsDescription
optionsstringReturns current settings, or a specific setting if you specify it.
updateobjectUpdates the settings with the new ones.
reinitRecalculates sticky size and position. Useful after altering DOM elements inside sticky.
detachDetaches the HC-Sticky from element, preventing it from running.
attachAttaches the HC-Sticky back to the element.
destroyCompletely destroys HC-Sticky and reverts element to original state.

FAQs

Package last updated on 29 Nov 2017

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