Skip to content

Commit f7e1884

Browse files
committed
切割线数据并入结构
1 parent 909390b commit f7e1884

File tree

6 files changed

+207
-70
lines changed

6 files changed

+207
-70
lines changed

src/editor/inputs/linear.vue

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
<div class="fields">
1111
<span class="label"> 切线与割线 </span>
1212
<s-popup class="derivate-popup input" align="right">
13-
<s-button type="outlined" slot="trigger"> 设置面板 </s-button>
14-
<DerivatePane :self="self"/>
13+
<s-button type="outlined" slot="trigger">
14+
设置面板 <s-icon name="chevron_right" slot="end"></s-icon>
15+
</s-button>
16+
<DerivatePane :self="self" />
1517
</s-popup>
1618
<span class="label"> {{ t("data.more.range") }} </span>
1719
<Domain :self="self" />
@@ -37,6 +39,16 @@
3739
<s-checkbox type="checkbox" v-model.lazy="self.skipTip">
3840
{{ t("data.more.skipTip") }}
3941
<HelpIcon> {{ t("data.more.skipTipHelp") }} </HelpIcon>
42+
<HelpIcon
43+
v-if="
44+
self.skipTip &&
45+
(self.derivative?.updateOnMouseMove ||
46+
self.secants.some((s) => s.updateOnMouseMove))
47+
"
48+
type="warn"
49+
>
50+
“隐藏悬浮提示”启用时,切线与割线跟随鼠标不生效
51+
</HelpIcon>
4052
</s-checkbox>
4153
</div>
4254
</div>
@@ -46,7 +58,7 @@
4658

4759
<script setup lang="ts">
4860
import { PrivateDataTypes } from "@/types/data";
49-
import { toRef } from "vue";
61+
import { toRef } from "vue";
5062
import { useI18n } from "vue-i18n";
5163
import { I18nSchema } from "@/i18n";
5264
const { t } = useI18n<{ message: I18nSchema }>();
@@ -64,6 +76,4 @@ import ColorPicker from "./subblocks/colorPicker.vue";
6476
import Domain from "./subblocks/domain.vue";
6577
import DerivatePane from "./subblocks/derivatePane.vue";
6678
import "./inputs.scss";
67-
6879
</script>
69-

src/editor/inputs/subblocks/derivatePane.vue

Lines changed: 65 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119

120120
<script lang="ts" setup>
121121
import { PrivateDataTypes } from "@/types/data";
122-
import { computed, reactive, ref, toRef } from "vue";
122+
import { computed, reactive, ref, toRef, watchEffect } from "vue";
123123
import FunctionField from "./function.vue";
124124
125125
import AnimatedList from "@/ui/animated/animatedList.vue";
@@ -133,30 +133,87 @@ const props = defineProps<{
133133
const tab = ref("derivate");
134134
const self = toRef(props, "self");
135135
136-
const derivateEnabled = ref(false);
137-
const derivateFn = ref("");
138-
const derivFollowMouseStr = ref("followMouse");
136+
const initDerivate = self.value.derivative ?? {
137+
fn: "",
138+
updateOnMouseMove: true,
139+
x0: "" as number | "",
140+
};
141+
142+
const derivateEnabled = ref(self.value.derivative !== undefined);
143+
const derivateFn = ref(initDerivate.fn);
144+
const derivFollowMouseStr = ref(
145+
initDerivate.updateOnMouseMove ? "followMouse" : "manual"
146+
);
139147
const derivFollowMouse = computed(
140148
() => derivFollowMouseStr.value === "followMouse"
141149
);
142-
const derivateX = ref(0);
150+
const derivateX = ref<number | "">(initDerivate.x0 ?? "");
151+
const derivateReady = computed(
152+
(): undefined | PrivateDataTypes.LinearPart.Derivative => {
153+
if (!derivateEnabled.value) return undefined;
154+
if (derivFollowMouse.value)
155+
return {
156+
fn: derivateFn.value,
157+
updateOnMouseMove: true,
158+
};
159+
return {
160+
fn: derivateFn.value,
161+
updateOnMouseMove: false,
162+
x0: derivateX.value || 0,
163+
};
164+
}
165+
);
166+
watchEffect(() => {
167+
self.value.derivative = derivateReady.value;
168+
});
143169
144-
const secantEnabled = ref(false);
170+
const initSecant = self.value.secants;
171+
const secantEnabled = ref(initSecant.length > 0);
145172
const secantArr = reactive<
146173
{
147174
key: number;
148175
followMouse: boolean;
149176
x1: number | "";
150177
x2: number | "";
151178
}[]
152-
>([]);
179+
>(
180+
initSecant.map((item) => ({
181+
key: Math.random(),
182+
followMouse: item.updateOnMouseMove,
183+
x1: item.x0,
184+
x2: item.x1 || "",
185+
}))
186+
);
187+
const secantReady = computed((): PrivateDataTypes.LinearPart.Secant[] => {
188+
if (!secantEnabled.value) return [];
189+
return secantArr.flatMap((item) => {
190+
if (item.x1 === "") return [];
191+
if (item.followMouse)
192+
return {
193+
x0: item.x1,
194+
updateOnMouseMove: true,
195+
};
196+
if (item.x2 === "") return [];
197+
return {
198+
x0: item.x1,
199+
x1: item.x2,
200+
updateOnMouseMove: false,
201+
};
202+
});
203+
});
204+
watchEffect(() => {
205+
self.value.secants = secantReady.value;
206+
});
153207
</script>
154208

155209
<style lang="scss">
156210
.derivate-pane {
157211
width: 25em;
158212
s-tab {
159213
background-color: var(--s-color-surface-container-low);
214+
border-top-left-radius: 3px;
215+
border-top-right-radius: 3px;
216+
overflow: hidden;
160217
}
161218
.tab-text {
162219
display: flex;
@@ -172,7 +229,7 @@ const secantArr = reactive<
172229
&-leave-active {
173230
transition:
174231
opacity 0.1s,
175-
margin-left 0.5s cubic-bezier(0, 1, 0, 1);
232+
margin-left 0.5s cubic-bezier(0.075, 0.82, 0.165, 1);
176233
}
177234
&-leave-to,
178235
&-enter-from {

src/editor/inputs/subblocks/helpIcon.vue

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
<template>
2-
<s-tooltip>
3-
<SIconInfo class="help" slot="trigger" />
2+
<s-tooltip @click.stop>
3+
<SIconWarn v-if="props.type === 'warn'" class="help warn" slot="trigger" />
4+
<SIconInfo v-else class="help" slot="trigger" />
45
<slot></slot>
56
</s-tooltip>
67
</template>
78

89
<script setup lang="ts">
910
import SIconInfo from "@/ui/icons/info.vue";
11+
import SIconWarn from "@/ui/icons/warn.vue";
12+
13+
const props = defineProps<{
14+
type?: "info" | "warn";
15+
}>();
1016
</script>
1117

1218
<style scoped lang="scss">
@@ -21,5 +27,13 @@ import SIconInfo from "@/ui/icons/info.vue";
2127
&:hover {
2228
opacity: 1;
2329
}
30+
31+
&.warn {
32+
color: var(--s-color-warning);
33+
animation:
34+
bouncein var(--s-motion-duration-medium4)
35+
var(--s-motion-easing-emphasized),
36+
breathe 2s infinite;
37+
}
2438
}
2539
</style>

src/graph/graph.vue

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -193,28 +193,8 @@ s-icon.spin {
193193
}
194194
195195
s-icon.bouncein {
196-
animation: bouncein var(--s-motion-duration-medium4)
197-
var(--s-motion-easing-emphasized);
198-
}
199-
200-
@keyframes rotate {
201-
0% {
202-
transform: rotate(0deg);
203-
}
204-
100% {
205-
transform: rotate(360deg);
206-
}
207-
}
208-
209-
@keyframes bouncein {
210-
0% {
211-
transform: scale(1);
212-
}
213-
50% {
214-
transform: scale(1.3);
215-
}
216-
100% {
217-
transform: scale(1);
218-
}
196+
animation:
197+
bouncein var(--s-motion-duration-medium4) var(--s-motion-easing-emphasized),
198+
breathe 2s infinite;
219199
}
220200
</style>

src/public.scss

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,39 @@ input[type="number"] {
7070
position: relative;
7171
}
7272

73+
@keyframes rotate {
74+
0% {
75+
transform: rotate(0deg);
76+
}
77+
100% {
78+
transform: rotate(360deg);
79+
}
80+
}
81+
82+
@keyframes bouncein {
83+
0% {
84+
transform: scale(1);
85+
}
86+
50% {
87+
transform: scale(1.3);
88+
}
89+
100% {
90+
transform: scale(1);
91+
}
92+
}
93+
94+
@keyframes breathe {
95+
0% {
96+
opacity: 1;
97+
}
98+
50% {
99+
opacity: 0.6;
100+
}
101+
100% {
102+
opacity: 1;
103+
}
104+
}
105+
73106
s-page {
74107
--s-color-scrim: #000000;
75108
--s-color-primary: #00639a;

0 commit comments

Comments
 (0)