-
Notifications
You must be signed in to change notification settings - Fork 942
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1356 from Pompette/feature/responsive_volume_comp…
…onent
- Loading branch information
Showing
6 changed files
with
180 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1 @@ | ||
export const PLAYER_CSS_CLASSNAME = '__remotion-player'; | ||
export const VOLUME_SLIDER_INPUT_CSS_CLASSNAME = PLAYER_CSS_CLASSNAME.concat( | ||
'_volume-slider-input' | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import {useMemo} from 'react'; | ||
import {fullscreenIconSize, ICON_SIZE} from './icons'; | ||
import {VOLUME_SLIDER_WIDTH} from './MediaVolumeSlider'; | ||
import {X_PADDING, X_SPACER} from './PlayerControls'; | ||
|
||
export const useVideoControlsResize = ({ | ||
allowFullscreen: allowFullScreen, | ||
playerWidth, | ||
}: { | ||
allowFullscreen: boolean; | ||
playerWidth: number; | ||
}): { | ||
maxTimeLabelWidth: number; | ||
displayVerticalVolumeSlider: boolean; | ||
} => { | ||
const resizeInfo = useMemo((): { | ||
maxTimeLabelWidth: number; | ||
displayVerticalVolumeSlider: boolean; | ||
} => { | ||
const playPauseIconSize = ICON_SIZE; | ||
const volumeIconSize = ICON_SIZE; | ||
const _fullscreenIconSize = allowFullScreen ? fullscreenIconSize : 0; | ||
const elementsSize = | ||
volumeIconSize + | ||
playPauseIconSize + | ||
_fullscreenIconSize + | ||
X_PADDING * 2 + | ||
X_SPACER * 2; | ||
|
||
const maxTimeLabelWidth = playerWidth - elementsSize; | ||
|
||
const maxTimeLabelWidthWithoutNegativeValue = Math.max( | ||
maxTimeLabelWidth, | ||
0 | ||
); | ||
|
||
const availableTimeLabelWidthIfVolumeOpen = | ||
maxTimeLabelWidthWithoutNegativeValue - VOLUME_SLIDER_WIDTH; | ||
|
||
// If max label width is lower than the volume width | ||
// then it means we need to take it's width as the max label width | ||
// otherwise we took the available width when volume open | ||
const computedLabelWidth = | ||
availableTimeLabelWidthIfVolumeOpen < VOLUME_SLIDER_WIDTH | ||
? maxTimeLabelWidthWithoutNegativeValue | ||
: availableTimeLabelWidthIfVolumeOpen; | ||
const minWidthForHorizontalDisplay = | ||
computedLabelWidth + elementsSize + VOLUME_SLIDER_WIDTH; | ||
|
||
const displayVerticalVolumeSlider = | ||
playerWidth < minWidthForHorizontalDisplay; | ||
|
||
return { | ||
maxTimeLabelWidth: maxTimeLabelWidthWithoutNegativeValue, | ||
displayVerticalVolumeSlider, | ||
}; | ||
}, [allowFullScreen, playerWidth]); | ||
|
||
return resizeInfo; | ||
}; |
cbc5186
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
remotion – ./
remotion-git-main-remotion.vercel.app
remotion.vercel.app
remotiondocs.com
remotion.dev
remotion-remotion.vercel.app
www.remotiondocs.com
www.remotion.dev
v3.remotion.dev