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

antd-img-crop-enhance

v0.0.2

Published

An image cropper for Ant Design Upload(Base [email protected])

Readme

基于 [email protected] 的增强

  1. 支持自定义 zoomStep
  2. 实例方法支持 setAspect

Link in bio to widgets, your online home screen. ➫ 🔗 kee.so


antd-img-crop

An image cropper for Ant Design Upload

npm npm npm bundle size GitHub npm type definitions

English | 简体中文

Install

pnpm add antd-img-crop
# or
yarn add antd-img-crop
# or
npm i antd-img-crop

Usage

import { Upload } from 'antd';
import ImgCrop from 'antd-img-crop';

const Demo = () => (
  <ImgCrop>
    <Upload>+ Add image</Upload>
  </ImgCrop>
);

Edit antd-img-crop

Props

| Prop | Type | Default | Description | | -------------- | ---------- | -------------- | -------------------------------------------------------------------------------- | | quality | number | 0.4 | Cropped image quality, 0 to 1 | | fillColor | string | 'white' | Fill color for cropped image | | zoomSlider | boolean | true | Enable zoom adjustment | | rotationSlider | boolean | false | Enable rotation adjustment | | aspectSlider | boolean | false | Enable aspect adjustment | | showReset | boolean | false | Show reset button to reset zoom rotation aspect | | resetText | string | Reset | Reset button text | | aspect | number | 1 / 1 | Aspect of crop area , width / height | | minZoom | number | 1 | Minimum zoom factor | | maxZoom | number | 3 | Maximum zoom factor | | zoomStep | number | 0.1 | Zoom step | | cropShape | string | 'rect' | Shape of crop area, 'rect' or 'round' | | showGrid | boolean | false | Show grid of crop area (third-lines) | | cropperProps | object | - | react-easy-crop props (* existing props cannot be overridden) | | modalClassName | string | '' | Modal classname | | modalTitle | string | 'Edit image' | Modal title | | modalWidth | number | string | Modal width | | modalOk | string | | Ok button text | | modalCancel | string | | Cancel button text | | onModalOk | function | - | Callback of click ok button | | onModalCancel | function | - | Callback of click cancel button (or modal mask & top right "x") | | modalProps | object | | Ant Design Modal props (* existing props cannot be overridden) | | beforeCrop | function | - | Callback before crop modal, if return false or reject(), modal will not open |

Ref

setAspect: (a: number) => void;

FAQ

ConfigProvider not work?

Try to set libraryDirectory('es' or 'lib') to babel-plugin-import config, see which one will work.

module.exports = {
  plugins: [
    ['import', { libraryName: 'antd', libraryDirectory: 'es', style: true }],
  ],
};

No style? (only antd<=v4)

If you use antd<=v4 + babel-plugin-import, and no Modal or Slider were imported, please import these styles manually:

import 'antd/es/modal/style';
import 'antd/es/slider/style';

License

MIT License (c) nanxiaobei