|
@@ -1,4 +1,4 @@
|
|
|
-import { defineComponent, watch } from "vue";
|
|
|
+import { defineComponent, ref, watch } from "vue";
|
|
|
import { string } from "vue-types";
|
|
|
import { useCompData } from ".";
|
|
|
import { View } from "../View";
|
|
@@ -11,9 +11,10 @@ export const Component = defineComponent({
|
|
|
compId: string().isRequired,
|
|
|
},
|
|
|
setup(props) {
|
|
|
- const { store, controls } = useEditor();
|
|
|
+ const { store, controls, actions } = useEditor();
|
|
|
const comp = useCompData(props.compId);
|
|
|
const { value } = comp;
|
|
|
+ const videoRef = ref();
|
|
|
|
|
|
async function changeVal() {
|
|
|
try {
|
|
@@ -28,7 +29,10 @@ export const Component = defineComponent({
|
|
|
watch(
|
|
|
() => [value.ratio],
|
|
|
() => {
|
|
|
- comp.setH(comp.getW() / value.ratio);
|
|
|
+ const { videoWidth, videoHeight } = videoRef.value;
|
|
|
+ const t = value.ratio || videoWidth / videoHeight;
|
|
|
+ comp.setH(comp.getW() / t);
|
|
|
+ actions.onCompLayoutUpdated(comp);
|
|
|
}
|
|
|
);
|
|
|
|
|
@@ -41,6 +45,8 @@ export const Component = defineComponent({
|
|
|
return (
|
|
|
<View class={rootCls} compId={props.compId}>
|
|
|
<video
|
|
|
+ ref={videoRef}
|
|
|
+ key={value.url}
|
|
|
class="w-full object-cover"
|
|
|
style={{ aspectRatio: value.ratio }}
|
|
|
{...options}
|