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

wwl-resize

v1.0.5

Published

拖动改变元素大小。目前仅支持鼠标操作,不支持手势。

Downloads

3

Readme

拖动改变元素大小。目前仅支持鼠标操作,不支持手势。

使用

npm

npm install -S wwl-resize

  • resizeBlock: var resizeBlock = require('wwl-resize/resizeblock')
  • resizeImage: var resizeImage = require('wwl-resize/resizeimage')

直接下载

  • resizeBlock: http://wangwl.net/static/demo/wwl-resize/resizeblock.js
  • resizeImage: http://wangwl.net/static/demo/wwl-resize/resizeimage.js

resizeBlock

function( node , options? ) : function

示例:

var dispose = resizeBlock( document.getElementById('#div1') );

将一个元素块变成可拖动控制尺寸,返回一个dispose函数,调用该函数释放相关资源(取消事件回调等)。

node

{node|string} 元素或选择器 改变尺寸的目标元素

options.scale

{number} 限制宽高比例

默认可随意拖动,传入scale参数,限制拖动时的宽高比例

options.container

{node|string} 拖动范围

传入元素节点或选择器,控制拖动范围。

options.targetClass

{string}

对目标元素设置一个样式类,默认不设置。

options.pointClass

{string}

对目标元素拖动滑块设置样式类,默认不设置

options.resizeActive

function(node,size) node为目标节点。 size: {width,height} 当前元素尺寸。

在即将触发拖动时(即mousedown事件中),调用resizeActive事件。

options.resizeStart

resizeStart(node,size)

在第一次改变尺寸前,触发resizeStart事件。

如果该回调返回布尔值false,则不允许改变尺寸。

options.resizeMove

resizeMove(node,size)

改变尺寸过程中触发。

options.resizeEnd

resizeEnd(node,size)

在改变尺寸完成后触发。

resizeImage

function(node, img, options) : function

示例:

var dispose=resizeImage('.resize', 'http://pic-bucket.nosdn.127.net/photo/0001/2018-04-15/DFEV9E9M00AO0001NOS.jpg')

提供一个简便方法,用于针对改变图片尺寸。

node

{node|string} 元素或选择器 改变尺寸的目标元素

img

{file|string} 传入图片,可以File类型,或者url

options

该options会传给resizeBlock

在传给resizeBlock前,resizeImage会自动计算scale值,并覆盖原options.scale。

通过设置options.disableScale,则不计算scale值,options不做任何处理,直接传给resizeBlock