@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/angular.cjs CHANGED
@@ -2798,13 +2798,28 @@ var MediaPlugin = class {
2798
2798
  video.src = url;
2799
2799
  video.controls = true;
2800
2800
  video.playsInline = true;
2801
- video.style.maxWidth = "90%";
2802
- video.style.maxHeight = "90%";
2803
2801
  video.style.borderRadius = "8px";
2804
2802
  video.style.boxShadow = "0 8px 30px rgba(0,0,0,0.3)";
2805
2803
  video.style.backgroundColor = "#000000";
2804
+ video.style.objectFit = "contain";
2805
+ video.style.transition = "transform 0.2s ease";
2806
2806
  element = video;
2807
2807
  mediaElement = video;
2808
+ const onMeta = () => {
2809
+ if (video.videoWidth > 0 && video.videoHeight > 0) {
2810
+ naturalW = video.videoWidth;
2811
+ naturalH = video.videoHeight;
2812
+ }
2813
+ updateBaseDimensions();
2814
+ applyTransform();
2815
+ };
2816
+ if (video.readyState >= 1 && video.videoWidth > 0) {
2817
+ naturalW = video.videoWidth;
2818
+ naturalH = video.videoHeight;
2819
+ } else {
2820
+ video.addEventListener("loadedmetadata", onMeta, { once: true });
2821
+ video.addEventListener("canplay", onMeta, { once: true });
2822
+ }
2808
2823
  } else if (isAudio) {
2809
2824
  const audio = document.createElement("audio");
2810
2825
  audio.src = url;
@@ -2845,11 +2860,19 @@ var MediaPlugin = class {
2845
2860
  let fitMode = ctx?.options?.fitMode || "width";
2846
2861
  let isUserZoomed = false;
2847
2862
  const updateBaseDimensions = () => {
2848
- if (!isImage) return;
2849
- const img = element;
2850
- if (img.naturalWidth > 0 && img.naturalHeight > 0) {
2851
- naturalW = img.naturalWidth;
2852
- naturalH = img.naturalHeight;
2863
+ if (!isImage && !isVideo) return;
2864
+ if (isImage) {
2865
+ const img = element;
2866
+ if (img.naturalWidth > 0 && img.naturalHeight > 0) {
2867
+ naturalW = img.naturalWidth;
2868
+ naturalH = img.naturalHeight;
2869
+ }
2870
+ } else if (isVideo) {
2871
+ const vid = element;
2872
+ if (vid.videoWidth > 0 && vid.videoHeight > 0) {
2873
+ naturalW = vid.videoWidth;
2874
+ naturalH = vid.videoHeight;
2875
+ }
2853
2876
  }
2854
2877
  const availW = Math.max(100, ctx.container.clientWidth - 32);
2855
2878
  const availH = Math.max(100, ctx.container.clientHeight - 32);
@@ -2863,7 +2886,7 @@ var MediaPlugin = class {
2863
2886
  baseH = Math.max(1, Math.round(naturalH * fitRatio));
2864
2887
  };
2865
2888
  const applyTransform = () => {
2866
- if (isImage) {
2889
+ if (isImage || isVideo) {
2867
2890
  if (!isUserZoomed) {
2868
2891
  updateBaseDimensions();
2869
2892
  }
@@ -2874,10 +2897,10 @@ var MediaPlugin = class {
2874
2897
  sizer.style.width = `${boxW}px`;
2875
2898
  sizer.style.height = `${boxH}px`;
2876
2899
  sizer.style.margin = boxH < availH ? "auto 0" : "0";
2877
- const imgW = isRotated90 ? boxH : boxW;
2878
- const imgH = isRotated90 ? boxW : boxH;
2879
- element.style.width = `${imgW}px`;
2880
- element.style.height = `${imgH}px`;
2900
+ const elW = isRotated90 ? boxH : boxW;
2901
+ const elH = isRotated90 ? boxW : boxH;
2902
+ element.style.width = `${elW}px`;
2903
+ element.style.height = `${elH}px`;
2881
2904
  element.style.maxWidth = "none";
2882
2905
  element.style.maxHeight = "none";
2883
2906
  element.style.transform = rotation ? `rotate(${rotation}deg)` : "none";
@@ -2887,6 +2910,8 @@ var MediaPlugin = class {
2887
2910
  element.style.transform = `scale(${currentZoom}) rotate(${rotation}deg)`;
2888
2911
  }
2889
2912
  };
2913
+ updateBaseDimensions();
2914
+ applyTransform();
2890
2915
  if (isImage) {
2891
2916
  const img = element;
2892
2917
  if (img.complete && img.naturalWidth > 0) {
@@ -2931,7 +2956,7 @@ var MediaPlugin = class {
2931
2956
  currentZoom = level;
2932
2957
  applyTransform();
2933
2958
  } : void 0,
2934
- fitToPage: isImage ? () => {
2959
+ fitToPage: isImage || isVideo ? () => {
2935
2960
  isUserZoomed = false;
2936
2961
  fitMode = "page";
2937
2962
  currentZoom = 1;
@@ -2941,7 +2966,7 @@ var MediaPlugin = class {
2941
2966
  updateBaseDimensions();
2942
2967
  applyTransform();
2943
2968
  } : void 0,
2944
- fitToWidth: isImage ? () => {
2969
+ fitToWidth: isImage || isVideo ? () => {
2945
2970
  isUserZoomed = false;
2946
2971
  fitMode = "width";
2947
2972
  currentZoom = 1;
@@ -2951,7 +2976,7 @@ var MediaPlugin = class {
2951
2976
  updateBaseDimensions();
2952
2977
  applyTransform();
2953
2978
  } : void 0,
2954
- resetZoom: isImage ? () => {
2979
+ resetZoom: isImage || isVideo ? () => {
2955
2980
  isUserZoomed = false;
2956
2981
  fitMode = ctx?.options?.fitMode || "width";
2957
2982
  currentZoom = 1;