All Projects → somewebmedia → Hc Sticky

somewebmedia / Hc Sticky

Licence: mit
JavaScript library that makes any element on your page visible while you scroll.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Hc Sticky

Jquery Scrolllock
Locks mouse wheel scroll inside container, preventing it from propagating to parent element
Stars: ✭ 109 (-70.93%)
Mutual labels:  jquery-plugin, scroll, jquery
Footer Reveal
A jQuery plugin for easy implementation of the 'fixed/reveal' footer effect. Demo here:
Stars: ✭ 111 (-70.4%)
Mutual labels:  jquery-plugin, scroll, jquery
Stickyfloat
This plugin makes it possible to have a fixed position element that is relative to it’s parent. A normal fixed positioned element would be “out of context” and is very difficult to use in the most common situations with fluid designs. This plugin solves that problem with as little code as I could possible get it so it will run in the most optimized way, while also allow you to customize it in many important ways which might suit you best.
Stars: ✭ 166 (-55.73%)
Mutual labels:  jquery-plugin, sticky, jquery
Preloadme
PreLoadMe, a lightweight jQuery website preloader.
Stars: ✭ 272 (-27.47%)
Mutual labels:  jquery-plugin, jquery
Email Autocomplete
A jQuery plugin that suggests and autocompletes the domain in email fields.
Stars: ✭ 265 (-29.33%)
Mutual labels:  jquery-plugin, jquery
Colorpicker
jQuery UI widget for color picking (similar to the one in Microsoft Office 2010).
Stars: ✭ 271 (-27.73%)
Mutual labels:  jquery-plugin, jquery
scrollbox
A lightweight jQuery custom scrollbar plugin, that triggers event when reached the defined point.
Stars: ✭ 15 (-96%)
Mutual labels:  jquery-plugin, scroll
Stickystack.js
A jQuery plugin that creates a stacking effect by sticking panels as they reach the top of the viewport.
Stars: ✭ 287 (-23.47%)
Mutual labels:  jquery-plugin, jquery
Sidr
Sidr is a jQuery plugin for creating side menus and the easiest way for doing your menu responsive.
Stars: ✭ 2,924 (+679.73%)
Mutual labels:  jquery-plugin, jquery
Texttailor.js
jQuery plugin, tailor made text to fill the height of the parent element or ellipse it if it doesn't fit
Stars: ✭ 291 (-22.4%)
Mutual labels:  jquery-plugin, jquery
Jquery.scrollto
Lightweight, cross-browser and highly customizable animated scrolling with jQuery
Stars: ✭ 3,609 (+862.4%)
Mutual labels:  scroll, jquery
Protip
A new generation jQuery Tooltip plugin
Stars: ✭ 357 (-4.8%)
Mutual labels:  jquery-plugin, jquery
Jquery Tablesort
A tiny & dead-simple jQuery plugin for sortable tables.
Stars: ✭ 254 (-32.27%)
Mutual labels:  jquery-plugin, jquery
Js Offcanvas
A lightweight, flexible jQuery off-canvas navigation plugin which lets you create fully accessible sidebar or top/bottom sliding (or push) panels with keyboard interactions and ARIA attributes.
Stars: ✭ 272 (-27.47%)
Mutual labels:  jquery-plugin, jquery
NoobScroll
A lightweight jQuery Plugin that add some cool function to make scrolling more fun [Archive]
Stars: ✭ 43 (-88.53%)
Mutual labels:  jquery-plugin, scroll
Sticky Kit
A jQuery plugin for creating smart sticky elements
Stars: ✭ 2,961 (+689.6%)
Mutual labels:  jquery-plugin, jquery
Tweetie
Simple jQuery Twitter feed plugin
Stars: ✭ 314 (-16.27%)
Mutual labels:  jquery-plugin, jquery
Jquery Loading
Easily add and manipulate loading states of any element on the page.
Stars: ✭ 321 (-14.4%)
Mutual labels:  jquery-plugin, jquery
Datetimepicker
jQuery Plugin Date and Time Picker
Stars: ✭ 3,402 (+807.2%)
Mutual labels:  jquery-plugin, jquery
Ziptastic Jquery Plugin
This is a jQuery plugin that shows how Ziptastic could be used.
Stars: ✭ 244 (-34.93%)
Mutual labels:  jquery-plugin, jquery

HC-Sticky

Version Downloads

JavaScript library that makes any element on your page visible while you scroll. Dependency free, but lso works as a jQuery plugin. Check out the demos.

Quick start

Install

This package can be installed with:

  • npm: npm install --save hc-sticky

Or download the latest release.

Including HC-Sticky

Script tag

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

Webpack/Browserify

In the script, including HC-Sticky will usually look like this:

const hcSticky = require('hc-sticky');

Babel

import hcSticky from 'hc-sticky';

AMD (Asynchronous Module Definition)

If using AMD, the module will be automatically defined as hcSticky.

Usage

Be sure to call HC-Sticky once your element is available in the DOM.

Vanilla JS

document.addEventListener('DOMContentLoaded', function() {

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

});

jQuery

jQuery(document).ready(function($) {

  $('#element').hcSticky({
    stickTo: $('#content')[0]
  });

});

For HC-Sticky to work as a jQuery plugin, jQuery has to be a property of global window object, so be careful when using it in compbination with Babel/Webpack/Browserify and jQuery.

Options

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

Property Default Type Description
top 0 int The distance from the top of the Window at which to trigger HC-Sticky.
bottom 0 int The distance from the bottom of the Window at which to attach HC-Sticky.
innerTop 0 int The distance from the top inside of the sticky element at which to trigger HC-Sticky.
innerSticker null string / element object Element inside of the sticky element at which to attach HC-Sticky. This has higher priority than innerTop option.
bottomEnd 0 int The distance from the bottom of the referring element at which to stop HC-Sticky.
stickTo null (parent element) string / element object Element that represents the reference for height instead of height of the container.
followScroll true boolean When set to false, sticky content will not move with the page if it is bigger than Window.
stickyClass 'sticky' string HTML class that will be applied to sticky element while it is attached.
responsive null object Object containing responsive breakpoints, on which you can tell HC Sticky what to do.
mobileFirst false boolean Direction of the responsive queries.
disable false boolean Disable the plugin. Usualy used with responsive object.
onStart null function Callback function fired when the element becomes attached.
onStop null function Callback function fired when the element stops floating.
onBeforeResize null function Callback function fired before sticky has been resized (happens after Window resize and before sticky reinit).
onResize null function Callback function fired after sticky has been resized (happens after Window resize and sticky reinit).
resizeDebounce 100 int Limit the rate at which the HC Sticky can fire on window resize.

More on how to use the responsive object here.

Methods

Methods are used to control the plugin after initialization.

Method Accepts Description
options string Returns current settings, or a specific setting if you specify it.
update object Updates the settings with the new ones.
refresh N/A Recalculates sticky size and position. Useful after altering DOM elements inside sticky.
detach N/A Detaches the HC-Sticky from element, preventing it from running.
attach N/A Attaches the HC-Sticky back to the element.
destroy N/A Completely destroys HC-Sticky and reverts element to original state.

Vanilla JS

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

Sticky.update({
  top: 20
});

jQuery

var $sticky = $('#element');

$sticky.hcSticky({
  stickTo: '#content'
});

$sticky.hcSticky('update', {
  top: 20
});

Dev Building

This package comes with Gulp. The following tasks are available:

  • default compiles the JS into /dist and builds the Demos into /docs.
  • watch watches source JS and Demo files and builds them automatically whenever you save.

You can pass a --dev command if you don't want the compiled JS to be minified.

License

The code and the documentation are released under the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].