diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..b73ff00 Binary files /dev/null and b/.DS_Store differ diff --git a/example/showcase.html b/example/showcase.html index 05aac07..1df0fd3 100644 --- a/example/showcase.html +++ b/example/showcase.html @@ -29,9 +29,9 @@
-
+
- Use is as a preview of a gallery
-
+

Or as a preview for a video

@@ -63,9 +63,9 @@

Or as a preview for a video

-
+
- { img.addEventListener('mouseenter', mouseEnterListener) }) + + + const almover = () => { + let last_known_scroll_position = window.scrollY; + images.forEach(img => { + + if((last_known_scroll_position >= (parseInt(img.dataset.posy) - 10)) && (last_known_scroll_position <= (parseInt(img.dataset.posy) + 10))) + { + + hoveredImg.el = img + hoveredImg.poster = hoveredImg.el.getAttribute('src') + hoveredImg.index = -1 + hoveredImg.images = hoveredImg.el.getAttribute('data-preview').split('|') + + timeout.set(() => previewImages(true), HOVER_DELAY) + hoveredImg.el.addEventListener('mouseleave', () => { + hoveredImg.reset() + timeout.reset() + }) + + //console.log(img.id); + //mouseEnterListener(img); + //console.log(`${img.id}, img position :${img.dataset.posy} , scroll positions: ${last_known_scroll_position}`); + } + }) + } + + const setPosYImages = () => { + images.forEach(img => { + img.dataset.posy = img.getBoundingClientRect().y; + }) + } + + window.addEventListener('scroll', function(){ + almover(); + }) + + window.addEventListener('load', function(){ + setPosYImages(); + }) + + })()