npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ember-sliding-sticky

v1.0.0

Published

A `position: sticky` alternative that works inside parents with `overflow: hidden`

Downloads

7

Readme

ember-sliding-sticky

Ember Observer Score npm package version license MIT ember-versions 1.13+ node-versions 4+ ember-cli 2.12.1

A drop-in implementation for sticky elements. By default, uses transform: translate3d(0, Npx, 0) to position sticky elements.

Pros

  • Very easy to use.
  • Works correctly and naturally with sticky elements taller than viewport.
  • Works both with window scrolling and custom element scrolling.
  • Unlike position: sticky, works fine inside parents that have overflow and/or transform.
  • Thanks to not using position: fixed, when your scroll container is shorter than viewport and the sticky element is taller, the sticky element never overflows out of parent.
  • Allows for a sliding animation. Just enable throttling and apply transition: transform 0.5s ease to your sticky element.

Cons

  • Only one sticky element per column.
  • Customizing offset is not supported yet. PRs welcome!
  • For the sticky element to appear fixed, throttling must be disabled. This may cause two issues (the effect gets worse on slower systems and when there are many sticky elements on the page):
    • Scrolling may be laggy on slow systems.
    • The sticky element may jitter slightly.
  • Only respects one scroll container. If you have a scrolling container inside a scrolling container, you can only tell a sticky element to align according to the inner container's scrolling. But that's a very rare case.
  • Relies on jQuery.

Restrictions

Requires a sticky element to be initially located at the top of its immediate parent, so that the whole parent's inner height is available for the sticky element to roam.

One possible way to achieve this is to apply the following CSS to the immediate parent of the sticky element:

display:     flex;
align-items: flex-start;

Demo

https://github.com/Deveo/ember-sliding-sticky/graphs/contributors

Installation

With npm: ember i ember-sticky-container

With Yarn: yarn add -D ember-sticky-container

Quickstart

In a template, replace an HTML element you want to be sticky with the sliding-sticky component.

Before:

<div>My sidebar</div>

After:

{{#sliding-sticky}}
  My sidebar
{{/sliding-sticky}}

Alternatively, you can apply the sliding sticky mixin to your components:

import Component from 'ember-component'
import SlidingStickyMixin from 'ember-sliding-sticky/mixin'

export default Component.extend(SlidingStickyMixin, {
  // ...
})

Animating sticky elements

By applying transition: transform 0.5s ease CSS to your sticky elements, you can make them appear static while you're scrolling, but when you stop scrolling, the elements smoothly slide back into view.

If you go for this effect, it's highly recommended to enable throttling (see below), it will prevent scrolling from appear laggy on slow systems. Throttling is disabled by default because without animation it causes the sticky element to jitter.

Available options

| Option | Type | Default value | Description | |:--------------------------------|:--------------------------------------------------|:--------------|:---------------------------------------------------------------------------------------------------------------------------| | slidingStickyScrollParent | selector string, DOM element or jQuery collection | window | Which scroll container to use. | | slidingStickyThrottleDuration | Number | 0 | Throttle duration in milliseconds. 0 disables throttling. Set to 100 or so if you're using the transition animation. |

Overridable methods

| Option | Arguments | Description | |:-----------------------------|:--------------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------| | slidingStickyApplyPosition | positionPx (number of pixels) | Lets you customize the way the element is positioned. By default, applies transform: translate3d(0, Npx, 0) inline CSS to the element. | | slidingStickyTransitionEnd | none | Lets you react when the element finishes positioning. This is only useful when you apply transition: transform to the element. |

Credit

Proudly built in @Deveo by @lolmaus and contributors.

https://deveo.com

License

MIT