zf-dbs 1.0.0 → 2.0.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.
@@ -1,4 +1,4 @@
1
- import { Z as e } from "./CIg5yiwu.mjs";
1
+ import { Z as e } from "./DbOTUn3A.mjs";
2
2
  const t = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3
3
  __proto__: null,
4
4
  ZfScaleContainer: e,
@@ -0,0 +1,133 @@
1
+ import { defineComponent as v, ref as c, onMounted as w, onBeforeUnmount as $, computed as x, openBlock as _, createElementBlock as b, createElementVNode as E, normalizeStyle as F, unref as S, renderSlot as z, nextTick as O } from "vue";
2
+ import { _ as y } from "./CHgC5LLL.mjs";
3
+ const M = /* @__PURE__ */ v({
4
+ __name: "zf-scale-container",
5
+ props: {
6
+ width: { default: void 0 },
7
+ height: { default: void 0 },
8
+ mode: { default: "aspectFit" }
9
+ },
10
+ setup(f) {
11
+ const t = f, r = c(null), a = c(0), i = c(0);
12
+ let s = !1;
13
+ const o = () => {
14
+ s || (s = !0, O(() => {
15
+ a.value = r.value?.clientWidth || 0, i.value = r.value?.clientHeight || 0, s = !1;
16
+ }));
17
+ };
18
+ w(() => {
19
+ window.addEventListener("resize", o), o();
20
+ }), $(() => {
21
+ window.removeEventListener("resize", o);
22
+ });
23
+ const m = {
24
+ // 自适应模式
25
+ adaptive(e) {
26
+ const n = a.value / t.width, l = i.value / t.height, h = e ?? a.value < i.value, p = h ? n : l, d = h ? t.width : a.value / l, u = h ? i.value / n : t.height;
27
+ return d < t.width || u < t.height ? Math.abs(n - l) > 0.2 ? this.aspectFit() : this.scaleToFill() : {
28
+ width: `${d}px`,
29
+ height: `${u}px`,
30
+ transform: `scale(${p}, ${p}) translate(-50%, -50%)`,
31
+ transformOrigin: "0 0",
32
+ position: "absolute",
33
+ top: "50%",
34
+ left: "50%"
35
+ };
36
+ },
37
+ adaptiveX() {
38
+ return this.adaptive(!1);
39
+ },
40
+ adaptiveY() {
41
+ return this.adaptive(!0);
42
+ },
43
+ // 缩放模式,不保持纵横比缩放图片,使图片的宽高完全拉伸至填满元素
44
+ scaleToFill() {
45
+ const e = a.value / t.width, n = i.value / t.height;
46
+ return {
47
+ width: `${t.width}px`,
48
+ height: `${t.height}px`,
49
+ transform: `scale(${e}, ${n})`,
50
+ transformOrigin: "0 0"
51
+ };
52
+ },
53
+ // 保持纵横比缩放模式
54
+ aspectFit() {
55
+ const e = Math.min(a.value / t.width, i.value / t.height);
56
+ return {
57
+ width: `${t.width}px`,
58
+ height: `${t.height}px`,
59
+ transform: `scale(${e}, ${e}) translate(-50%, -50%)`,
60
+ transformOrigin: "0 0",
61
+ position: "absolute",
62
+ top: "50%",
63
+ left: "50%"
64
+ };
65
+ },
66
+ // 保持纵横比缩放模式
67
+ aspectFill() {
68
+ const e = Math.max(a.value / t.width, i.value / t.height);
69
+ return {
70
+ width: `${t.width}px`,
71
+ height: `${t.height}px`,
72
+ transform: `scale(${e}, ${e}) translate(-50%, -50%)`,
73
+ transformOrigin: "0 0",
74
+ position: "absolute",
75
+ top: "50%",
76
+ left: "50%"
77
+ };
78
+ },
79
+ // 宽度不变,高度自动变化,保持原图宽高比不变,只保证图片的宽度能完全显示出来。
80
+ widthFix() {
81
+ const e = a.value / t.width;
82
+ return {
83
+ width: `${t.width}px`,
84
+ height: `${t.height}px`,
85
+ transform: `scale(${e}, ${e}) translate(-50%, -50%)`,
86
+ transformOrigin: "0 0",
87
+ position: "absolute",
88
+ top: "50%",
89
+ left: "50%"
90
+ };
91
+ },
92
+ // 高度不变,宽度自动变化,保持原图宽高比不变,只保证图片的高度能完全显示出来。
93
+ heightFix() {
94
+ const e = i.value / t.height;
95
+ return {
96
+ width: `${t.width}px`,
97
+ height: `${t.height}px`,
98
+ transform: `scale(${e}, ${e}) translate(-50%, -50%)`,
99
+ transformOrigin: "0 0",
100
+ position: "absolute",
101
+ top: "50%",
102
+ left: "50%"
103
+ };
104
+ },
105
+ // 裁剪模式,不缩放图片,只显示图片的中间区域。
106
+ center() {
107
+ return {
108
+ width: `${t.width}px`,
109
+ height: `${t.height}px`,
110
+ position: "absolute",
111
+ top: "50%",
112
+ left: "50%",
113
+ transform: "translate(-50%, -50%)"
114
+ };
115
+ }
116
+ }, g = x(() => m[t.mode]?.() ?? {});
117
+ return (e, n) => (_(), b("div", {
118
+ ref_key: "containerElement",
119
+ ref: r,
120
+ class: "zf-scale-container"
121
+ }, [
122
+ E("div", {
123
+ class: "zf-scale-wrapper",
124
+ style: F(S(g))
125
+ }, [
126
+ z(e.$slots, "default", {}, void 0, !0)
127
+ ], 4)
128
+ ], 512));
129
+ }
130
+ }), L = /* @__PURE__ */ y(M, [["__scopeId", "data-v-21eb743f"]]);
131
+ export {
132
+ L as Z
133
+ };