From 4b34e7647dd8a2edf720413dc934bebb34de0f82 Mon Sep 17 00:00:00 2001 From: Balakrishnan Balasubramanian Date: Sun, 27 Aug 2023 19:37:05 -0400 Subject: [PATCH] get imgs dynamically --- index.html | 45 +++++---------------------------------------- index.js | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 40 deletions(-) create mode 100644 index.js diff --git a/index.html b/index.html index d356a28..f3abb72 100644 --- a/index.html +++ b/index.html @@ -5,42 +5,7 @@ - + -
+
diff --git a/index.js b/index.js new file mode 100644 index 0000000..15b9c5c --- /dev/null +++ b/index.js @@ -0,0 +1,38 @@ + +var crops = []; + +function makeCroppieElem(elem, imgUrl) { + cpie = new Croppie(elem, { + viewport: { + width: elem.clientWidth, + height: elem.clientHeight, + type: 'square' + }, + showZoomer: false, + }); + + cpie.bind({ + url: imgUrl + }); + + crops.push(cpie) +} + +function makeCroppie(collageDivId) { + const collageDiv = document.getElementById(collageDivId) + for(elem of collageDiv.getElementsByClassName("collage-img")) { + makeCroppieElem(elem, elem.dataset.collageImageUrl) + } +} + +function main() { + makeCroppie("collage") +} + +function showCrop() { + for(cpie of crops) { + console.log(cpie.get()) + console.log(cpie.element.clientWidth) + console.log(cpie.element.clientHeight) + } +}