Skip to content

Commit

Permalink
fix #1: insert styles via appendChild
Browse files Browse the repository at this point in the history
  • Loading branch information
robinloeffel committed Mar 9, 2020
1 parent 3daa5e9 commit 62a8108
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion dist/cosha.iife.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 16 additions & 16 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@ const cosha = ({
} = {}) => {
if (NodeList.prototype.forEach) {
const images = document.querySelectorAll(`.${className}`);
const styles = document.createElement('style');

document.head.insertAdjacentHTML('beforeend', `
<style>
.${className}-wrapper {
position: relative;
display: flex;
align-items: center;
justify-content: center;
}
styles.textContent = `
.${className}-wrapper {
position: relative;
display: flex;
align-items: center;
justify-content: center;
}
.${className}-clone {
filter: blur(${blur}) brightness(${brightness}) saturate(${saturation});
position: absolute;
z-index: -1;
transform: translate3d(${x}, ${y}, 0);
}
</style>
`);
.${className}-clone {
filter: blur(${blur}) brightness(${brightness}) saturate(${saturation});
position: absolute;
z-index: -1;
transform: translate3d(${x}, ${y}, 0);
}
`;
document.head.appendChild(styles);

images.forEach(image => {
const clone = image.cloneNode();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cosha",
"version": "0.3.4",
"version": "0.3.5",
"description": "Colorful shadows for your images",
"homepage": "npm.robinloeffel.ch/cosha",
"repository": "robinloeffel/cosha",
Expand Down

0 comments on commit 62a8108

Please sign in to comment.