Skip to content

Commit

Permalink
feat: toggle player class vjs-thumbnails-ready according to plugin state
Browse files Browse the repository at this point in the history
With this the player can be styled depending on plugin state.
  • Loading branch information
phloxic committed Dec 29, 2023
1 parent 1988633 commit 2f183d6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/sprite-thumbnails.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ const spriteThumbs = (player, plugin, options) => {
progress.off(spriteEvents, hijackMouseTooltip);
tooltipEl.style = tooltipStyleOrig;
}
player.toggleClass('vjs-thumbnails-ready', pstate.ready);
});

player.on('loadstart', () => {
Expand Down
13 changes: 12 additions & 1 deletion test/sprite-thumbnails.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ QUnit.module('videojs-sprite-thumbnails', {
});

QUnit.test('changes ready state', function(assert) {
assert.expect(5);
assert.expect(7);

this.player.spriteThumbnails({
url: '../img/oceans-thumbs.jpg',
Expand All @@ -62,6 +62,11 @@ QUnit.test('changes ready state', function(assert) {
true,
'the plugin is now able to show thumbnails on ready'
);
assert.strictEqual(
this.player.hasClass('vjs-thumbnails-ready'),
true,
'player has class vjs-thumbnails-ready'
);

this.clock.tick(1);
const currentConfig = this.player.spriteThumbnails().options;
Expand All @@ -74,6 +79,12 @@ QUnit.test('changes ready state', function(assert) {
false,
'options empty: plugin disabled and not ready'
);
assert.strictEqual(
this.player.hasClass('vjs-thumbnails-ready'),
false,
'player does not have class vjs-thumbnails-ready'
);

const overridingConfig = this.player.spriteThumbnails().options;

assert.strictEqual(
Expand Down

0 comments on commit 2f183d6

Please sign in to comment.