@noirmd/previewer 2.0.5 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/react.cjs CHANGED
@@ -11944,6 +11944,7 @@ var hover3d_default = hover3dDirective;
11944
11944
 
11945
11945
  // vanilla/directives/hovergallery.ts
11946
11946
  var IMG_RE3 = /!\[([^\]]*)\]\(([^)]+)\)/g;
11947
+ var MAX_IMAGES = 10;
11947
11948
  var hovergalleryDirective = ({ props, slots }) => {
11948
11949
  const images = [];
11949
11950
  const raw = slots.default || "";
@@ -11955,18 +11956,56 @@ var hovergalleryDirective = ({ props, slots }) => {
11955
11956
  if (images.length === 0) {
11956
11957
  return document.createDocumentFragment();
11957
11958
  }
11959
+ const count = Math.min(images.length, MAX_IMAGES);
11958
11960
  const figure = document.createElement("figure");
11959
11961
  figure.className = "nr-hover-gallery";
11960
11962
  if (props.aspect) figure.style.aspectRatio = props.aspect;
11961
11963
  if (props.class) figure.classList.add(...props.class.split(/\s+/).filter(Boolean));
11962
- if (props.style) figure.setAttribute("style", props.style);
11963
- for (const img of images) {
11964
+ if (props.style) figure.setAttribute("style", (figure.getAttribute("style") || "") + ";" + props.style);
11965
+ const imgEls = [];
11966
+ for (let i = 0; i < count; i++) {
11964
11967
  const el = document.createElement("img");
11965
- el.src = img.src;
11966
- el.alt = img.alt;
11968
+ el.src = images[i].src;
11969
+ el.alt = images[i].alt;
11967
11970
  el.loading = "lazy";
11971
+ el.draggable = false;
11972
+ if (i === 0) el.classList.add("nr-hg-active");
11973
+ imgEls.push(el);
11968
11974
  figure.appendChild(el);
11969
11975
  }
11976
+ for (let i = 0; i < count; i++) {
11977
+ const strip = document.createElement("div");
11978
+ strip.className = "nr-hg-trigger";
11979
+ strip.style.left = `${i / count * 100}%`;
11980
+ strip.style.width = `${1 / count * 100}%`;
11981
+ strip.addEventListener("mouseenter", () => {
11982
+ for (let j = 0; j < imgEls.length; j++) {
11983
+ imgEls[j].classList.toggle("nr-hg-active", j === i);
11984
+ }
11985
+ for (let j = 0; j < dotEls.length; j++) {
11986
+ dotEls[j].classList.toggle("nr-hg-dot-active", j === i);
11987
+ }
11988
+ });
11989
+ figure.appendChild(strip);
11990
+ }
11991
+ figure.addEventListener("mouseleave", () => {
11992
+ for (let j = 0; j < imgEls.length; j++) {
11993
+ imgEls[j].classList.toggle("nr-hg-active", j === 0);
11994
+ }
11995
+ for (let j = 0; j < dotEls.length; j++) {
11996
+ dotEls[j].classList.toggle("nr-hg-dot-active", j === 0);
11997
+ }
11998
+ });
11999
+ const dotContainer = document.createElement("div");
12000
+ dotContainer.className = "nr-hg-dots";
12001
+ const dotEls = [];
12002
+ for (let i = 0; i < count; i++) {
12003
+ const dot = document.createElement("span");
12004
+ if (i === 0) dot.classList.add("nr-hg-dot-active");
12005
+ dotEls.push(dot);
12006
+ dotContainer.appendChild(dot);
12007
+ }
12008
+ figure.appendChild(dotContainer);
11970
12009
  return figure;
11971
12010
  };
11972
12011
  var hovergallery_default = hovergalleryDirective;