Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made a few volume skin changes #2553

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/css/components/_volume.scss
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ width and height to zero. */
width: 2.9em;
}


.video-js .vjs-volume-menu-button.vjs-volume-menu-button-horizontal:hover .vjs-menu .vjs-menu-content,
.video-js .vjs-volume-menu-button.vjs-volume-menu-button-horizontal .vjs-menu.vjs-lock-showing .vjs-menu-content {
.video-js .vjs-volume-menu-button.vjs-volume-menu-button-horizontal .vjs-menu.vjs-lock-showing .vjs-menu-content
.video-js .vjs-volume-menu-button.vjs-volume-menu-button-horizontal.vjs-slider-active .vjs-menu .vjs-menu-content {
height: 2.9em;
width: 8em;
}
Expand Down
6 changes: 4 additions & 2 deletions src/css/components/menu/_menu-inline.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@
}

// Hover state
.video-js .vjs-menu-button-inline:hover {
.video-js .vjs-menu-button-inline:hover,
.video-js .vjs-menu-button-inline.vjs-slider-active {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just use :focus (or :active)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The menu button isn't actually in focus here, the internal slider is. I have the slider firing an event when it's active so the menu button can catch it add this class to itself.

// This width is currently specific to the inline volume bar.
width: 10em;
width: 12em;
}

.video-js .vjs-menu-button.vjs-menu-button-inline:hover .vjs-menu,
.video-js .vjs-menu-button-inline.vjs-slider-active .vjs-menu,
.video-js .vjs-menu-button-inline .vjs-menu.vjs-lock-showing {
display: block;
opacity: 1;
Expand Down
5 changes: 3 additions & 2 deletions src/js/control-bar/control-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ class ControlBar extends Component {

ControlBar.prototype.options_ = {
loadEvent: 'play',
volumeMenuButton: {
inline: true
},
children: [
'playToggle',
'volumeMenuButton',
Expand All @@ -55,8 +58,6 @@ ControlBar.prototype.options_ = {
'remainingTimeDisplay',
'customControlSpacer',
'playbackRateMenuButton',
'muteToggle',
'volumeControl',
'chaptersButton',
'subtitlesButton',
'captionsButton',
Expand Down
31 changes: 17 additions & 14 deletions src/js/control-bar/volume-menu-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,24 @@ class VolumeMenuButton extends MenuButton {
this.on(player, 'loadstart', this.volumeUpdate);

// hide mute toggle if the current tech doesn't support volume control
if (player.tech && player.tech['featuresVolumeControl'] === false) {
this.addClass('vjs-hidden');
}
this.on(player, 'loadstart', function(){
if (player.tech['featuresVolumeControl'] === false) {
function updateVisibility() {
if (player.tech && player.tech['featuresVolumeControl'] === false) {
this.addClass('vjs-hidden');
} else {
this.removeClass('vjs-hidden');
}
}

updateVisibility.call(this);
this.on(player, 'loadstart', updateVisibility);

this.on(this.volumeBar, ['slideractive', 'focus'], function(){
this.addClass('vjs-slider-active');
});

this.on(this.volumeBar, ['sliderinactive', 'blur'], function(){
this.removeClass('vjs-slider-active');
});
this.addClass('vjs-menu-button');
}

/**
Expand Down Expand Up @@ -83,15 +90,11 @@ class VolumeMenuButton extends MenuButton {
contentElType: 'div'
});

let vc = new VolumeBar(this.player_, this.options_.volumeBar);
let vb = new VolumeBar(this.player_, this.options_.volumeBar);

vc.on('focus', function() {
menu.lockShowing();
});
vc.on('blur', function() {
menu.unlockShowing();
});
menu.addChild(vc);
menu.addChild(vb);

this.volumeBar = vb;
return menu;
}

Expand Down
4 changes: 4 additions & 0 deletions src/js/slider/slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ class Slider extends Component {
handleMouseDown(event) {
event.preventDefault();
Dom.blockTextSelection();

this.addClass('vjs-sliding');
this.trigger('slideractive');

this.on(document, 'mousemove', this.handleMouseMove);
this.on(document, 'mouseup', this.handleMouseUp);
Expand All @@ -90,7 +92,9 @@ class Slider extends Component {
*/
handleMouseUp() {
Dom.unblockTextSelection();

this.removeClass('vjs-sliding');
this.trigger('sliderinactive');

this.off(document, 'mousemove', this.handleMouseMove);
this.off(document, 'mouseup', this.handleMouseUp);
Expand Down