UNPKG

3.84 kBMarkdownView Raw
1<p align="center">
2 <a href="https://medium-zoom.francoischalifour.com"><img src="https://raw.githubusercontent.com/francoischalifour/medium-zoom/master/logo.svg?sanitize=true" width="64"></a>
3 <h3 align="center">Medium Zoom Element</h3>
4 <p align="center">HTML Element for <a href="https://github.com/francoischalifour/medium-zoom"><code>medium-zoom</code></a></p>
5</p>
6
7<p align="center">
8 <a href="https://www.npmjs.com/package/medium-zoom-element">
9 <img src="https://img.shields.io/npm/v/medium-zoom-element.svg?style=flat-square" alt="version">
10 </a>
11 <a href="https://unpkg.com/medium-zoom-element/dist/">
12 <img src="http://img.badgesize.io/https://unpkg.com/medium-zoom-element/dist/medium-zoom-element.min.js?label=size&style=flat-square" alt="size">
13 </a>
14 <a href="https://unpkg.com/medium-zoom-element/dist/">
15 <img src="http://img.badgesize.io/https://unpkg.com/medium-zoom-element/dist/medium-zoom-element.min.js?compression=gzip&label=gzip%20size&style=flat-square" alt="gzip size">
16 </a>
17 <a href="https://github.com/francoischalifour/medium-zoom-element/blob/master/LICENSE">
18 <img src="https://img.shields.io/npm/l/medium-zoom-element.svg?style=flat-square" alt="MIT license">
19 </a>
20</p>
21
22> Web component bundling the [`medium-zoom`](https://github.com/francoischalifour/medium-zoom) API.
23
24## Usage
25
26From [npm](https://www.npmjs.com) or [Yarn](https://yarnpkg.com):
27
28```sh
29npm install --save medium-zoom
30# or
31yarn add medium-zoom
32```
33
34From a [CDN](https://en.wikipedia.org/wiki/Content_delivery_network):
35
36```html
37<script src="https://unpkg.com/medium-zoom-element@0/dist/medium-zoom-element.min.js"></script>
38```
39
40Use the `medium-zoom` web component in your HTML page:
41
42```html
43<medium-zoom
44 src="image.jpg"
45 alt="Zoomable image"
46></medium-zoom>
47```
48
49## API
50
51### Options
52
53| Attribute | Description |
54|---------------------|-------------------------------------------------------------------|
55| `src` | Source of the image |
56| `alt` | Alternative text for the image |
57| `width` | Width of the image |
58| `height` | Height of the image |
59| `margin` | Space outside the zoomed image |
60| `background` | Color of the overlay |
61| `scroll-offset` | Number of pixels to scroll to dismiss the zoom |
62| `disable-metaclick` | Disables the action on meta click (opens the link / image source) |
63| `zoom-target` | Source of the zoomed image |
64
65Refer to [`medium-zoom`'s options](https://github.com/francoischalifour/medium-zoom#options) for default values.
66
67```html
68<medium-zoom
69 src="image.jpg"
70 zoom-target="image-hd.jpg"
71 margin="48"
72 background="rgba(0,0,0,.16)"
73 scroll-offset="0"
74 disable-metaclick
75 alt="Zoomable image"
76></medium-zoom>
77```
78
79### Methods
80
81Refer to [`medium-zoom`'s methods](https://github.com/francoischalifour/medium-zoom#methods).
82
83### JavaScript getters/setters
84
85* `margin`
86* `background`
87* `scrollOffset`
88* `metaClick`
89* `zoomTarget`
90
91```js
92const image = document.querySelector('medium-zoom')
93
94image.margin = 48
95console.log(image.margin) // 48
96```
97
98## Dev
99
100* Run `yarn` to install Node dependencies
101* Run `yarn dev` to watch changes and rebuild the library
102* Open [`examples/index.html`](examples/index.html) to check your changes (it includes [`dist/medium-zoom-element.min.js`](dist/medium-zoom-element.min.js) which is watched with `yarn dev`)
103
104## License
105
106MIT © [François Chalifour](https://francoischalifour.com)