MCPcopy Index your code
hub / github.com/d-oliveros/ngSticky

github.com/d-oliveros/ngSticky @v1.8.13

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.8.13 ↗ · + Follow
22 symbols 52 edges 3 files 16 documented · 73% updated 9y agov1.7.8 · 2015-01-12★ 35063 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Angular Sticky

A simple, pure javascript (No jQuery required!) AngularJS directive to make elements stick when scrolling down.

Features

  • Allows use of an offset so elements can be stuck to eg. 50px from the top of the browser
  • Recalculates element position on page load and on window resize
  • Clean: No external CSS or jQuery required, and it only adds the classes you specify.

Bower

Install with bower:

bower install ngSticky

Usage

Include the .js file in your page then enable usage of the directive by including the "sticky" module as a dependency. Use the directive as follows:

Hey there!

To toggle the element stickiness you can bind with scope using the disabled-sticky (ng-model) as follows {{ disabled = true }}:

I won't stick!

I will stick!

To make the element stick within a certain offset of the top of the screen, you can provide an offset as follows:

I won't touch the top of your screen!

By default the element will be replaced with a place holder to prevent DOM resizing. This can be disabled as follows:

I won't be replaced!

If you want to customize the style while the element is sticky, we have an api for you too:

Taste my glue!

And if you want to customize the body style while the element is sticky:

Taste my glue!

And if you want to add in a class when the element is confined and bottomed out:

Taste my glue!

It's also possible to set styles specifically for non sticky element:

In order to enable sticky based on a media query:

Won't be sticky on small screens!

If you want the sticky element to be scrollable only if it's smaller then the window inner height then you can set the stick-limit attribute:

Will stick only if the element isn't bigger then the view

And if you want to confine an element to its parent, and let it 'bottom out', just add the confine attribute:

Will unstick and stick to bottom of parent element

NOTE: The confine attribute will automagically assign its parent a position: relative style in order to help with absolute positioning relative to the parent.

If you'd like to use an element's overflow-y instead of the window scrollbar. You can use the "sticky-scroll" element to denote an element styled to handle this.

<sticky-scroll style="overflow-y: scroll;min-height: 1000px;display: block;">

Will stick to element, instead of window scrollbar.

</sticky-scroll>

NOTE: This doesn't work for bottomed out or position absolute elements.

Development

To start the development server:

npm run examples
// Then go to localhost:8080

To create the minified dist/sticky.min.js file, run:

npm run build

Cheers.

Core symbols most depended-on inside this repo

elementsOffsetFromTop
called by 7
lib/sticky.js
unStickElement
called by 6
lib/sticky.js
scrollbarYPos
called by 5
lib/sticky.js
checkIfShouldStick
called by 3
lib/sticky.js
initSticky
called by 2
lib/sticky.js
createPlaceholder
called by 2
lib/sticky.js
memorizeDimensions
called by 1
lib/sticky.js
deriveScrollingViewport
called by 1
lib/sticky.js

Shape

Function 22

Languages

TypeScript100%

Modules by API surface

lib/sticky.js22 symbols

For agents

$ claude mcp add ngSticky \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact