fix: time markers on video slider for quiz

This commit is contained in:
Jannat Patel
2025-06-16 12:07:39 +05:30
parent 3a2a0313ac
commit cb797223ed

View File

@@ -64,15 +64,28 @@
<Pause v-else @click="pauseVideo" class="size-5 text-ink-white" /> <Pause v-else @click="pauseVideo" class="size-5 text-ink-white" />
</template> </template>
</Button> </Button>
<input
type="range" <div class="relative flex items-center w-full flex-1">
min="0" <input
:max="duration" type="range"
step="0.1" min="0"
v-model="currentTime" :max="duration"
@input="changeCurrentTime" step="0.1"
class="duration-slider w-full h-1" v-model="currentTime"
/> @input="changeCurrentTime"
class="duration-slider h-1"
/>
<!-- QUIZ MARKERS -->
<div class="absolute top-0 left-0 w-full h-full pointer-events-none">
<div
v-for="(quiz, index) in quizzes"
:key="index"
:style="getQuizMarkerStyle(quiz.time)"
class="absolute top-0 h-full w-0.5 bg-red-500"
></div>
</div>
</div>
<span class="text-sm font-medium"> <span class="text-sm font-medium">
{{ formatSeconds(currentTime) }} / {{ formatSeconds(duration) }} {{ formatSeconds(currentTime) }} / {{ formatSeconds(duration) }}
</span> </span>
@@ -288,6 +301,13 @@ const toggleFullscreen = () => {
videoContainer.value.requestFullscreen() videoContainer.value.requestFullscreen()
} }
} }
const getQuizMarkerStyle = (time) => {
const percentage = ((time - 5) / Math.ceil(duration.value)) * 100
return {
left: `${percentage}%`,
}
}
</script> </script>
<style scoped> <style scoped>
@@ -307,11 +327,10 @@ iframe {
} }
.duration-slider { .duration-slider {
flex: 1;
-webkit-appearance: none; -webkit-appearance: none;
appearance: none; appearance: none;
border-radius: 10px; border-radius: 10px;
background-color: theme('colors.gray.100'); background-color: theme('colors.gray.600');
cursor: pointer; cursor: pointer;
} }
@@ -319,20 +338,20 @@ iframe {
width: 2px; width: 2px;
border-radius: 50%; border-radius: 50%;
-webkit-appearance: none; -webkit-appearance: none;
background-color: theme('colors.gray.500'); background-color: theme('colors.white');
} }
@media screen and (-webkit-min-device-pixel-ratio: 0) { @media screen and (-webkit-min-device-pixel-ratio: 0) {
input[type='range'] { input[type='range'] {
overflow: hidden; overflow: hidden;
width: 150px; width: 100%;
-webkit-appearance: none; -webkit-appearance: none;
} }
input[type='range']::-webkit-slider-thumb { input[type='range']::-webkit-slider-thumb {
-webkit-appearance: none; -webkit-appearance: none;
cursor: pointer; cursor: pointer;
box-shadow: -500px 0 0 500px theme('colors.gray.600'); box-shadow: -500px 0 0 500px theme('colors.white');
} }
} }
</style> </style>