fix horizontal scrolling on windows devices + better support for trackpad (#493)
This commit is contained in:
parent
44a163789d
commit
786397921d
2 changed files with 7 additions and 8 deletions
|
|
@ -452,7 +452,7 @@ function Bookmark(props: BookmarkProps & { isExpanded?: boolean; onToggleFolder?
|
|||
);
|
||||
}
|
||||
|
||||
function HorizontalScroller({ children, className, customRef }: React.PropsWithChildren<{ className?: string; customRef?: (node: HTMLDivElement) => void; }>) {
|
||||
export function HorizontalScroller({ children, className, customRef }: React.PropsWithChildren<{ className?: string; customRef?: (node: HTMLDivElement) => void; }>) {
|
||||
const internalRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
|
|
@ -461,7 +461,7 @@ function HorizontalScroller({ children, className, customRef }: React.PropsWithC
|
|||
|
||||
const handleWheel = (e: WheelEvent) => {
|
||||
e.preventDefault();
|
||||
element.scrollLeft += e.deltaY;
|
||||
element.scrollLeft += e.deltaX + e.deltaY;
|
||||
};
|
||||
|
||||
element.addEventListener("wheel", handleWheel);
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import { findComponentByCodeLazy, findStoreLazy } from "@webpack";
|
|||
import { Button, ContextMenuApi, Flex, FluxDispatcher, useCallback, useEffect, useRef, UserStore, useState, useStateFromStores } from "@webpack/common";
|
||||
|
||||
import { BasicChannelTabsProps, ChannelTabsProps, clearStaleNavigationContext, closeTab, createTab, handleChannelSwitch, isNavigationFromSource, isTabSelected, moveToTab, openedTabs, openStartupTabs, saveTabs, settings, setUpdaterFunction, useGhostTabs } from "../util";
|
||||
import BookmarkContainer from "./BookmarkContainer";
|
||||
import BookmarkContainer, { HorizontalScroller } from "./BookmarkContainer";
|
||||
import ChannelTab, { PreviewTab } from "./ChannelTab";
|
||||
import { BasicContextMenu } from "./ContextMenus";
|
||||
|
||||
|
|
@ -100,7 +100,6 @@ export default function ChannelsTabsContainer(props: BasicChannelTabsProps) {
|
|||
}, [userId]);
|
||||
|
||||
const ref = useRef<HTMLDivElement>(null);
|
||||
const tabScrollerRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
setUpdaterFunction(update);
|
||||
|
|
@ -296,11 +295,11 @@ export default function ChannelsTabsContainer(props: BasicChannelTabsProps) {
|
|||
<div className={cl("separator")} />
|
||||
</>}
|
||||
<div className={cl("tab-container")}>
|
||||
<div className={cl("tab-scroller")} ref={tabScrollerRef}>
|
||||
<HorizontalScroller className={cl("tab-scroller")}>
|
||||
{openedTabs.filter(tab => tab != null).map((tab, i) =>
|
||||
<ChannelTab {...tab} index={i} key={tab.id} />
|
||||
)}
|
||||
</div>
|
||||
</HorizontalScroller>
|
||||
|
||||
<button
|
||||
onClick={() => createTab(props, true)}
|
||||
|
|
@ -316,11 +315,11 @@ export default function ChannelsTabsContainer(props: BasicChannelTabsProps) {
|
|||
);
|
||||
}
|
||||
|
||||
export function ChannelTabsPreview(p) {
|
||||
export function ChannelTabsPreview(p: { setValue: (v: TabSet) => void; }) {
|
||||
const id = UserStore.getCurrentUser()?.id;
|
||||
if (!id) return <Paragraph>there's no logged in account?????</Paragraph>;
|
||||
|
||||
const { setValue }: { setValue: (v: TabSet) => void; } = p;
|
||||
const { setValue } = p;
|
||||
const { tabSet }: { tabSet: TabSet; } = settings.use(["tabSet"]);
|
||||
|
||||
const placeholder = [{ guildId: "@me", channelId: undefined as any }];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue