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

v-momentum-scroll

v1.0.1

Published

simulate momentum scroll.

Downloads

2

Readme

v-momentum-scroll

用于需要模拟惯性的地方。基于前端也要懂物理 —— 惯性滚动篇 改造。

example here

Install

npm 安装

npm i v-momentum-scroll --save

Include plugin in your main.js file.

import Vue from 'vue'

import MomentumScroll from 'v-momentum-scroll';

Vue.use(MomentumScroll);

使用链接引入

<script src="https://unpkg.com/v-momentum-scroll/dist/v-momentum-scroll.umd.js"></script>
<body>
  <div id="app">
    <!-- 需要明确的宽度和高度,同时position值不能为static  -->
    <!-- 默认为position值relative,宽高各100px,不然会导致异常显示  -->
    <v-momentum-scroll style="width:200px;height:200px">
      <ul class="list"
            ref="scroller">
          <li class="list-item"
              v-for="(item,index) in list"
              :key="index">
            {{item}}
          </li>
        </ul>
    </v-momentum-scroll>
  </div>
</body>
  <!-- 先引入vue -->
  <script src="https://unpkg.com/vue/dist/vue.js"></script>
  <!-- v-momentum-scroll.js -->
  <script src="./v-momentum-scroll.umd.js"></script>
  <script>
    new Vue({
      el: '#app',
      computed: {
        list() {
          const list = [];
          for (let i = 1; i <= 50; i++) {
            list.push(i);
          }
          return list;
        },
      },
    })
  </script>
</html>

usage

<template>
  <v-momentum-scroll class="wrapper">
    <!-- 需要滚动的东西 -->
  </v-momentum-scroll>
</template>
// 需要明确的宽度和高度,同时position值不能为static
// 默认为position值relative,宽高各100px,不然会导致异常显示
.wrapper {
  height: 60% !important;
  width: 60% !important;
}

props

| param | required | type | default | describe | | :-------------: | :------: | :-----: | :-------: | :------------------------------------------------------------- | | hitBorder | ❌ | function | | 滚动到边界时触发的函数,Function({direction:'bottom'|'top',type:'noBounce'|'weekBounce'|'strongBounce',offsetY:number(滚动的高度)}),当范围值为 HTMLElement 时会滚动到相应位置 |

methods

通过使用vue的ref来调用组件内部的方法。

| method | args | describle| | :--- |:-----:|:---------| | bounceTo|el:HTMLElement,callback:Function | 变速滚动到指定元素| | scrollTo | el:HTMLElement,speed:number,callback:Function | 匀速滚动到指定元素| | getOffsetTop | el:HTMLElement | 获取元素在v-momentum-scroll中的offsetTop|

changelog

1.0.1

  • 修复无法滚动到0的问题

1.0.0

  • init