@noirmd/previewer 2.0.5 → 2.1.1

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.js CHANGED
@@ -11922,6 +11922,7 @@ var hover3d_default = hover3dDirective;
11922
11922
 
11923
11923
  // vanilla/directives/hovergallery.ts
11924
11924
  var IMG_RE3 = /!\[([^\]]*)\]\(([^)]+)\)/g;
11925
+ var MAX_IMAGES = 10;
11925
11926
  var hovergalleryDirective = ({ props, slots }) => {
11926
11927
  const images = [];
11927
11928
  const raw = slots.default || "";
@@ -11933,18 +11934,56 @@ var hovergalleryDirective = ({ props, slots }) => {
11933
11934
  if (images.length === 0) {
11934
11935
  return document.createDocumentFragment();
11935
11936
  }
11937
+ const count = Math.min(images.length, MAX_IMAGES);
11936
11938
  const figure = document.createElement("figure");
11937
11939
  figure.className = "nr-hover-gallery";
11938
11940
  if (props.aspect) figure.style.aspectRatio = props.aspect;
11939
11941
  if (props.class) figure.classList.add(...props.class.split(/\s+/).filter(Boolean));
11940
- if (props.style) figure.setAttribute("style", props.style);
11941
- for (const img of images) {
11942
+ if (props.style) figure.setAttribute("style", (figure.getAttribute("style") || "") + ";" + props.style);
11943
+ const imgEls = [];
11944
+ for (let i = 0; i < count; i++) {
11942
11945
  const el = document.createElement("img");
11943
- el.src = img.src;
11944
- el.alt = img.alt;
11946
+ el.src = images[i].src;
11947
+ el.alt = images[i].alt;
11945
11948
  el.loading = "lazy";
11949
+ el.draggable = false;
11950
+ if (i === 0) el.classList.add("nr-hg-active");
11951
+ imgEls.push(el);
11946
11952
  figure.appendChild(el);
11947
11953
  }
11954
+ for (let i = 0; i < count; i++) {
11955
+ const strip = document.createElement("div");
11956
+ strip.className = "nr-hg-trigger";
11957
+ strip.style.left = `${i / count * 100}%`;
11958
+ strip.style.width = `${1 / count * 100}%`;
11959
+ strip.addEventListener("mouseenter", () => {
11960
+ for (let j = 0; j < imgEls.length; j++) {
11961
+ imgEls[j].classList.toggle("nr-hg-active", j === i);
11962
+ }
11963
+ for (let j = 0; j < dotEls.length; j++) {
11964
+ dotEls[j].classList.toggle("nr-hg-dot-active", j === i);
11965
+ }
11966
+ });
11967
+ figure.appendChild(strip);
11968
+ }
11969
+ figure.addEventListener("mouseleave", () => {
11970
+ for (let j = 0; j < imgEls.length; j++) {
11971
+ imgEls[j].classList.toggle("nr-hg-active", j === 0);
11972
+ }
11973
+ for (let j = 0; j < dotEls.length; j++) {
11974
+ dotEls[j].classList.toggle("nr-hg-dot-active", j === 0);
11975
+ }
11976
+ });
11977
+ const dotContainer = document.createElement("div");
11978
+ dotContainer.className = "nr-hg-dots";
11979
+ const dotEls = [];
11980
+ for (let i = 0; i < count; i++) {
11981
+ const dot = document.createElement("span");
11982
+ if (i === 0) dot.classList.add("nr-hg-dot-active");
11983
+ dotEls.push(dot);
11984
+ dotContainer.appendChild(dot);
11985
+ }
11986
+ figure.appendChild(dotContainer);
11948
11987
  return figure;
11949
11988
  };
11950
11989
  var hovergallery_default = hovergalleryDirective;