1.0.9 • Published 8 years ago

viewfinder v1.0.9

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

viewfinder

Allow users to select an image and crop it inline, removing user confusion when the image is later served and freeing up those precious cycles on the backend

Demo

alt text

Usage

npm install --save viewfinder
import Viewfinder from 'viewfinder';

if (process.env.BROWSER) {
    require('viewfinder/dist/viewfinder.css');
}

class App extends React.Component {
    save() {
        const a = document.createElement("a");
        a.style.display = 'none';
        document.body.appendChild(a);

        // out takes an optional parameter that scales output image relative
        // to the DOM image
        a.href = this.image.out(4);
        a.download = 'viewfinder-image.png';
        a.click();
    }

    render() {
        return (
            <Viewfinder
                ref={ (c) => this.image = c.image }
                scale={ 0.5 } />
            <Button onClick={ this.save.bind(this) }>
                Save
            </Button>
        );
    }
}

export default App;
1.0.9

8 years ago

1.0.8

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago