-
-
Notifications
You must be signed in to change notification settings - Fork 5
(feat): add built-in option to clone the canvas (w/ support for alternate canvas implementations) #7
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
base: master
Are you sure you want to change the base?
(feat): add built-in option to clone the canvas (w/ support for alternate canvas implementations) #7
Changes from all commits
52537f8
7cb4e0e
d717f4c
92a2da5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,7 +15,7 @@ | |
| <br> | ||
| [](https://npmjs.org/package/trim-canvas) | ||
|
|
||
| A tiny (< 100 LoC) library for trimming whitespace from a `canvas` element with no dependencies. | ||
| A tiny (~100 LoC) library for trimming whitespace from a `canvas` element with no dependencies. | ||
|
|
||
| ## Installation | ||
|
|
||
|
|
@@ -35,9 +35,29 @@ trimCanvas(canvas) | |
| ``` | ||
|
|
||
| If you don't want to mess with your existing canvas, then simply clone the canvas element beforehand. | ||
| `trim-canvas` v0.2+ has built-in support for cloning: | ||
|
|
||
| ```javascript | ||
| const newTrimmedCanvas = trimCanvas(canvas, {clone: true}) | ||
| ``` | ||
|
|
||
| Can view the [full list of options](#API) below. | ||
|
|
||
| `trim-canvas` returns the canvas element for easy chaining. | ||
|
|
||
| ### API | ||
|
|
||
| #### `trimCanvas(canvas, options)` | ||
|
|
||
| - arguments | ||
| - **canvas** *Canvas object* The canvas to be trimmed. | ||
| - **options** *object* Optional arguments. | ||
| - **clone** *bool* Whether to clone the canvas before trimming (default: `false`). | ||
| - **createCanvas** *function* A custom function to create a Canvas (defaults to DOM implementation). | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should mention that it's only used for cloning as that's a pretty key detail. Could make |
||
| Supports [`node-canvas`'s `createCanvas`](https://github.com/Automattic/node-canvas#createcanvas). | ||
|
|
||
| - returns the trimmed canvas (original or cloned) | ||
|
|
||
| ## Example | ||
|
|
||
| Can see how `trim-canvas` is used inside of `react-signature-canvas` [here](https://github.com/agilgur5/react-signature-canvas/blob/310bff81813509a4035bedfe50d76e7045a880cb/src/index.js#L53-L64). | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This link would be out-of-date with this release, as there's no need for |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a link to MDN?