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

Slider handle current time #2255

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
25 changes: 25 additions & 0 deletions src/css/components/_progress.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@
/* We need an increased hit area on hover */
.video-js .vjs-progress-control:hover .vjs-progress-holder { font-size: 1.666666666666666666em }

/* Also show the current time tooltip */
.video-js .vjs-progress-control:hover .vjs-play-progress:after {
display: block;

/* If we let the font size grow as much as everything else, the current time tooltip ends up
ginormous. If you'd like to enable the current time tooltip all the time, this should be disabled
to avoid a weird hitch when you roll off the hover. */
font-size: 0.6em;
}

/* Progress Bars */
.video-js .vjs-progress-holder .vjs-play-progress,
.video-js .vjs-progress-holder .vjs-load-progress,
Expand Down Expand Up @@ -58,6 +68,21 @@
}
}

// Current Time "tooltip"
.video-js .vjs-play-progress:after {
/* By default this is hidden and only shown when hovering over the progress control */
display: none;
position: absolute;
top: -2.4em;
right: -1.5em;
font-size: 0.9em;
color: $primary-bg;
content: attr(data-current-time);
Copy link
Member

Choose a reason for hiding this comment

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

Does this work in IE8?

Copy link
Member

Choose a reason for hiding this comment

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

YES

padding: 0.2em 0.5em;
@include background-color-with-alpha($primary-text, 0.8);
@include border-radius(0.3em);
}

.video-js .vjs-load-progress {
background: rgb(100, 100, 100) /* IE8- Fallback */;
background: rgba(255, 255, 255, 0.2);
Expand Down
1 change: 1 addition & 0 deletions src/css/components/_time.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
}

/* We need the extra specificity that referencing .vjs-no-flex provides. */
.video-js .vjs-current-time, .video-js.vjs-no-flex .vjs-current-time { display: none; }
.video-js .vjs-duration, .video-js.vjs-no-flex .vjs-duration { display: none; }
.vjs-time-divider { display: none; line-height: 3em; }
13 changes: 13 additions & 0 deletions src/js/control-bar/progress-control/play-progress-bar.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import Component from '../../component.js';
import * as Fn from '../../utils/fn.js';
import formatTime from '../../utils/format-time.js';

/**
* Shows play progress
Expand All @@ -9,13 +11,24 @@ import Component from '../../component.js';
*/
class PlayProgressBar extends Component {

constructor(player, options){
super(player, options);
this.on(player, 'timeupdate', this.updateDataAttr);
player.ready(Fn.bind(this, this.updateDataAttr));
}

createEl() {
return super.createEl('div', {
className: 'vjs-play-progress',
innerHTML: `<span class="vjs-control-text"><span>${this.localize('Progress')}</span>: 0%</span>`
});
}

updateDataAttr() {
let time = (this.player_.scrubbing()) ? this.player_.getCache().currentTime : this.player_.currentTime();
this.el_.setAttribute('data-current-time', formatTime(time, this.player_.duration()));
}

}

Component.registerComponent('PlayProgressBar', PlayProgressBar);
Expand Down