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

Adding keyboard pause/play to video element #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
9 changes: 9 additions & 0 deletions index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@
:controls='controls'
:aria-label='alt'
:style='assetStyles'
tabindex='0'
@keyup.enter='togglePause'
@keyup.space='togglePause'
@canplaythrough='onAssetLoad("video")')

//- Generated sources
Expand Down Expand Up @@ -113,6 +116,12 @@ export default
@fitsAssetsContainerClasses
@loadsAssetsContainerClasses
].filter (val) -> !!val

methods:
togglePause: (e) ->
if e.target.paused
then e.target.play()
else e.target.pause()
Comment on lines +120 to +124
Copy link
Member Author

Choose a reason for hiding this comment

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

@brokenhd can you move this method into https://github.com/BKWLD/vue-visual/blob/master/concerns/supports-videos.coffee since it's fundamentally video related?

Also, how about togglePlayback() as the method name?

Lastly, you can use the existing @play() and @pause() methods for this, which would be good in case we add additional behaviors onto those methods. Like how @play() also starts loading.


</script>

Expand Down