mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-13 19:58:09 +00:00
[UBER-129] Fix scroll after collapsing a list header (#3330)
Signed-off-by: Ruslan Bayandinov <wazsone@ya.ru>
This commit is contained in:
parent
d7400dc03a
commit
10f033ba41
@ -453,6 +453,14 @@
|
|||||||
? 'visible'
|
? 'visible'
|
||||||
: 'hidden'
|
: 'hidden'
|
||||||
let scrollY: number = 0
|
let scrollY: number = 0
|
||||||
|
|
||||||
|
let safariScrollJumpfix: boolean = true
|
||||||
|
export const enableSafariScrollJumpFix = (enable: boolean): void => {
|
||||||
|
if (enable) {
|
||||||
|
scrollY = divScroll?.scrollTop ?? 0
|
||||||
|
}
|
||||||
|
safariScrollJumpfix = enable
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:window on:resize={_resize} />
|
<svelte:window on:resize={_resize} />
|
||||||
@ -476,24 +484,25 @@
|
|||||||
}}
|
}}
|
||||||
class="scroll relative flex-shrink"
|
class="scroll relative flex-shrink"
|
||||||
style:overflow-x={horizontal ? 'auto' : 'hidden'}
|
style:overflow-x={horizontal ? 'auto' : 'hidden'}
|
||||||
on:scroll={(evt) => {
|
on:scroll={() => {
|
||||||
if ($tooltipstore.label !== undefined) closeTooltip()
|
if ($tooltipstore.label !== undefined) closeTooltip()
|
||||||
const newPos = divScroll?.scrollTop ?? 0
|
|
||||||
|
|
||||||
// TODO: Workaround: https://front.hc.engineering/workbench/platform/tracker/TSK-760
|
// TODO: Workaround: https://front.hc.engineering/workbench/platform/tracker/TSK-760
|
||||||
// In Safari scroll could jump on click, with no particular reason.
|
// In Safari scroll could jump on click, with no particular reason.
|
||||||
|
if (safariScrollJumpfix) {
|
||||||
if (
|
const newPos = divScroll?.scrollTop ?? 0
|
||||||
!scrolling &&
|
if (
|
||||||
!isScrolling &&
|
!scrolling &&
|
||||||
scrollY !== 0 &&
|
!isScrolling &&
|
||||||
Math.abs(newPos - scrollY) > 100 &&
|
scrollY !== 0 &&
|
||||||
divScroll !== undefined &&
|
Math.abs(newPos - scrollY) > 100 &&
|
||||||
isSafari()
|
divScroll !== undefined &&
|
||||||
) {
|
isSafari()
|
||||||
divScroll.scrollTop = scrollY
|
) {
|
||||||
|
divScroll.scrollTop = scrollY
|
||||||
|
}
|
||||||
|
scrollY = divScroll?.scrollTop ?? 0
|
||||||
}
|
}
|
||||||
scrollY = divScroll?.scrollTop ?? 0
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
|
@ -148,6 +148,7 @@
|
|||||||
on:select-prev={(evt) => {
|
on:select-prev={(evt) => {
|
||||||
select(-2, evt.detail)
|
select(-2, evt.detail)
|
||||||
}}
|
}}
|
||||||
|
on:collapsed
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -319,6 +319,7 @@
|
|||||||
index: e.detail.index + getInitIndex(categories, i)
|
index: e.detail.index + getInitIndex(categories, i)
|
||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
|
on:collapsed
|
||||||
{flatHeaders}
|
{flatHeaders}
|
||||||
{disableHeader}
|
{disableHeader}
|
||||||
{props}
|
{props}
|
||||||
|
@ -390,6 +390,7 @@
|
|||||||
$focusStore = { provider: $focusStore.provider }
|
$focusStore = { provider: $focusStore.provider }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
dispatch('collapsed', { div })
|
||||||
}
|
}
|
||||||
localStorage.setItem(categoryCollapseKey, collapsed ? 'true' : 'false')
|
localStorage.setItem(categoryCollapseKey, collapsed ? 'true' : 'false')
|
||||||
}}
|
}}
|
||||||
@ -460,11 +461,6 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
.expandCollapse {
|
|
||||||
overflow: hidden;
|
|
||||||
transition: height 0.3s ease-out;
|
|
||||||
height: auto;
|
|
||||||
}
|
|
||||||
.zero-container {
|
.zero-container {
|
||||||
border-radius: 0.25rem;
|
border-radius: 0.25rem;
|
||||||
|
|
||||||
|
@ -198,7 +198,6 @@
|
|||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
.categoryHeader {
|
.categoryHeader {
|
||||||
position: relative;
|
|
||||||
position: sticky;
|
position: sticky;
|
||||||
top: 0;
|
top: 0;
|
||||||
padding: 0 2.5rem 0 0.75rem;
|
padding: 0 2.5rem 0 0.75rem;
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
export let props: Record<string, any> = {}
|
export let props: Record<string, any> = {}
|
||||||
|
|
||||||
let list: List
|
let list: List
|
||||||
|
let scroll: Scroller
|
||||||
|
|
||||||
const listProvider = new ListSelectionProvider((offset: 1 | -1 | 0, of?: Doc, dir?: SelectDirection) => {
|
const listProvider = new ListSelectionProvider((offset: 1 | -1 | 0, of?: Doc, dir?: SelectDirection) => {
|
||||||
if (dir === 'vertical') {
|
if (dir === 'vertical') {
|
||||||
@ -42,6 +43,7 @@
|
|||||||
|
|
||||||
<div class="w-full h-full py-4 clear-mins">
|
<div class="w-full h-full py-4 clear-mins">
|
||||||
<Scroller
|
<Scroller
|
||||||
|
bind:this={scroll}
|
||||||
fade={{ multipler: { top: 2.75 * viewOptions.groupBy.length, bottom: 0 } }}
|
fade={{ multipler: { top: 2.75 * viewOptions.groupBy.length, bottom: 0 } }}
|
||||||
padding={'0 1rem'}
|
padding={'0 1rem'}
|
||||||
noFade
|
noFade
|
||||||
@ -67,8 +69,13 @@
|
|||||||
on:check={(event) => {
|
on:check={(event) => {
|
||||||
listProvider.updateSelection(event.detail.docs, event.detail.value)
|
listProvider.updateSelection(event.detail.docs, event.detail.value)
|
||||||
}}
|
}}
|
||||||
on:content={(evt) => {
|
on:content={(event) => {
|
||||||
listProvider.update(evt.detail)
|
listProvider.update(event.detail)
|
||||||
|
}}
|
||||||
|
on:collapsed={(event) => {
|
||||||
|
scroll.enableSafariScrollJumpFix(false)
|
||||||
|
event.detail.div.scrollIntoView(true)
|
||||||
|
scroll.enableSafariScrollJumpFix(true)
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Scroller>
|
</Scroller>
|
||||||
|
Loading…
Reference in New Issue
Block a user