vfit 0.1.11 → 0.1.13
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/fitscale.es.js +7 -6
- package/dist/fitscale.umd.js +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/fitscale.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent, reactive, computed, inject, ref, watch, createElementBlock, openBlock, normalizeStyle,
|
|
1
|
+
import { defineComponent, reactive, computed, inject, ref, watch, createElementBlock, openBlock, normalizeStyle, renderSlot } from "vue";
|
|
2
2
|
function observeScale(target, designHeight, onScale) {
|
|
3
3
|
const observer = new ResizeObserver((entries) => {
|
|
4
4
|
for (const entry of entries) {
|
|
@@ -24,7 +24,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
24
24
|
bottom: { type: Number },
|
|
25
25
|
left: { type: Number },
|
|
26
26
|
right: { type: Number },
|
|
27
|
-
unit: { type: String, default: "px" }
|
|
27
|
+
unit: { type: String, default: "px" },
|
|
28
|
+
z: { type: Number, default: 300 }
|
|
28
29
|
},
|
|
29
30
|
setup(__props) {
|
|
30
31
|
const position = reactive({
|
|
@@ -59,11 +60,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
59
60
|
}, { immediate: true });
|
|
60
61
|
return (_ctx, _cache) => {
|
|
61
62
|
return openBlock(), createElementBlock("div", {
|
|
62
|
-
class:
|
|
63
|
-
style: normalizeStyle({ transform: position.scale, transformOrigin: origin.value, top: position.top, bottom: position.bottom, left: position.left, right: position.right })
|
|
63
|
+
class: "fit-container",
|
|
64
|
+
style: normalizeStyle({ transform: position.scale, transformOrigin: origin.value, top: position.top, bottom: position.bottom, left: position.left, right: position.right, zIndex: props.z })
|
|
64
65
|
}, [
|
|
65
66
|
renderSlot(_ctx.$slots, "default", {}, void 0, true)
|
|
66
|
-
],
|
|
67
|
+
], 4);
|
|
67
68
|
};
|
|
68
69
|
}
|
|
69
70
|
});
|
|
@@ -74,7 +75,7 @@ const _export_sfc = (sfc, props) => {
|
|
|
74
75
|
}
|
|
75
76
|
return target;
|
|
76
77
|
};
|
|
77
|
-
const FitContainer = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
78
|
+
const FitContainer = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-1954a495"]]);
|
|
78
79
|
const FitScaleKey = Symbol("FitScale");
|
|
79
80
|
function createFitScale(options = {}) {
|
|
80
81
|
const fitScale = ref(1);
|
package/dist/fitscale.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(t,e){typeof exports==="object"&&typeof module!=="undefined"?e(exports,require("vue")):typeof define==="function"&&define.amd?define(["exports","vue"],e):(t=typeof globalThis!=="undefined"?globalThis:t||self,e(t.FitScale={},t.Vue))})(this,function(t,e){"use strict";function o(t,e,o){const n=new ResizeObserver(t=>{for(const n of t){const t=n.contentRect.height;const
|
|
1
|
+
(function(t,e){typeof exports==="object"&&typeof module!=="undefined"?e(exports,require("vue")):typeof define==="function"&&define.amd?define(["exports","vue"],e):(t=typeof globalThis!=="undefined"?globalThis:t||self,e(t.FitScale={},t.Vue))})(this,function(t,e){"use strict";function o(t,e,o){const n=new ResizeObserver(t=>{for(const n of t){const t=n.contentRect.height;const r=n.contentRect.width;let i;if(r/t<1.7666666666666666){i=r/1920*.98}else{i=t/e}o(i)}});n.observe(t);return n}const n=e.defineComponent({__name:"FitContainer",props:{scale:{type:Number,default:0},top:{type:Number},bottom:{type:Number},left:{type:Number},right:{type:Number},unit:{type:String,default:"px"},z:{type:Number,default:300}},setup(t){const o=e.reactive({scale:`scale(1)`,top:"auto",bottom:"auto",left:"auto",right:"auto"});const n=t;const r=e.computed(()=>{const t=n.right!==void 0;const e=n.bottom!==void 0;if(t&&e)return"100% 100%";if(t)return"100% 0";if(e)return"0 100%";return"0 0"});const i=e.inject(c,e.ref(1));e.watch([()=>n.scale,i],()=>{const t=n.scale&&n.scale>0?n.scale:(i==null?void 0:i.value)??1;o.scale=`scale(${t})`;const e=["top","bottom","left","right"];e.forEach(e=>{const r=n[e];if(n.unit==="%"){o[e]=r==void 0?"auto":`${r}${n.unit}`}else{o[e]=r==void 0?"auto":`${r*t}${n.unit}`}})},{immediate:true});return(t,i)=>(e.openBlock(),e.createElementBlock("div",{class:"fit-container",style:e.normalizeStyle({transform:o.scale,transformOrigin:r.value,top:o.top,bottom:o.bottom,left:o.left,right:o.right,zIndex:n.z})},[e.renderSlot(t.$slots,"default",{},void 0,true)],4))}});const r=(t,e)=>{const o=t.__vccOpts||t;for(const[n,r]of e){o[n]=r}return o};const i=r(n,[["__scopeId","data-v-1954a495"]]);const c=Symbol("FitScale");function s(t={}){const n=e.ref(1);return{install(e){const r=typeof t.target==="string"?document.querySelector(t.target):t.target;const s=r||document.querySelector("#app");o(s,t.designHeight??1080,t=>{n.value=t});e.provide(c,n);e.config.globalProperties.$fitScale=n;e.component("FitContainer",i)}}}function a(){const t=e.inject(c,e.ref(1));return t}t.FitContainer=i;t.FitScaleKey=c;t.createFitScale=s;t.useFitScale=a;Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});
|
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.fit-container[data-v-
|
|
1
|
+
.fit-container[data-v-1954a495]{position:absolute;transform-origin:0 0;z-index:300;will-change:transform}
|