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-scroll-box

v1.2.1

Published

A component providing scroll css hooks and actions.

Downloads

14

Readme

Ember-scroll-box Build Status

A scroll-box provides CSS hooks that allow styling when the content is scrolled to the top or bottom and triggers actions at configurable scroll thresholds. The component has been designed with performance in mind and as such throttles its scroll handling. All functionality is covered by a suite of tests.

How to install

ember install ember-scroll-box

Using the CSS hooks to style shadows/indicators

Given a scroll-box with some content:

Template:

{{#scroll-box class="my-container"}}
  {{#each items as |item|}}
    <div>Some repeated content</div>
  {{/each}}
{{/scroll-box}}

CSS:

.my-container {
  height: 100px;
}

When the content is scrolled to the top the .scroll-box--at-top class will be present and... when the content is scrolled to the bottom the .scroll-box--at-bottom class will be present.

The following CSS can be applied to show shadows at the top and bottom when content overflows (including a fancy transition for when the shadows appears/disappears):

.scroll-box {
  overflow: hidden;
}
.scroll-box_body {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  overflow: auto;
}
.scroll-box::before,
.scroll-box::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  box-shadow: 0 0 5px 4px rgba(0,0,0,0.4);
  z-index: 1;
  transition: opacity 400ms;
  opacity: 1;
}
.scroll-box::before {
  top: 0;
}
.scroll-box::after {
  bottom: 0;
}
.scroll-box.scroll-box--at-top::before,
.scroll-box.scroll-box--at-bottom::after {
  opacity: 0;
}

Note: To provide CSS hooks that are useful for styling scroll indicators, one additional inner div .scroll-box_body is used. Sadly without this element it is not possible (aside from a few limited or ugly techniques) to style the top/bottom of a scrollable area.

Using the actions for infinite scroll

Given a scroll-box with a hooked up nearBottom action:

Template:

{{#scroll-box
  class="my-container"
  nearBottom="loadMoreContent"
  thresholdBottom=100}}
  {{#each items as |item|}}
    <div>Some repeated content</div>
  {{/each}}
{{/scroll-box}}

CSS:

.my-container {
  height: 100px;
}

As you can imagine, this will trigger the outer context's loadMoreContent action when content scrolls withint 100px of the bottom. You can then handle retrieving more records and push them to the items array. nearTop, thresholdTop, atTop and atBottom are also available.

How to collaborate on this addon

  • git clone this repository
  • npm install

Running

Running Tests

  • npm test (Runs ember try:each to test your addon against multiple Ember versions)
  • ember test
  • ember test --server

Building

  • ember build

For more information on using ember-cli, visit https://ember-cli.com/.