Skip to content

Commit

Permalink
feat: expose the option to set opacity
Browse files Browse the repository at this point in the history
  • Loading branch information
nwaughachukwuma committed Apr 30, 2020
1 parent 3546d3a commit 3c67bfa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ player.logo(options);
| padding | Optional | Number | 5 | Padding around the logo image (px). |
| fadeDelay | Optional | Number, Null | 5000 | Time until fade-out begins (msec). If `null` is specified, automatic fade-out is not performed. |
| hideOnReady | Optional | Boolean | false | Do not show the logo image when the player is ready. |
| opacity | Optional | Boolean | 1 | The opacity of the logo (from `[0, 1]`). If not specified, it will default to 1 |

## Methods

Expand Down
10 changes: 8 additions & 2 deletions src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ const defaults = {
height: undefined,
padding: 5,
fadeDelay: 5000,
hideOnReady: false
hideOnReady: false,
opacity: 1
};

/**
Expand All @@ -35,6 +36,7 @@ class Logo extends Plugin {
* @param {Number} [options.padding=5] Padding around the logo image (px).
* @param {?Number} [options.fadeDelay=5000] Time until fade-out begins (msec). If `null` is specified, automatic fade-out is not performed.
* @param {Boolean} [options.hideOnReady=false] Do not show the logo image when the player is ready.
* @param {Number} [options.hideOnReady=false] The opacity of the image. If not specified it will default to 1
*/
constructor(player, options) {
super(player);
Expand Down Expand Up @@ -107,7 +109,7 @@ class Logo extends Plugin {

img.src = this.options.image;

const { width, height } = this.options;
const { width, height, opacity } = this.options;

if (width) {
img.width = width;
Expand All @@ -116,6 +118,10 @@ class Logo extends Plugin {
img.height = height;
}

if (opacity) {
img.style.opacity = opacity
}

if (this.options.url) {
// Create a element for the image link
const a = document.createElement('a'); // eslint-disable-line no-undef
Expand Down

0 comments on commit 3c67bfa

Please sign in to comment.