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.
github.com/Developmint/vue-next-level-scroll
"Click to scroll" component using the modern Browser API.
A live demo is available at https://oqxy5xr5ny.sse.codesandbox.io/.
$ npm install vue-next-level-scroll
import VueNextLevelScroll from 'vue-next-level-scroll'
export default {
components: {
VueNextLevelScroll
}
}
export default {
components: {
VueNextLevelScroll: () => import('vue-next-level-scroll')
}
}
UNPKG | jsDelivr (available as window.ifBot)
Vue.component('scroll', window.nextLevelScroll)
// Continue as you wish. If you want to load a scroll behavior polyfill, do it **before** adding the CDN link.
VueNextLevelScroll uses the new ScrollBehavior specification
by default.
Unfortunately, Firefox is the only browser that has it built-in (by now).
For this reason, you might like to go for this polyfill (don't worry, less than 2kB after GZIP).
As you likely have seen, there are various Vue directives out their that handle scrolling as well. You might have used one or two of them already or built one yourself.
But! A component can sometimes be the better approach, as it can be tree shaken, is better suited for universal/SSR code and can be loaded asynchronously as well!
Prop | Optional? | Comment |
---|---|---|
target | :white_check_mark: | Can be any query selector you want (or a function that returns such). Will be passed to the scroll function |
tag | :white_check_mark: | Defaults to div . The HTML tag used for the VueNextLevelScroll component |
scrollFunction | :white_check_mark: | You can define an own scroll function that will take the target prop as parameter and can do whatever you like. |
shouldNavigate | :white_check_mark: | If set, VueRouter will reflect navigation changes in the url(top: no hash, target: hash) |
navigationType | :white_check_mark: | Defaults to push . The navigation type of that VueRouter should use. Usually either push or replace |
When no target
prop is set, the default scroll function will trigger a scroll to top:
<vue-next-level-scroll>
<img src="https://developmint.de/logo.png">
</vue-next-level-scroll>
When the target
prop is provided, the default scroll function look the DOM node up and smooth scroll to it.
If the target
is a class query, the first found element will be chosen to scroll to.
<vue-next-level-scroll target="#my-target">
<img src="https://developmint.de/logo.png">
</vue-next-level-scroll>
<div id="my-target"/>
When the target
prop is given but no node matches, a console error will appear.
<vue-next-level-scroll target="#my-target">
<img src="https://developmint.de/logo.png">
</vue-next-level-scroll>
<div id="my-non-existing-target"/>
Error: Could not scroll to #my-target
Most users are satisfied with the default scroll function provided by VueNextLevelScroll However if you need other behavior you can simply write your own function:
<template>
<vue-next-level-scroll
target="#my-target"
:scroll="myScroll">
<img src="https://developmint.de/logo.png">
</vue-next-level-scroll>
<div id="my-non-existing-target"/>
</template>
<script>
export default {
methods: {
myScroll (target) { doSomeMagicHere(target) }
}
}
</script>
You might not need the polyfill then as well :wink:
Please see our CONTRIBUTING.md
MIT License - Copyright (c) Developmint - Alexander Lichter
FAQs
Unknown package
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.