@files-preview-app/preview-file 1.3.10 → 1.3.11

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
@@ -2717,13 +2717,28 @@ var MediaPlugin = class {
2717
2717
  video.src = url;
2718
2718
  video.controls = true;
2719
2719
  video.playsInline = true;
2720
- video.style.maxWidth = "90%";
2721
- video.style.maxHeight = "90%";
2722
2720
  video.style.borderRadius = "8px";
2723
2721
  video.style.boxShadow = "0 8px 30px rgba(0,0,0,0.3)";
2724
2722
  video.style.backgroundColor = "#000000";
2723
+ video.style.objectFit = "contain";
2724
+ video.style.transition = "transform 0.2s ease";
2725
2725
  element = video;
2726
2726
  mediaElement = video;
2727
+ const onMeta = () => {
2728
+ if (video.videoWidth > 0 && video.videoHeight > 0) {
2729
+ naturalW = video.videoWidth;
2730
+ naturalH = video.videoHeight;
2731
+ }
2732
+ updateBaseDimensions();
2733
+ applyTransform();
2734
+ };
2735
+ if (video.readyState >= 1 && video.videoWidth > 0) {
2736
+ naturalW = video.videoWidth;
2737
+ naturalH = video.videoHeight;
2738
+ } else {
2739
+ video.addEventListener("loadedmetadata", onMeta, { once: true });
2740
+ video.addEventListener("canplay", onMeta, { once: true });
2741
+ }
2727
2742
  } else if (isAudio) {
2728
2743
  const audio = document.createElement("audio");
2729
2744
  audio.src = url;
@@ -2764,11 +2779,19 @@ var MediaPlugin = class {
2764
2779
  let fitMode = ctx?.options?.fitMode || "width";
2765
2780
  let isUserZoomed = false;
2766
2781
  const updateBaseDimensions = () => {
2767
- if (!isImage) return;
2768
- const img = element;
2769
- if (img.naturalWidth > 0 && img.naturalHeight > 0) {
2770
- naturalW = img.naturalWidth;
2771
- naturalH = img.naturalHeight;
2782
+ if (!isImage && !isVideo) return;
2783
+ if (isImage) {
2784
+ const img = element;
2785
+ if (img.naturalWidth > 0 && img.naturalHeight > 0) {
2786
+ naturalW = img.naturalWidth;
2787
+ naturalH = img.naturalHeight;
2788
+ }
2789
+ } else if (isVideo) {
2790
+ const vid = element;
2791
+ if (vid.videoWidth > 0 && vid.videoHeight > 0) {
2792
+ naturalW = vid.videoWidth;
2793
+ naturalH = vid.videoHeight;
2794
+ }
2772
2795
  }
2773
2796
  const availW = Math.max(100, ctx.container.clientWidth - 32);
2774
2797
  const availH = Math.max(100, ctx.container.clientHeight - 32);
@@ -2782,7 +2805,7 @@ var MediaPlugin = class {
2782
2805
  baseH = Math.max(1, Math.round(naturalH * fitRatio));
2783
2806
  };
2784
2807
  const applyTransform = () => {
2785
- if (isImage) {
2808
+ if (isImage || isVideo) {
2786
2809
  if (!isUserZoomed) {
2787
2810
  updateBaseDimensions();
2788
2811
  }
@@ -2793,10 +2816,10 @@ var MediaPlugin = class {
2793
2816
  sizer.style.width = `${boxW}px`;
2794
2817
  sizer.style.height = `${boxH}px`;
2795
2818
  sizer.style.margin = boxH < availH ? "auto 0" : "0";
2796
- const imgW = isRotated90 ? boxH : boxW;
2797
- const imgH = isRotated90 ? boxW : boxH;
2798
- element.style.width = `${imgW}px`;
2799
- element.style.height = `${imgH}px`;
2819
+ const elW = isRotated90 ? boxH : boxW;
2820
+ const elH = isRotated90 ? boxW : boxH;
2821
+ element.style.width = `${elW}px`;
2822
+ element.style.height = `${elH}px`;
2800
2823
  element.style.maxWidth = "none";
2801
2824
  element.style.maxHeight = "none";
2802
2825
  element.style.transform = rotation ? `rotate(${rotation}deg)` : "none";
@@ -2806,6 +2829,8 @@ var MediaPlugin = class {
2806
2829
  element.style.transform = `scale(${currentZoom}) rotate(${rotation}deg)`;
2807
2830
  }
2808
2831
  };
2832
+ updateBaseDimensions();
2833
+ applyTransform();
2809
2834
  if (isImage) {
2810
2835
  const img = element;
2811
2836
  if (img.complete && img.naturalWidth > 0) {
@@ -2850,7 +2875,7 @@ var MediaPlugin = class {
2850
2875
  currentZoom = level;
2851
2876
  applyTransform();
2852
2877
  } : void 0,
2853
- fitToPage: isImage ? () => {
2878
+ fitToPage: isImage || isVideo ? () => {
2854
2879
  isUserZoomed = false;
2855
2880
  fitMode = "page";
2856
2881
  currentZoom = 1;
@@ -2860,7 +2885,7 @@ var MediaPlugin = class {
2860
2885
  updateBaseDimensions();
2861
2886
  applyTransform();
2862
2887
  } : void 0,
2863
- fitToWidth: isImage ? () => {
2888
+ fitToWidth: isImage || isVideo ? () => {
2864
2889
  isUserZoomed = false;
2865
2890
  fitMode = "width";
2866
2891
  currentZoom = 1;
@@ -2870,7 +2895,7 @@ var MediaPlugin = class {
2870
2895
  updateBaseDimensions();
2871
2896
  applyTransform();
2872
2897
  } : void 0,
2873
- resetZoom: isImage ? () => {
2898
+ resetZoom: isImage || isVideo ? () => {
2874
2899
  isUserZoomed = false;
2875
2900
  fitMode = ctx?.options?.fitMode || "width";
2876
2901
  currentZoom = 1;