Skip to content

Commit

Permalink
Merge pull request #19 from PrestonN/master
Browse files Browse the repository at this point in the history
Add toggle to show timestamp on hover
  • Loading branch information
chrisboustead authored Sep 3, 2020
2 parents b621241 + 1df1399 commit 3daf72b
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 35 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ Note: Plugin hides the default skin's mouse display timestamp on hover.
- [`<script>` Tag](#script-tag)
- [Browserify/CommonJS](#browserifycommonjs)
- [RequireJS/AMD](#requirejsamd)
- [Options](#options)
- [Example](#example)
- [Available Options](#available-options)
- [License](#license)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->
Expand Down Expand Up @@ -72,6 +75,23 @@ require(['video.js', 'videojs-vtt-thumbnails'], function(videojs) {
});
```

## Options

Options are passed in the same object as the source location.

### Example

```js
var player = videojs('my-video');
player.vttThumbnails({
src: 'example/thumbs.vtt',
showTimestamp: true
});
```
### Available Options

- `showTimestamp` (Boolean, Default: false) - Disables the timestamp that is shown on hover.

## License

MIT. Copyright (c) Chris Boustead &lt;[email protected]&gt;
Expand Down
66 changes: 33 additions & 33 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,12 @@ class vttThumbnailsPlugin {
}

setupThumbnailElement(data) {
const mouseDisplay = this.player.$('.vjs-mouse-display');
let mouseDisplay = null;

if (!this.options.showTimestamp) {
mouseDisplay = this.player.$('.vjs-mouse-display');
}

// eslint-disable-next-line no-undef
const thumbHolder = document.createElement('div');

Expand All @@ -190,7 +195,7 @@ class vttThumbnailsPlugin {
this.progressBar.appendChild(thumbHolder);
this.thumbnailHolder = thumbHolder;

if (mouseDisplay) {
if (mouseDisplay && !this.options.showTimestamp) {
mouseDisplay.classList.add('vjs-hidden');
}

Expand Down

0 comments on commit 3daf72b

Please sign in to comment.