Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
kingdido999 committed Apr 8, 2018
1 parent 54bc068 commit 792a0f0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
20 changes: 14 additions & 6 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,43 @@ Alternatively:
- [unpkg](https://unpkg.com/zooming)
- [Download source](https://github.com/kingdido999/zooming/releases)

## Usage
## Example usage

Assuming we have the following images on our page and we want to make them zoomable:
To make the following images zoomable:

```html
<img src='foo-image.jpg' class='.img-zoomable' />
<img src='bar-image.jpg' class='.img-zoomable' />
```

We can load the library via script tag:
First, we need to load the library:

### Option 1: Script tag

```html
<script src="build/zooming.min.js"></script>
```

Or module loader:
### Option 2: Module loader

```javascript
import Zooming from 'zooming'
```

Then, initialize Zooming instance after DOM content is fully loaded:
Next, initialize Zooming instance after DOM content is fully loaded:

```js
document.addEventListener('DOMContentLoaded', function () {
new Zooming().listen('.img-zoomable')
const zooming = new Zooming({
// options...
})

zooming.listen('.img-zoomable')
})
```

!> Starting from Zooming **2.0**, we no longer listen to images with data attribute `data-action="zoom"` by default. Please make sure to call `.listen()` on target images after Zooming instance is created.

## What's Next?

Check out [Guide](/guide) and [Configuration](/configuration).
3 changes: 1 addition & 2 deletions examples/grid/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@

<script src="../../build/zooming.js"></script>
<script>
const zooming = new Zooming()
zooming.listen('img')
new Zooming().listen('img')
</script>
</body>

Expand Down

0 comments on commit 792a0f0

Please sign in to comment.