get-image-pos

Get image position coordinates

Usage no npm install needed!

<script type="module">
  import getImagePos from 'https://cdn.skypack.dev/get-image-pos';
</script>

README

Get image position coordinates

Documentation: https://antonbobrov.github.io/get-image-pos/

How to start with NPM

npm install get-image-pos

How to start with CDN

<script src="https://cdn.jsdelivr.net/npm/get-image-pos/dist/cdn/index.min.js"></script>

Example

import { getPos, applyHTMLPos } from 'get-image-pos';
// for CDN:
// window.getImagePos

const image = document.querySelector("img");

const pos = getPos({
    source: image,
    rule: 'cover',
    container: image.parentElement,
});

applyHTMLPos({
    source: image,
    rule: 'cover',
    container: image.parentElement,
});