Skip to content

Public property for canvas element, and new CSS background image option. #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ node_modules

lib/
build/
pixman-0.30.0/
pixman.tar.gz

### Windows template
# Windows image file caches
Expand Down
10 changes: 8 additions & 2 deletions examples/main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ class SketchFieldDemo extends React.Component {
stretched: true,
stretchedX: false,
stretchedY: false,
centerContained: false,
originX: 'left',
originY: 'top'
};
Expand Down Expand Up @@ -259,13 +260,14 @@ class SketchFieldDemo extends React.Component {
if (accepted && accepted.length > 0) {
let sketch = this._sketch;
let reader = new FileReader();
let {stretched, stretchedX, stretchedY, originX, originY} = this.state;
let {stretched, stretchedX, stretchedY, originX, originY, centerContained} = this.state;
reader.addEventListener('load', () => sketch.setBackgroundFromDataUrl(reader.result, {
stretched: stretched,
stretchedX: stretchedX,
stretchedY: stretchedY,
originX: originX,
originY: originY
originY: originY,
centerContained: centerContained,
}), false);
reader.readAsDataURL(accepted[0]);
}
Expand Down Expand Up @@ -435,6 +437,10 @@ class SketchFieldDemo extends React.Component {
defaultToggled={this.state.stretchedY}
onToggle={(e) => this.setState({stretchedY: !this.state.stretchedY})}/>

<Toggle label="Center contain"
defaultToggled={this.state.centerContained}
onToggle={(e) => this.setState({centerContained: !this.state.centerContained})}/>

<div>
<DropZone
ref="dropzone"
Expand Down
Loading