fix(stats): restore sticky comparison header
This commit is contained in:
+16
-1
@@ -150,6 +150,8 @@ export default function ModelComparePair() {
|
|||||||
const [themePreference, setThemePreference] = createSignal<ThemePreference>("system")
|
const [themePreference, setThemePreference] = createSignal<ThemePreference>("system")
|
||||||
const [highlightBest, setHighlightBest] = createSignal(true)
|
const [highlightBest, setHighlightBest] = createSignal(true)
|
||||||
const [addingModel, setAddingModel] = createSignal(false)
|
const [addingModel, setAddingModel] = createSignal(false)
|
||||||
|
let comparisonHeadingScroll: HTMLDivElement | undefined
|
||||||
|
let comparisonBodyScroll: HTMLDivElement | undefined
|
||||||
const models = createMemo(
|
const models = createMemo(
|
||||||
() =>
|
() =>
|
||||||
modelSelections().map((model, index) =>
|
modelSelections().map((model, index) =>
|
||||||
@@ -188,6 +190,9 @@ export default function ModelComparePair() {
|
|||||||
if (typeof window === "undefined" || next.length < 2) return
|
if (typeof window === "undefined" || next.length < 2) return
|
||||||
window.location.href = comparisonModelsHref(next)
|
window.location.href = comparisonModelsHref(next)
|
||||||
}
|
}
|
||||||
|
const syncComparisonScroll = (source: HTMLDivElement, target: HTMLDivElement | undefined) => {
|
||||||
|
if (target && target.scrollLeft !== source.scrollLeft) target.scrollLeft = source.scrollLeft
|
||||||
|
}
|
||||||
const structuredData = createMemo(() =>
|
const structuredData = createMemo(() =>
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
"@context": "https://schema.org",
|
"@context": "https://schema.org",
|
||||||
@@ -260,8 +265,18 @@ export default function ModelComparePair() {
|
|||||||
data-model-count={models().length}
|
data-model-count={models().length}
|
||||||
style={`--compare-detail-grid: ${comparisonDetailGridTemplate(models().length)}`}
|
style={`--compare-detail-grid: ${comparisonDetailGridTemplate(models().length)}`}
|
||||||
>
|
>
|
||||||
<div data-component="compare-detail-scroll">
|
<div
|
||||||
|
data-component="compare-detail-heading-scroll"
|
||||||
|
ref={(element) => (comparisonHeadingScroll = element)}
|
||||||
|
onScroll={(event) => syncComparisonScroll(event.currentTarget, comparisonBodyScroll)}
|
||||||
|
>
|
||||||
<ComparisonPairSelector catalogModels={selectorModels()} models={models()} />
|
<ComparisonPairSelector catalogModels={selectorModels()} models={models()} />
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
data-component="compare-detail-body-scroll"
|
||||||
|
ref={(element) => (comparisonBodyScroll = element)}
|
||||||
|
onScroll={(event) => syncComparisonScroll(event.currentTarget, comparisonHeadingScroll)}
|
||||||
|
>
|
||||||
<Show
|
<Show
|
||||||
when={stats() !== undefined}
|
when={stats() !== undefined}
|
||||||
fallback={
|
fallback={
|
||||||
|
|||||||
@@ -6089,9 +6089,21 @@
|
|||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
[data-page="stats"] [data-component="compare-detail-scroll"] {
|
[data-page="stats"] [data-component="compare-detail-heading-scroll"] {
|
||||||
|
position: sticky;
|
||||||
|
top: 72px;
|
||||||
|
z-index: 9;
|
||||||
|
overflow-x: auto;
|
||||||
|
background: var(--stats-bg);
|
||||||
|
scrollbar-width: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-page="stats"] [data-component="compare-detail-heading-scroll"]::-webkit-scrollbar {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-page="stats"] [data-component="compare-detail-body-scroll"] {
|
||||||
overflow-x: auto;
|
overflow-x: auto;
|
||||||
overflow-y: hidden;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[data-page="stats"] [data-section="compare-detail-selector"],
|
[data-page="stats"] [data-section="compare-detail-selector"],
|
||||||
|
|||||||
Reference in New Issue
Block a user