Skip to content

Commit

Permalink
fix(controls): Ensured that fullscreen is the last icon on the contro…
Browse files Browse the repository at this point in the history
…l bar; added missing documentation
  • Loading branch information
rafa8626 committed Jan 9, 2019
1 parent 77fd131 commit 70e19c1
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/js/controls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,16 +322,17 @@ class Controls implements PlayerComponent {
],
};

if (isVideo(this.player.getElement())) {
this.fullscreen = new Fullscreen(this.player);
this.items.right.push(this.fullscreen);
}

// Append the custom items (if any)
const customItems = this.player.getCustomControls();
// Append the custom items
customItems.forEach(item => {
this.items[item.position].push(item);
});

// Make sure fullscreen is always the last one
if (isVideo(this.player.getElement())) {
this.fullscreen = new Fullscreen(this.player);
this.items.right.push(this.fullscreen);
}
}

/**
Expand Down Expand Up @@ -377,7 +378,7 @@ class Controls implements PlayerComponent {
}

/**
*
* Create a button for custom control items and activate `click` event on it.
*
* @private
* @param {ControlItem} item
Expand All @@ -395,7 +396,7 @@ class Controls implements PlayerComponent {
}

/**
*
* Remove a custom control button and deactivate `click` event on it.
*
* @private
* @param {ControlItem} item
Expand Down
25 changes: 25 additions & 0 deletions src/js/interfaces/control-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,34 @@
* @export
*/
export default interface ControlItem {
/**
* The icon image to present the custom control
*
* @type string
*/
icon: string;
/**
* The custom control label (for accessibility purposes)
*
* @type string
*/
title: string;
/**
* The custom control position (left. middle or right)
*
* @type string
*/
position: string;
/**
* Flag to indicate is a custom control
*
* @type boolean
*/
custom?: boolean;
/**
* The custom control callback to be executed when clicking on it
*
* @memberof ControlItem
*/
click(): void;
}

0 comments on commit 70e19c1

Please sign in to comment.