sp

@danielr1996/sticky-polyfill

A VanillaJS Polyfill for position: sticky;

Showing:

Popularity

Downloads/wk

0

Maintenance

No Maintenance Data Available

Package

Dependencies

0

License

WTFPL

Type Definitions

Tree-Shakeable

No?

Categories

Readme

About

This library is a VanillaJS polyfill for the CSS Attribute position: sticky

Usage

Angular (Angular2+)

First include the script in .angular-cli.json so it gets added to your build with ng build ...

{ "glob": "**/*", "input": "../node_modules/@danielr1996/sticky-polyfill/dist", "output": "./assets/js/sticky-polyfill/" }

... and include the script in index.html

<script src="/assets/js/sticky-polyfill/sticky-polyfill.min.js"></script>

Then you need to call the sticky-polyfill library after the desired element is initialized (AfterViewInit hook in AppComponent should always work, but you can also choose the component where your desired element is used). You can use any valid CSS Selector (https://developer.mozilla.org/de/docs/Web/API/Document/querySelector);

export class AppComponent implements AfterViewInit {
  ngAfterViewInit(): void {
    sticky('nav');
  }
}

and add this to the top of your component so TypeScript doesn't complain that sticky is unknown (it is added to the window object)

declare var sticky;

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial