Spaces:
Sleeping
Sleeping
Update static/js/editor.js
Browse files- static/js/editor.js +26 -8
static/js/editor.js
CHANGED
|
@@ -501,6 +501,9 @@ function updateOverlayContent(currentTime) {
|
|
| 501 |
const karaokeStyles = ['auto_director', 'karaoke_static'];
|
| 502 |
if(karaokeStyles.includes(state.st.name) && seg.words) {
|
| 503 |
let html = "";
|
|
|
|
|
|
|
|
|
|
| 504 |
seg.words.forEach((w, i) => {
|
| 505 |
let isActive = (currentTime >= w.start && currentTime <= w.end);
|
| 506 |
|
|
@@ -511,28 +514,43 @@ function updateOverlayContent(currentTime) {
|
|
| 511 |
let textColor = '#ffffff';
|
| 512 |
if (w.color) textColor = w.color;
|
| 513 |
|
| 514 |
-
|
|
|
|
| 515 |
|
| 516 |
if(isActive) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 517 |
html += `<span style="${baseStyle}
|
| 518 |
background-color: ${boxColor};
|
| 519 |
color: ${textColor} !important;
|
| 520 |
-
|
| 521 |
-
|
| 522 |
-
|
|
|
|
|
|
|
|
|
|
| 523 |
position: relative;
|
| 524 |
z-index: 100;
|
| 525 |
-
|
| 526 |
} else {
|
|
|
|
| 527 |
html += `<span style="${baseStyle}
|
| 528 |
color: ${textColor} !important;
|
| 529 |
text-shadow: none;
|
| 530 |
-
margin: 0 ${
|
| 531 |
-
padding:
|
| 532 |
position: relative;
|
| 533 |
-
z-index: 1;">${w.word}</span
|
| 534 |
}
|
| 535 |
|
|
|
|
| 536 |
if ((i + 1) % 5 === 0 && i !== seg.words.length - 1) {
|
| 537 |
html += "<br><br>";
|
| 538 |
}
|
|
|
|
| 501 |
const karaokeStyles = ['auto_director', 'karaoke_static'];
|
| 502 |
if(karaokeStyles.includes(state.st.name) && seg.words) {
|
| 503 |
let html = "";
|
| 504 |
+
// فاصله استاندارد بین کلمات (ثابت)
|
| 505 |
+
const GAP = 5;
|
| 506 |
+
|
| 507 |
seg.words.forEach((w, i) => {
|
| 508 |
let isActive = (currentTime >= w.start && currentTime <= w.end);
|
| 509 |
|
|
|
|
| 514 |
let textColor = '#ffffff';
|
| 515 |
if (w.color) textColor = w.color;
|
| 516 |
|
| 517 |
+
// استایل پایه: اینلاین-بلاک برای اعمال پدینگ/مارجین، و تراز عمودی وسط
|
| 518 |
+
let baseStyle = "display: inline-block; vertical-align: middle; transition: all 0.1s; font-family: inherit;";
|
| 519 |
|
| 520 |
if(isActive) {
|
| 521 |
+
// تکنیک حاشیه منفی:
|
| 522 |
+
// 1. padding: کادر را بزرگ میکند.
|
| 523 |
+
// 2. margin منفی: اثر padding را خنثی میکند تا بقیه کلمات هل داده نشوند.
|
| 524 |
+
// فرمول افقی: فاصله استاندارد (GAP) منهای پدینگ تنظیمی
|
| 525 |
+
// فرمول عمودی: منفی پدینگ تنظیمی (برای جلوگیری از پریدن خط بالا/پایین)
|
| 526 |
+
|
| 527 |
+
let py = state.st.paddingY;
|
| 528 |
+
let px = state.st.paddingX;
|
| 529 |
+
|
| 530 |
html += `<span style="${baseStyle}
|
| 531 |
background-color: ${boxColor};
|
| 532 |
color: ${textColor} !important;
|
| 533 |
+
border-radius: ${state.st.radius}px;
|
| 534 |
+
box-shadow: 0 0 10px rgba(0,0,0,0.3);
|
| 535 |
+
|
| 536 |
+
padding: ${py}px ${px}px;
|
| 537 |
+
margin: -${py}px calc(${GAP}px - ${px}px);
|
| 538 |
+
|
| 539 |
position: relative;
|
| 540 |
z-index: 100;
|
| 541 |
+
white-space: nowrap;">${w.word}</span>`;
|
| 542 |
} else {
|
| 543 |
+
// کلمات غیرفعال: فقط فاصله استاندارد را دارند
|
| 544 |
html += `<span style="${baseStyle}
|
| 545 |
color: ${textColor} !important;
|
| 546 |
text-shadow: none;
|
| 547 |
+
margin: 0 ${GAP}px;
|
| 548 |
+
padding: 0;
|
| 549 |
position: relative;
|
| 550 |
+
z-index: 1;">${w.word}</span>`;
|
| 551 |
}
|
| 552 |
|
| 553 |
+
// شکستن خطوط
|
| 554 |
if ((i + 1) % 5 === 0 && i !== seg.words.length - 1) {
|
| 555 |
html += "<br><br>";
|
| 556 |
}
|