Get image position coordinates
https://antonbobrov.github.io/get-image-pos/
Documentation: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,
});