Security News
How Threat Actors are Abusing GitHub’s File Upload Feature to Host Malware
GitHub is susceptible to a CDN flaw that allows attackers to host malware on any public repository.
@bva/vue-sticky-directive
Advanced tools
Readme
Makes any Vue component or element sticky – scrolls at a fixed position in the viewport. Specially useful for main navigation headers, sidebars, and more.
@bva/stickie
(which in turn is dependency free).ResizeObserver
and matchMedia
to detect changes to the interface, caching calculated properties, etc.From your favorite CLI using yarn:
yarn add @bva/vue-sticky-directive
Or npm:
npm install @bva/vue-sticky-directive
import Sticky from '@bva/vue-sticky-directive';
Vue.use(VueStickyDirective);
import Sticky from '@bva/vue-sticky-directive';
export default {
name: 'componentName',
directives: {
Sticky
},
};
Usage is as simple setting the v-sticky
directive:
<template>
<div v-sticky>
A sticky element
</div>
</template>
<script>
...
</script>
You can also pass options if needed. Directly in the directive:
<template>
<div v-sticky="{ contained: true, offset: 20 }">
A sticky element
</div>
</template>
<script>
...
</script>
Or from a Vue object:
<template>
<div v-sticky="stickyOptions">
A sticky element
</div>
</template>
<script>
export default {
...,
data() {
return {
stickyOptions: {
contained: true,
offset: 20,
},
};
},
...,
};
</script>
All options available in @bva/stickie
are also available to this directive. Head over its documentation to learn more: https://www.npmjs.com/package/@bva/stickie#options
All events fired by @bva/stickie
https://www.npmjs.com/package/@bva/stickie#events can be handled through this directive.
You can use Vue’s standard @
notation as well as v-on
:
<template>
<div v-sticky @sticky:active="onStickyActive">
A sticky element
</div>
</template>
<script>
export default {
...,
methods: {
onStickyActive() {
console.log('Sticky is now active!');
},
},
...,
};
</script>
Accessing event data can be done through the event’s details
object on the listener binding:
<template>
<div v-sticky @sticky:active="(evt) => onStickyActive(evt.detail)">
A sticky element
</div>
</template>
<script>
export default {
...,
methods: {
onStickyActive(data) {
console.log('Sticky is now active!');
console.log('Event data:', data);
},
},
...,
};
</script>
Or simply access it directly on the handler:
<template>
<div v-sticky @sticky:active="onStickyActive">
A sticky element
</div>
</template>
<script>
export default {
...,
methods: {
onStickyActive({ details }) {
console.log('Sticky is now active!');
console.log('Event data:', details);
},
},
...,
};
</script>
FAQs
Vue directive to enable sticky scrolling on navigation elements such as headers and sidebars.
The npm package @bva/vue-sticky-directive receives a total of 47 weekly downloads. As such, @bva/vue-sticky-directive popularity was classified as not popular.
We found that @bva/vue-sticky-directive 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.
Security News
GitHub is susceptible to a CDN flaw that allows attackers to host malware on any public repository.
Security News
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
Research
Security News
The Socket Research team found this npm package includes code for collecting sensitive developer information, including your operating system username, Git username, and Git email.