diff --git a/src/components/seek_bar/seek_bar.js b/src/components/seek_bar/seek_bar.js index 3ed2fc5..515fe65 100644 --- a/src/components/seek_bar/seek_bar.js +++ b/src/components/seek_bar/seek_bar.js @@ -131,6 +131,7 @@ export default class SeekBarPlugin extends MediaControlComponentPlugin { seek(rangeInput) { if (this.shouldDisableInteraction) return const percentage = rangeInput.target.value / rangeInput.target.max * 100 + this.$el[0].style.setProperty('--seek-before-width', `${percentage}%`) this.container.seekPercentage(percentage) this._isDragging = false this.core.trigger(Events.Custom.MEDIA_CONTROL_SEEK_BAR_STOP_DRAGGING, { event: rangeInput }) diff --git a/src/components/seek_bar/seek_bar.test.js b/src/components/seek_bar/seek_bar.test.js index 96a5ac4..3b90687 100644 --- a/src/components/seek_bar/seek_bar.test.js +++ b/src/components/seek_bar/seek_bar.test.js @@ -442,6 +442,12 @@ describe('SeekBarPlugin', function() { expect(this.container.seekPercentage).not.toHaveBeenCalled() }) + test('adds the ratio of event.target.value and event.target.max values as --seek-before-width style property of DOM element plugin', () => { + this.plugin.seek({ target: { value: 20, max: 200 } }) + + expect(getComputedStyle(this.plugin.$el[0]).getPropertyValue('--seek-before-width')).toEqual('10%') + }) + test('calls container.seekPercentage with the ratio of event.target.value and event.target.max values', () => { jest.spyOn(this.container, 'seekPercentage') this.plugin.seek({ target: { value: 20, max: 200 } })