Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Scrollama is a modern & lightweight JavaScript library for scrollytelling using IntersectionObserver in favor of scroll events. Current version: 3.0.3
The core parts of the Scrollama code base are being refactored for 3.0 to simplfy and clarify the logic. The goal behind this to ease make future maintainance, bug fixing, and feature additions easier moving forward.
order
optionorder
has been deprecated..onContainerEnter
and .onContainerExit
have been deprecated in favor of CSS property position: sticky;
. How to use position sticky.Scrollytelling can be complicated to implement and difficult to make performant. The goal of this library is to provide a simple interface for creating scroll-driven interactives. Scrollama is focused on performance by using IntersectionObserver to handle element position detection.
Note: most of these examples use D3 to keep the code concise, but this can be used with any library, or with no library at all.
position: sticky;
to create a fixed graphic to the side of the text.position: sticky;
to create a fixed graphic with fullscreen graphic with text overlayed.Note: As of version 1.4.0, the IntersectionObserver polyfill has been removed from the build. You must include it yourself for cross-browser support. Check here to see if you need to include the polyfill.
Old school (exposes the scrollama
global):
<script src="https://unpkg.com/scrollama"></script>
New school:
npm install scrollama intersection-observer --save
And then import/require it:
import scrollama from "scrollama"; // or...
const scrollama = require("scrollama");
You can use this library to simply trigger steps, similar to something like Waypoints. This is useful if you need more control over your interactive, or you don't want to follow the sticky scrollytelling pattern.
You can use any id/class naming conventions you want. The HTML structure should look like:
<!--you don't need the "data-step" attr, but can be useful for storing instructions for JS -->
<div class="step" data-step="a"></div>
<div class="step" data-step="b"></div>
<div class="step" data-step="c"></div>
// instantiate the scrollama
const scroller = scrollama();
// setup the instance, pass callback functions
scroller
.setup({
step: ".step",
})
.onStepEnter((response) => {
// { element, index, direction }
})
.onStepExit((response) => {
// { element, index, direction }
});
options:
step
(string | HTMLElement[]): Selector (or array of elements) for the step elements that will trigger changes.
requiredoffset
(number 0 - 1, or string with "px"): How far from the top of the viewport to trigger a step. (default: 0.5) (middle of screen)progress
(boolean): Whether to fire incremental step progress updates or
not. (default: false)threshold
(number, 1+): The granularity of the progress interval in pixels (smaller = more granular). (default: 4)once
(boolean): Only trigger the step to enter once then remove listener. (default: false)debug
(boolean): Whether to show visual debugging tools or not. (default:
false)Callback that fires when the top or bottom edge of a step element enters the offset threshold.
The argument of the callback is an object: { element: DOMElement, index: number, direction: string }
element
: The step element that triggered
index
: The index of the step of all steps
direction
: 'up' or 'down'
Callback that fires when the top or bottom edge of a step element exits the offset threshold.
The argument of the callback is an object: { element: DOMElement, index: number, direction: string }
element
: The step element that triggered
index
: The index of the step of all steps
direction
: 'up' or 'down'
Callback that fires the progress (0 - 1) a step has made through the threshold.
The argument of the callback is an object: { element: DOMElement, index: number, progress: number }
element
: The step element that triggered
index
: The index of the step of all steps
progress
: The percent of completion of the step (0 - 1)
direction
: 'up' or 'down'
Get or set the offset percentage. Value must be between 0-1 (where 0 = top of viewport, 1 = bottom), or a string that includes "px" (e.g., "200px"). If set, returns the scrollama instance.
This is no longer necessary with the addition of a built-in resize observer. Tell scrollama to get latest dimensions the browser/DOM. It is best practice to throttle resize in your code, update the DOM elements, then call this function at the end.
Tell scrollama to resume observing for trigger changes. Only necessary to call if you have previously disabled.
Tell scrollama to stop observing for trigger changes.
Removes all observers and callback functions.
To override the offset passed in the options, set a custom offset for an individual element using data attributes. For example: <div class="step" data-offset="0.25">
or data-offset="100px"
.
viewport height
(vh) in your CSS because scrolling up and down constantly triggers vh to change, which will also trigger a window resize.Logo by the awesome Elaina Natario
MIT License
Copyright (c) 2021 Russell Goldenberg
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
Lightweight scrollytelling library using IntersectionObserver
The npm package scrollama receives a total of 5,022 weekly downloads. As such, scrollama popularity was classified as popular.
We found that scrollama 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.