New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ember-scroll-box

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-scroll-box

A component providing scroll css hooks and actions.

  • 1.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
Maintainers
1
Weekly downloads
 
Created
Source

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/.

Keywords

FAQs

Package last updated on 28 Nov 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc