fixed dragability after new statment is added

This commit is contained in:
Thomas 2022-04-09 18:59:28 -05:00
parent 83374615aa
commit 8fbab92e1b
5 changed files with 16 additions and 8 deletions

View File

@ -1,20 +1,17 @@
<script setup lang="ts">
import { ref } from "vue";
import { RichTextBox } from "../types.ts";
import { stepX, stepY } from "../support/const.ts";
const props = defineProps({
value: {
type: RichTextBox,
},
// statement: { type: String, required: true },
// startingX: { type: Number, default: 0 },
// startingY: { type: Number, default: 0 },
});
</script>
<template>
<Draggable
:grid="[5, 5]"
:grid="[stepX, stepY]"
:default-position="{ x: props.value.x, y: props.value.y }"
>
<div style="display: flex; bottom: 10px; right: 0">

View File

@ -11,6 +11,7 @@ import VarDeclEditor from './VarDeclEditor.vue'
import ExpressionEditor from './ExpressionEditor.vue'
import TextBox from '../components/TextBox.vue'
import {RichTextBox} from "../types.ts";
import { stepX, stepY } from "../support/const.ts";
const math = new MathPage(uuidv4())
const statements = ref<MathStatement[]>([])
@ -114,15 +115,18 @@ function richUpdateValue() {
<q-page-container id="editor" >
<!-- <WrapperBox />-->
<span v-for="statement in statements">
<span v-for="statement in statements" style="display: flex">
<Draggable
:grid="[25, 25]"
:grid="[stepX, stepY]"
>
<div>
<Statement
:key="statementsKey"
:statement="statement"
:evaluation="evaluation"
/>
</div>
</Draggable>
</span>

2
src/support/const.ts Normal file
View File

@ -0,0 +1,2 @@
export const stepX = 5
export const stepY = 5

View File

@ -269,6 +269,9 @@ export class MathStatement {
/** The raw statement input by the user. */
public readonly raw: string,
public x: Number = 0,
public y: Number = 0,
) {}
/** Parse the raw statement to an AST. */

View File

@ -98,5 +98,7 @@ export class RichTextBox {
public text: string = '',
public x: Number = 0,
public y: Number = 0,
) {}
) {
}
}