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