summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lightbox.js3
-rw-r--r--src/utility.js11
2 files changed, 1 insertions, 13 deletions
diff --git a/src/lightbox.js b/src/lightbox.js
index 5523fc7..57922b3 100644
--- a/src/lightbox.js
+++ b/src/lightbox.js
@@ -1,4 +1,3 @@
-import Utility from './utility.js';
import Overlay from './overlay.js';
import Shadow from './shadow.js';
@@ -21,7 +20,7 @@ export default class LightBox {
const images = document.querySelectorAll(`${this.container} img[data-libo]`);
images.forEach(image => {
- image.id = Utility.hashCode(image.src); // generate unique id for image
+ image.id = crypto.randomUUID(); // generate unique id for image
const link = this.wrapInLink(image);
// add event listener to open lightbox on click
link.addEventListener('click', e => {
diff --git a/src/utility.js b/src/utility.js
deleted file mode 100644
index f2ee3fb..0000000
--- a/src/utility.js
+++ /dev/null
@@ -1,11 +0,0 @@
-export default class Utility {
- static hashCode(str) {
- let hash = 0;
- for (let i = 0, len = str.length; i < len; i++) {
- let chr = str.charCodeAt(i);
- hash = (hash << 5) - hash + chr;
- hash |= 0; // Convert to 32bit integer
- }
- return (hash>0) ? hash : -hash;
- }
-}