0.0.1 • Published 7 years ago

medium-zoom-element v0.0.1

Weekly downloads
11
License
MIT
Repository
github
Last release
7 years ago

Web component bundling the medium-zoom API.

Usage

From npm or Yarn:

npm install --save medium-zoom
# or
yarn add medium-zoom

From a CDN:

<script src="https://unpkg.com/medium-zoom-element@0/dist/medium-zoom-element.min.js"></script>

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

<medium-zoom
  src="image.jpg"
  alt="Zoomable image"
></medium-zoom>

API

Options

AttributeDescription
srcSource of the image
altAlternative text for the image
widthWidth of the image
heightHeight of the image
marginSpace outside the zoomed image
backgroundColor of the overlay
scroll-offsetNumber of pixels to scroll to dismiss the zoom
disable-metaclickDisables the action on meta click (opens the link / image source)
zoom-targetSource of the zoomed image

Refer to medium-zoom's options for default values.

<medium-zoom
  src="image.jpg"
  zoom-target="image-hd.jpg"
  margin="48"
  background="rgba(0,0,0,.16)"
  scroll-offset="0"
  disable-metaclick
  alt="Zoomable image"
></medium-zoom>

Methods

Refer to medium-zoom's methods.

JavaScript getters/setters

  • margin
  • background
  • scrollOffset
  • metaClick
  • zoomTarget
const image = document.querySelector('medium-zoom')

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

Dev

License

MIT © François Chalifour