|
@@ -268,6 +268,18 @@ export const limitSingleSvgPageHeight = () => {
|
|
|
|
|
|
}
|
|
|
|
|
|
+const isElementInViewport = (el: any) => {
|
|
|
+ const rect = el.getBoundingClientRect();
|
|
|
+ return (
|
|
|
+ rect.top >= 0 &&
|
|
|
+ rect.left >= 0 &&
|
|
|
+ rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
|
|
|
+ rect.right <= (window.innerWidth || document.documentElement.clientWidth)
|
|
|
+ );
|
|
|
+}
|
|
|
+const isNumeric = (str: any) => {
|
|
|
+ return /^\d+$/.test(str);
|
|
|
+ }
|
|
|
// 谱面优化
|
|
|
export const resetFormate = () => {
|
|
|
container.value = document.getElementById('scrollContainer')
|
|
@@ -296,14 +308,23 @@ export const resetFormate = () => {
|
|
|
const paths: SVGAElement[] = Array.from(staffline.querySelectorAll(".vf-measure > .vf-stave path"));
|
|
|
const dotModifiers: SVGAElement[] = Array.from(staffline.querySelectorAll(".vf-measure .vf-stopDot"));
|
|
|
const staves: SVGAElement[] = Array.from(staffline.querySelectorAll(".vf-measure > .vf-stave"));
|
|
|
+ const numberVfTexts = Array.from((container.value as HTMLElement).querySelectorAll(".vf-text > text"));
|
|
|
|
|
|
// 获取第一个线谱的y轴坐标
|
|
|
const firstLinePathY = paths[0]?.getBBox().y || 0
|
|
|
+ // D.C循环标记没有显示完全修复
|
|
|
// 反复标记 和 小节碰撞
|
|
|
- const repetWord = ["To Coda", "D.S. al Coda", "Coda"];
|
|
|
+ const repetWord = ["To Coda", "D.S. al Coda", "Coda", "D.C."];
|
|
|
texts
|
|
|
.filter((n) => repetWord.includes(n.textContent || ""))
|
|
|
.forEach((t) => {
|
|
|
+ // console.log('文本123',t.textContent,'是否在可视区域内',isElementInViewport(t))
|
|
|
+ // D.C循环标记不在可视区域内,需要修复移动其位置信息
|
|
|
+ if (t.textContent?.includes('D.C')) {
|
|
|
+ if (!isElementInViewport(t)) {
|
|
|
+ t.style.transform = `translateX(-40px)`;
|
|
|
+ }
|
|
|
+ }
|
|
|
vfbeams.forEach((curve) => {
|
|
|
const result = collisionDetection(t, curve);
|
|
|
const prePath: SVGAElement = t?.previousSibling as unknown as SVGAElement;
|
|
@@ -430,6 +451,14 @@ export const resetFormate = () => {
|
|
|
label.textContent = labelText.replace('#','♯')
|
|
|
}
|
|
|
});
|
|
|
+ // numberVfTexts.forEach((label: any) => {
|
|
|
+ // const labelText = label.textContent as string
|
|
|
+ // if (isNumeric(labelText)) {
|
|
|
+ // const _y = Number(label.getAttribute("y"))
|
|
|
+ // const endY = firstLinePathY ? firstLinePathY - musicalDistance : _y
|
|
|
+ // label.setAttribute("y", endY)
|
|
|
+ // }
|
|
|
+ // })
|
|
|
dotModifiers.forEach((group: any) => {
|
|
|
if (state.musicRenderType === 'fixedTone') {
|
|
|
group.setAttribute('transform', 'translate(3,-12)')
|