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

scrollprevent

v1.0.0

Published

纯原生JS,移动端阻止页面元素滚动插件

Downloads

1

Readme

ScrollPrevent

纯原生JS,移动端阻止页面元素滚动插件

介绍

在移动端开发的时候,未免会遇到这样的情况: 有一个弹出的浮动层,这个层有滚动条,可以上下滚动。 此时就会发现,当用户在操作这个浮层的时候,整个页面也可能会随之滚动。

ScrollPrevent.js就是为了解决这种情况而被制作的!

支持

IE 9+ / 现代化手机浏览器

使用方式

将dist/index.js保存到本地。 在HTML的任何位置使用一句话引入

<script src="index.js"></script>

之后,在页面尾部为浮层元素添加

window.ScrollPrevent.init(dom)

其中,dom为使用选择器选中的HTML原生DOM元素。比如

window.ScrollPrevent.init(document.querySelector("#show"))

之后我们可以发现,浮层的滚动和整个页面的滚动彻底无关了!

当然,想取消ScrollPrevent的效果也很容易。ScrollPrevent.init(dom)方法的会返回一个函数,调用它就可以取消。 就像这样

const unPrevent = window.ScrollPrevent.init(document.querySelector("#show"));
// 当你不想用时
unPrevent();

测试页面

可以使用移动设备访问测试页面

如果您正巧是用PC在访问本页面,可以拿起手机扫描下方的二维码,进行访问 二维码 !!新特性 您可以直接访问PC页面,体验ScrollPrevent测试页面

感谢使用。