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

h5-cropper

v0.0.1

Published

移动端图片裁剪器

Downloads

4

Readme

h5-cropper

移动端图片裁剪器,基于 cropperjs 制作的简单裁剪器

案例演示

HTML部分:

<!DOCTYPE html>
<html lang="cn">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" />
  <title>裁剪案例</title>
</head>
<script src="./h5-cropper.js"></script>
<body style="font-size: 14px">
  <img id="image" src="http://placekitten.com/g/720/400" width="100%" alt="">
  <div>
    <button style="width: 100%; font-size: 18px;" id="button">开始裁剪</button>
  </div>
</body>
<script src="./index.js"></script>
</html>

JS部分:

const img = document.getElementById('image')

document.getElementById('button').onclick = function () {
  var cropper = new window.H5Cropper(img.src, function (base64) {
    img.src = base64
  })
}

演示案例:https://sayll.github.io/h5-cropper/index.html

手机模式查看,效果更佳。

使用方式

直接下载使用

通过下载,直接引用dist/index.js,通过全局的window对象访问。

const cropper = new window.H5Cropper('http://placekitten.com/g/300/200', function (base64) {
  // to do something
  console.log(base64)
})

npm 下载使用

下载方式:

npm i -S h5-cropper

使用方式:

import H5Cropper from 'h5-cropper'
const cropper = new H5Cropper('http://placekitten.com/g/300/200', function (base64) {
  // to do something
  console.log(base64)
})

接口定义

调用方式:

new H5Cropper(url: string, callback?: (data64: string) => any, options?: CropperjsOptions)

|参数|描述| |----|----| |url|图片地址或base64| |callback|裁剪完成后的回调函数,接收最终的图片base64| |options|一些高级配置,详细请查看插件Cropperjs|