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.
svelte-scrollto
Advanced tools
Svelte action that listens for click events and scrolls to elements with animation. Inspired by rigor789/vue-scrollto.
Animating vertical and horizontal scrolling
npm install --save-dev svelte-scrollto
# or
yarn add -D svelte-scrollto
<script>
import * as animateScroll from "svelte-scrollto";
</script>
<a on:click={() => animateScroll.scrollToBottom()}> Scroll to bottom </a>
<a on:click={() => animateScroll.scrollToTop()}> Scroll to top </a>
<a on:click={() => animateScroll.scrollTo({element: 'scroll-to-element-selector'})}> Scroll to element </a>
<a on:click={() => animateScroll.scrollTo({element: 'scroll-to-element-selector', offset: 200})}> Scroll to below element 200px </a>
<a on:click={() => animateScroll.scrollTo({element: 'scroll-to-element-selector', duration: 2000})}> Scroll to element over 2000ms </a>
Using as a action
<script>
import { scrollto } from "svelte-scrollto";
</script>
<!-- Parameter is element selector or options -->
<a use:scrollto={'#scroll-element'}> Scroll to element </a>
Option | Required | Default value | Description |
---|---|---|---|
container | ✔ | "body" | Scroll container |
duration | ✔ | 500 | The duration (in milliseconds) of the scrolling animation. |
delay | 0 | ||
offset | 0 | The offset that should be applied when scrolling. This option accepts a callback function | |
easing | cubicInOut | The easing function to be used when animating. Can pass any easing from svelte/easing or pass custom easing function. | |
onStart | noop | A callback function that should be called when scrolling has started. Receives the target element and page offset as a parameter. | |
onDone | noop | A callback function that should be called when scrolling has ended. Receives the target element and page offset as a parameter. | |
onAborting | noop | A callback function that should be called when scrolling has been aborted by the user (user scrolled, clicked etc.). Receives the target element and page offset as parameters. | |
scrollX | false | Whether or not we want scrolling on the x axis | |
scrollY | true | Whether or not we want scrolling on the y axis |
Override global options:
import * as animateScroll from "svelte-scrollto";
animateScroll.setGlobalOptions({
offset: 200,
onStart: (element, offset) => {
if(element) {
console.log("Start scrolling to element:", element);
} else if(offset) {
console.log("Start scrolling to page offset: (${offset.x}, ${offset.y})");
}
}
})
scrollTo(options)
Accepts all global options and:
element
: The element you want scroll tox
: The offset we want to scrolling on the x axisy
: The offset we want to scrolling on the y axisscrollToTop(options)
Shortcut of use scrollTo with x
equal to 0
.
scrollToBottom(options)
Shortcut of use scrollTo with x
equal to containerHeight
Svelte action that listens for click
(touchstart
) events and scrolls to elements with animation.
scrollto
scrolltotop
scrolltobottom
If you want to use Lazy and want to scroll to elements, you need to give your lazy components (images, v.v..) fixed dimensions, so the browser known the size of the not loaded elements before scrolling.
FAQs
Svelte action that listens for click events and scrolls to elements with animation. Inspired by rigor789/vue-scrollto.
We found that svelte-scrollto 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.