
Product
Rust Support Now in Beta
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
ember-scroll-box
Advanced tools
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.
ember install ember-scroll-box
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.
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.
git clone
this repositorynpm install
ember serve
npm test
(Runs ember try:each
to test your addon against multiple Ember versions)ember test
ember test --server
ember build
For more information on using ember-cli, visit https://ember-cli.com/.
FAQs
A component providing scroll css hooks and actions.
We found that ember-scroll-box demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.