npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue-plugin-scroll-into-view

v0.0.1

Published

A lightweight Vue.js plugin that allows you to scroll an element into view with just a single line of code.

Downloads

4

Readme

vue-plugin-scroll-into-view

LICENSE Node CodeFactor

Coverage Status Snyk Vulnerabilities for GitHub Repo

Version Downloads

GitHub Stars GitHub Forks GitHub Discussions GitHub closed pull requests GitHub closed issues

vue-scroll-into-view is a simple Vue.js plugin that provides a convenient way to scroll an element into view with just a single line of code. Whether you have a long page with many sections, or you need to navigate to a specific part of the page, this plugin makes it easy to do so.

Features

Scrolls an element into the visible area of the browser window Supports scrolling to an element by $refs, selector, VNode, or HTMLElement Allows for customization of scroll options, such as animation and alignment Easy to install and use in your Vue.js 2 or 3 project

Usage Examples

Inside your code you can do something like this:

Basic usage

<template>
  <div>
    <h1>Hello World</h1>

    <table ref="table">
      <!-- long content -->
    </table>

    <button @click="nextPage"> Next </button>

  </div>
</template>
<script>
export default {
  methods: {
    nextPage() {

      // await requestNextPage();
      
      // scroll to top of the table
      this.$scrollIntoView(this.$refs.table); // refs or VNodes
      
      this.$scrollIntoView('div > table'); // CSS Selectors
    },
  }
}
</script>

Installation

NPM

npm install vue-plugin-scroll-into-view

Yarn

yarn add --dev vue-plugin-scroll-into-view

Adding to your project

index.js

import Vue from 'vue';
import VueScrollIntoView from 'vue-plugin-scroll-into-view';

Vue.use(VueScrollIntoView);

Options

this.$scrollIntoView(ref, options);

| Option | Type | Description | Default value | |----------------------------|---------|----------------------------------------------------------------------------------|---------------| | behavior | String | Defines the transition animation. One of "auto" or "smooth". | "auto" | | block | String | Defines vertical alignment. One of "start", "center", "end", or "nearest". | "start" | | inline | String | Defines horizontal alignment. One of "start", "center", "end", or "nearest". | "nearest" | | scrollMode | String | Defines the scrolling mode. One of "always", "if-needed", or "never". | "always" | | skipOverflowHiddenElements | Boolean | Whether to skip scrolling the ancestor elements with overflow: hidden. | false | | allowHorizontalScroll | Boolean | Whether to allow horizontal scrolling if the element is wider than the viewport. | false | | force | Boolean | Whether to always scroll the element, even if it's already in view. | false |

Options example

This will scroll the element with the ID my-section into view with default scroll options. You can also pass in custom scroll options if desired:

this.$scrollIntoView('#my-section', { behavior: 'smooth', block: 'center' });

License

The code is available under the MIT license.

Contributing

We are open to contributions, see CONTRIBUTING.md for more info.

You need at least Node 18 to build the project