Skip to content

Commit

Permalink
Merge pull request #85 from reuters-graphics/video-controls-middle
Browse files Browse the repository at this point in the history
Added option of center for controlsPosition prop of Video
  • Loading branch information
hobbes7878 authored Jun 21, 2023
2 parents cd48f0b + adaea8a commit 85f23e7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/components/Video/Controls.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
paused = !paused;
clickedOnPauseBtn = paused === true; // so video doesn't autoplay when coming into view again if paused previously
dispatch('pausePlayEvent', {
paused: paused,
clickedOnPauseBtn: clickedOnPauseBtn,
paused,
clickedOnPauseBtn,
});
}
</script>
Expand All @@ -32,9 +32,14 @@
opacity: {controlsOpacity};
top: {controlsPosition === 'top left' || controlsPosition === 'top right'
? `${10}px`
: controlsPosition === 'center'
? `${(heightVideoContainer - controlsBorderOffset) / 2}px`
: `${heightVideoContainer - controlsBorderOffset}px`};
left: {controlsPosition === 'top left' || controlsPosition === 'bottom left'
? `${10}px`
: controlsPosition === 'center'
? `${(widthVideoContainer - controlsBorderOffset) / 2}px`
: `${widthVideoContainer - controlsBorderOffset}px`};
"
>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Video/stories/docs/controls.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ If you do want to leave the controls, you have a couple of options to style them

- Set `controlsColour` to a colour of your choosing.
- Set `controlsOpacity` to a value between `0` and `1` to control the opacity. The default is `0.5`.
- Change the placement of the controls to one of: `top right`, `top left`, `bottom right`, `bottom left` by setting `controlsPosition`.
- Change the placement of the controls to one of: `top right`, `top left`, `bottom right`, `bottom left`, `center` by setting `controlsPosition`.
- Change the play button to a replay button at the end of the video with the option `separateReplayIcon={true}`.

Here is an example with bottom right corner white opaque controls, with a replay button, where you have to hover on the video to see the controls.
Expand Down

0 comments on commit 85f23e7

Please sign in to comment.