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

fix(ADA-1359): Make scrollbar visible all the time #65

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
34 changes: 6 additions & 28 deletions src/components/playlist-wrapper/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ import {PluginPositions, PlaylistExtraData} from '../../types';
const {toHHMMSS, KeyMap} = KalturaPlayer.ui.utils;
const {withText, Text} = KalturaPlayer.ui.preacti18n;

let scrollTimerId: ReturnType<typeof setTimeout>;
const SCROLL_BAR_TIMEOUT = 250;

const translates = ({player}: PlaylistWrapperProps) => {
const amount = player.playlist?.items.length;
return {
Expand Down Expand Up @@ -46,7 +43,6 @@ export const PlaylistWrapper = withText(translates)(
({onClose, player, pluginMode, playlistData, eventManager, toggledByKeyboard, ...otherProps}: PlaylistWrapperProps) => {
const {playlist} = player;
const [playlistExtraData, setPlaylistExtraData] = useState<PlaylistExtraData>({});
const [scrolling, setScrolling] = useState(false);
const [activeIndex, setActiveIndex] = useState(playlist.current.index);
const playlistContentRef = useRef<HTMLDivElement>(null);

Expand All @@ -66,19 +62,10 @@ export const PlaylistWrapper = withText(translates)(
[playlist]
);

const handleScroll = useCallback(() => {
clearTimeout(scrollTimerId);
setScrolling(true);
scrollTimerId = setTimeout(() => {
setScrolling(false);
}, SCROLL_BAR_TIMEOUT);
}, []);

const handleWheel = useCallback((e: WheelEvent) => {
e.preventDefault();
if (playlistContentRef?.current) {
playlistContentRef.current.scrollLeft += e.deltaY;
handleScroll();
}
}, []);

Expand All @@ -90,19 +77,11 @@ export const PlaylistWrapper = withText(translates)(
},
[onClose]
);
const handleFocus = useCallback(() => {
setScrolling(true);
}, []);

const handleBlur = useCallback(() => {
setScrolling(false);
}, []);

const handleKeyDown = useCallback((event: KeyboardEvent) => {
if (event.keyCode === KeyMap.UP || event.keyCode === KeyMap.DOWN || event.keyCode === KeyMap.LEFT || event.keyCode === KeyMap.RIGHT) {
setScrolling(true);
}
}, []);

const handleFocus = useCallback(() => {}, []);
Copy link
Contributor

Choose a reason for hiding this comment

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

if that's only noop methods, why keep them? Can we remove handleFocus, handleBlur and handleKeyDown methods?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

const handleBlur = useCallback(() => {}, []);
const handleKeyDown = useCallback(() => {}, []);

const playlistDuration = useMemo(() => {
const totalDuration = playlist.items.reduce((acc: number, cur: any) => {
return acc + (cur.sources.duration || 0);
Expand Down Expand Up @@ -134,7 +113,6 @@ export const PlaylistWrapper = withText(translates)(
const playlistContentParams = useMemo(() => {
if (pluginMode === PluginPositions.VERTICAL) {
return {
onScroll: handleScroll,
onFocus: handleFocus,
onBlur: handleBlur,
onKeyDown: handleKeyDown,
Expand All @@ -157,7 +135,7 @@ export const PlaylistWrapper = withText(translates)(
onKeyUp={handleClose}>
{renderPlaylistHeader}
<div
className={[styles.playlistContent, scrolling ? styles.scrolling : ''].join(' ')}
className={[styles.playlistContent].join(' ')}
{...playlistContentParams}
aria-live="polite">
{playlist.items.map((item: any) => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/playlist-wrapper/playlist-wrapper.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
width: 100%;
@include playlist-scrollbar();
&.scrolling::-webkit-scrollbar-track,
&.scrolling::-webkit-scrollbar-thumb, {
&.scrolling::-webkit-scrollbar-thumb {
visibility: visible;
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ $roundness-2: 8px;
}
&::-webkit-scrollbar-track {
background: rgba(33, 33, 33, 0.9);
visibility: hidden;
}
&::-webkit-scrollbar-thumb {
border-radius: 3px;
background-color: rgba(255, 255, 255, 0.3);
visibility: hidden;
}
}
Loading