From a98fb979aca0f8d565d72f1bf97aeb3d7ecc685d Mon Sep 17 00:00:00 2001 From: Lubos Krnac Date: Tue, 20 Dec 2016 15:58:57 +0530 Subject: [PATCH 1/3] Fix fading out after ID was removed Closes #8 --- src/plugin.js | 6 ++++-- test/plugin.test.js | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/plugin.js b/src/plugin.js index 949b1c0..a5bafe2 100644 --- a/src/plugin.js +++ b/src/plugin.js @@ -54,8 +54,10 @@ const setupWatermark = (player, options) => { */ const fadeWatermark = (options) => { setTimeout( - () => document.getElementById('vjs-watermark').classList.add('vjs-watermark-fade'), - options.fadeTime); + () => document.getElementsByClassName('vjs-watermark-content')[0] + .classList.add('vjs-watermark-fade'), + options.fadeTime + ); }; /** diff --git a/test/plugin.test.js b/test/plugin.test.js index 017ea8c..771d14e 100644 --- a/test/plugin.test.js +++ b/test/plugin.test.js @@ -170,3 +170,20 @@ QUnit.test('does add a link when URL is configured', function(assert) { 'the plugin doesn\'t add an ID to image container' ); }); + +QUnit.test('fades out after player is started', function(assert) { + // GIVEN + const imageUrl = '/images/foo.png'; + + this.player.watermark({ image: imageUrl, fadeTime: 1 }); + this.clock.tick(1); + + // WHEN + this.player.trigger('play'); + + // THEN + const imageContainer = this.player.contentEl() + .getElementsByClassName('vjs-watermark-content')[0]; + + assert.ok(imageContainer.classList.contains('vjs-watermark-fade')); +}); From cd6e5d6e824635f23dfd1d6a0649d5030f2405f0 Mon Sep 17 00:00:00 2001 From: Lubos Krnac Date: Tue, 20 Dec 2016 15:59:20 +0530 Subject: [PATCH 2/3] Bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6e815fa..d901b85 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "videojs-watermark", - "version": "1.0.0", + "version": "1.0.1", "description": "Adds a watermark image the video player", "repository": "https://github.com/dotsub/videojs-watermark", "main": "es5/plugin.js", From bc11230ae4de5c7c6b257d1482911b0c45eb4ab5 Mon Sep 17 00:00:00 2001 From: Lubos Krnac Date: Tue, 20 Dec 2016 16:59:31 +0530 Subject: [PATCH 3/3] Wait in test for failing out timeout --- test/plugin.test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/plugin.test.js b/test/plugin.test.js index 771d14e..d4ca8ff 100644 --- a/test/plugin.test.js +++ b/test/plugin.test.js @@ -180,6 +180,7 @@ QUnit.test('fades out after player is started', function(assert) { // WHEN this.player.trigger('play'); + this.clock.tick(10); // THEN const imageContainer = this.player.contentEl()