From a338e7c98fb0962a2c815a3b0ecab73192a1890f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Fri, 22 Oct 2021 18:59:15 +0200 Subject: [PATCH] Add tooltips to audio/video player buttons MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- app/soapbox/features/video/index.js | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/app/soapbox/features/video/index.js b/app/soapbox/features/video/index.js index 6de8bb87e..8dde3b2d7 100644 --- a/app/soapbox/features/video/index.js +++ b/app/soapbox/features/video/index.js @@ -139,15 +139,6 @@ class Video extends React.PureComponent { revealed: this.props.visible !== undefined ? this.props.visible : (this.props.displayMedia !== 'hide_all' && !this.props.sensitive || this.props.displayMedia === 'show_all'), }; - // Hard-coded in components.scss - // Any way to get ::before values programatically? - volWidth = 50; - volOffset = 70; - volHandleOffset = v => { - const offset = v * this.volWidth + this.volOffset; - return (offset > 110) ? 110 : offset; - } - setPlayerRef = c => { this.player = c; @@ -212,16 +203,17 @@ class Video extends React.PureComponent { } handleMouseVolSlide = throttle(e => { - const rect = this.volume.getBoundingClientRect(); - const x = (e.clientX - rect.left) / this.volWidth; //x position within the element. + const { x } = getPointerPosition(this.volume, e); if(!isNaN(x)) { let slideamt = x; + if(x > 1) { slideamt = 1; } else if(x < 0) { slideamt = 0; } + this.video.volume = slideamt; this.setState({ volume: slideamt }); } @@ -489,8 +481,8 @@ class Video extends React.PureComponent {
- - + +
@@ -513,10 +505,10 @@ class Video extends React.PureComponent {
- {(sensitive && !onCloseVideo) && } - {(!fullscreen && onOpenVideo) && } - {onCloseVideo && } - + {(sensitive && !onCloseVideo) && } + {(!fullscreen && onOpenVideo) && } + {onCloseVideo && } +