3.1.1 • Published 4 months ago

hq-cropper v3.1.1

Weekly downloads
89
License
MIT
Repository
github
Last release
4 months ago

npm version Downloads

hq-cropper

Cropper for large images

Demo

Installation

npm install hq-cropper

Usage Example

import { HqCropper } from 'hq-cropper'

function handleCrop(base64: string, blob: Blob | null) {
    document.querySelector('img#image-preview').setAttribute('src', base64)
}

const hqCropper = HqCropper(handleCrop)

document.querySelector('button#change-image-button')
    .addEventListener('click', hqCropper.open, false)

React usage

import { useMemo } from 'react'
import { HqCropper } from 'hq-cropper'

function MyComponent() {
    const [image, setImage] = useState('')

    /* Important: must be memoized */
    const { current: hqCropper } = useRef(HqCropper(setImage))

    return (
        <div>
            <img src={image} />
            <button onClick={hqCropper.open}>change</button>
        </div>
    )
}

Configuration

HqCropper can be initialized with config and css objects.

export type HqCropperType = (
    onSubmit: (result: string, state: IState) => void,
    config?: Partial<IConfig>,
    css?: Partial<IClassNames>
) => HqCropperInstance
3.1.1

4 months ago

3.1.0

4 months ago

3.0.1

11 months ago

3.0.0

11 months ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.0.12

2 years ago

1.0.11

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago