Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
robinloeffel committed Dec 10, 2023
1 parent b627c18 commit 8ed5241
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
export default ({ className = "cosha", blur = "5px", brightness = 1, saturation = 1, x = 0, y = 0 } = {}) => {
const images = document.querySelectorAll(`.${className}`);
const styles = document.createElement("style");
styles.textContent = `
.${className}-wrapper {
position: relative;
display: grid;
place-content: center;
}
.${className}-clone {
position: absolute;
z-index: -1;
translate: ${x} ${y} 0;
filter: blur(${blur}) brightness(${brightness}) saturate(${saturation});
}
`;
document.body.append(styles);
for (const original of images) {
const cloned = original.cloneNode(true);
const wrapper = document.createElement("div");
cloned.classList.remove(className);
cloned.classList.add(`${className}-clone`);
wrapper.classList.add(`${className}-wrapper`);
wrapper.append(original.cloneNode(true), cloned);
wrapper.querySelectorAll("img").item(1).alt = "";
original.replaceWith(wrapper);
}
};

0 comments on commit 8ed5241

Please sign in to comment.