Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/unhappychoice/cycle-cropper

:recycle: Cycle.js component for https://github.com/fengyuanchen/cropperjs
https://github.com/unhappychoice/cycle-cropper

cropper cropperjs cycle-cropper cyclejs image typescript

Last synced: 23 days ago
JSON representation

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

Awesome Lists containing this project

README

        

# cycle-cropper
[![npm version](https://badge.fury.io/js/cycle-cropper.svg)](https://badge.fury.io/js/cycle-cropper)
[![Libraries.io dependency status for GitHub repo](https://img.shields.io/librariesio/github/unhappychoice/cycle-cropper.svg)](https://libraries.io/github/unhappychoice/cycle-cropper)
![npm bundle size](https://img.shields.io/bundlephobia/min/cycle-cropper.svg)
![npm](https://img.shields.io/npm/dt/cycle-cropper.svg)
![GitHub](https://img.shields.io/github/license/unhappychoice/cycle-cropper.svg)

cycle-cropper is component for [cropper.js](https://github.com/fengyuanchen/cropperjs)

### Usage

```typescript
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](./LICENSE)