cycle-cropper
TypeScript icon, indicating that this package has built-in type declarations

1.1.18 • Public • Published

cycle-cropper

npm version Dependency Status

cycle-cropper is component for cropper.js

Usage

import {CropperComponent} from "cycle-cropper";
 
const main = (sources: Sources): Sinks => {
    const imageInput$ = sources.DOM.select(".image");
 
    const cropperSinks = CropperComponent({
        DOM: sources.DOM,
        image$: imageInput$,
        props$: Stream.of({ aspectRatio: 1 }) // cropper options
    });
 
    const imageData$ = cropperSinks.crop$
        .compose(sampleCombine(cropperSinks.cropper$))
        .map(([_, cropper]) => cropper.getCroppedCanvas().toDataURL())
 
    const dom$ = Stream.of([p("Image Cropper")].concat(cropperSinks.DOM));
 
    return { DOM: dom$ };
};
 
run(main, {
    DOM: makeDOMDriver("#app")
});
 

License

see LICENSE

Readme

Keywords

Package Sidebar

Install

npm i cycle-cropper

Weekly Downloads

14

Version

1.1.18

License

MIT

Last publish

Collaborators

  • unhappychoice