An open API service indexing awesome lists of open source software.

https://github.com/francoischalifour/medium-zoom-element

πŸ”ŽπŸŒ… HTML Element for medium-zoom
https://github.com/francoischalifour/medium-zoom-element

htmlelement medium-zoom webcomponent

Last synced: 11 months ago
JSON representation

πŸ”ŽπŸŒ… HTML Element for medium-zoom

Awesome Lists containing this project

README

          



Medium Zoom Element


HTML Element for medium-zoom



version


size


gzip size


MIT license



πŸ”¬ Playground ・
πŸ”Ž Demo

> Web component bundling the [`medium-zoom`](https://github.com/francoischalifour/medium-zoom) API.

## Usage

From [npm](https://www.npmjs.com) or [Yarn](https://yarnpkg.com):

```sh
npm install --save medium-zoom-element
# or
yarn add medium-zoom-element
```

From a [CDN](https://en.wikipedia.org/wiki/Content_delivery_network):

```html

```

Use the `medium-zoom` web component in your HTML page:

```html

```

## API

### Options

| Attribute | Description |
|---------------------|-------------------------------------------------------------------|
| `src` | Source of the image |
| `alt` | Alternative text for the image |
| `width` | Width of the image |
| `height` | Height of the image |
| `margin` | Space outside the zoomed image |
| `background` | Color of the overlay |
| `scroll-offset` | Number of pixels to scroll to dismiss the zoom |
| `disable-metaclick` | Disables the action on meta click (opens the link / image source) |
| `zoom-target` | Source of the zoomed image |

Refer to [`medium-zoom`'s options](https://github.com/francoischalifour/medium-zoom#options) for default values.

```html

```

### Methods

Refer to [`medium-zoom`'s methods](https://github.com/francoischalifour/medium-zoom#methods).

### JavaScript getters/setters

* `margin`
* `background`
* `scrollOffset`
* `metaClick`
* `zoomTarget`

```js
const image = document.querySelector('medium-zoom')

image.margin = 48
console.log(image.margin) // 48
```

## Dev

* Run `yarn` to install Node dependencies
* Run `yarn dev` to watch changes and rebuild the library
* 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`)

## License

MIT Β© [FranΓ§ois Chalifour](https://francoischalifour.com)