add documentInit

This commit is contained in:
Harvey Zack committed 2023-04-17 22:04:57 +08:00
1 parent d531c41735
commit c4252b21b5
11 files changed
+60 -67

No files matched your search

+3 -22
View File
@@ -49,15 +49,9 @@ export default function progress(options) {
const $indicator = query('.art-progress-indicator', $control);
const $tip = query('.art-progress-tip', $control);
const { INDICATOR_SIZE, INDICATOR_SIZE_ICON, INDICATOR_SIZE_MOBILE, INDICATOR_SIZE_MOBILE_ICON } =
art.constructor;
setStyle($played, 'backgroundColor', 'var(--art-theme)');
let indicatorSize = INDICATOR_SIZE;
if (icons.indicator) {
indicatorSize = INDICATOR_SIZE_ICON;
append($indicator, icons.indicator);
} else {
setStyles($indicator, {
@@ -65,19 +59,6 @@ export default function progress(options) {
});
}
if (isMobile) {
indicatorSize = INDICATOR_SIZE_MOBILE;
if (icons.indicator) {
indicatorSize = INDICATOR_SIZE_MOBILE_ICON;
}
}
setStyles($indicator, {
left: `-${indicatorSize / 2}px`,
width: `${indicatorSize}px`,
height: `${indicatorSize}px`,
});
function showHighlight(event) {
const { width } = getPosFromEvent(art, event);
const { text } = event.target.dataset;
@@ -112,7 +93,7 @@ export default function progress(options) {
if (type === 'played') {
setStyle($played, 'width', `${percentage * 100}%`);
setStyle($indicator, 'left', `calc(${percentage * 100}% - ${indicatorSize / 2}px)`);
setStyle($indicator, 'left', `calc(${percentage * 100}% - var(--art-indicator-size) / 2)`);
}
}
@@ -175,7 +156,7 @@ export default function progress(options) {
isDroging = event.button === 0;
});
proxy(document, 'mousemove', (event) => {
art.on('document:mousemove', (event) => {
if (isDroging) {
const { second, percentage } = getPosFromEvent(art, event);
setBar('played', percentage);
@@ -183,7 +164,7 @@ export default function progress(options) {
}
});
proxy(document, 'mouseup', () => {
art.on('document:mouseup', () => {
if (isDroging) {
isDroging = false;
}
+2 -2
View File
@@ -59,14 +59,14 @@ export default function volume(option) {
art.volume = getVolumeFromEvent(event);
});
proxy(document, 'mousemove', (event) => {
art.on('document:mousemove', (event) => {
if (isDroging) {
art.muted = false;
art.volume = getVolumeFromEvent(event);
}
});
proxy(document, 'mouseup', () => {
art.on('document:mouseup', () => {
if (isDroging) {
isDroging = false;
}