Skip to content
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

chore: add example of picker html tag #49

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ A dependency free utility for cropping images based on a focus point ~2.13kB gzi

There are two ways to supply the coordinates when initializing the `FocusedImage` class

#### Data Tags
#### Using data tags

```html
<div class="focused-image-container">
Expand All @@ -38,7 +38,7 @@ const img = document.querySelector('.focused-image') as HTMLImageElement
const focusedImage = new FocusedImage(img)
```

#### Using `focus` Option
#### Using `focus` option

```html
<div class="focused-image-container">
Expand All @@ -60,6 +60,18 @@ const focusedImage = new FocusedImage(img, {

### FocusPicker

```html
<div>
<img
id="focus-picker-img"
src="https://picsum.photos/2400/1400?image=1001"
alt=""
data-focus-x="0"
data-focus-y="0"
/>
</div>
```

Provide an `onChange` callback that will receive a `Focus` object that has `x` and `y` properties for the newly selected coordinates. Optionally supply a `focus` to initialize with, or a `retina` src to use instead of the default white ring SVG.

```ts
Expand Down