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

we-region

v0.0.11

Published

select region

Downloads

17

Readme

WeRegion

weRegion 是一个可以不修改原逻辑,增加拉选框的功能的鼠标拉选框库。原理是通过增加一个透明 canvas 绘制拉选框。应用可参考demo

下载

npm install --save we-region

或者

yarn add we-region

使用

通过传入 DOM 选择器使用

import WeRegion from 'we-region'

const weRegion = new WeRegion('.mask')

配置

weRegion 可以在实例化时,通过传入第二个参数进行配置

const weRegion = new WeRegion('.mask', {
    borderColor: '#0099FF',
    bodyColor: 'rgba(195, 213, 237, 0.6)',
})

配置项包括

options.move({ startX, startY, width, height })

拉选时的回调。其中 startXstartY 表示鼠标的起始位置,widthheight 表示拉选框的宽高

options.end({ startX, startY, width, height })

拉选结束时的回调,释放鼠标按钮和鼠标移除遮罩层时触发。其中 startXstartY 表示鼠标的起始位置,widthheight 表示拉选框的宽高

options.width

遮罩层的宽度,默认是取其父元素的宽度

options.height

遮罩层的高度,默认是取其父元素的高度

options.borderColor

选择框的边框颜色,默认是 #0099FF

options.bodyColor

选择框的颜色,默认是 rgba(195, 213, 237, 0.6)

options.zIndex

遮罩层的 z-index(注意需要比被覆盖的元素高),默认是 9527

实例方法

weRegion 提供 2 个实例方法

clear()

清除遮罩层中的拉选框

isRectCross(rect1, rect2)

检测给定矩形 rect1 与 rect2 是否相交。rect1 和 rect2 的签名均为 { x, y, width, height },其中 xy 表示矩形的横坐标和纵坐标,widthheight 表示矩形的宽和高。若 rect2 省略,则默认为当前拉选框的坐标和宽高

Licence

MIT