unhappychoice / cycle-cropper

:recycle: Cycle.js component for https://github.com/fengyuanchen/cropperjs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cycle-cropper

npm version Libraries.io dependency status for GitHub repo npm bundle size npm GitHub

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

About

:recycle: Cycle.js component for https://github.com/fengyuanchen/cropperjs

License:MIT License


Languages

Language:TypeScript 88.7%Language:JavaScript 11.3%