Skip to content

Commit

Permalink
Remove scroll snap and update last 2 scrolls
Browse files Browse the repository at this point in the history
Signed-off-by: Olga Bulat <[email protected]>
  • Loading branch information
obulat committed Nov 26, 2023
1 parent 0688cee commit 7c35d62
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 9 additions & 4 deletions frontend/src/components/VMediaInfo/VByLine/VByLine.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
>
<div
ref="buttonsRef"
class="buttons flex snap-x justify-start gap-x-3 overflow-x-scroll p-1.5px sm:gap-x-1"
class="buttons flex justify-start gap-x-3 overflow-x-scroll p-1.5px sm:gap-x-1"
:class="{
'ms-11': showScrollButton.start,
'me-11': showScrollButton.end,
Expand Down Expand Up @@ -171,18 +171,23 @@ export default defineComponent({
const scroll = (to: "start" | "end") => {
if (!buttonsRef.value) return
showScrollButton[to === "start" ? "end" : "start"] = true
const buttons = buttonsRef.value
let distToSide = getDistToSide(to, dir.value, buttons)
showScrollButton[to === "start" ? "end" : "start"] = true
let distToSide = getDistToSide(to, dir.value, buttons)
let adjustedScrollStep = scrollStep
// If the scroll step is larger than the distance to the side, scroll
// to the side and hide the scroll button.
// If the distance to the side is less than twice the scroll step, scroll
// half the distance to the side to prevent a very small scroll at the end.
const isLastScroll = distToSide - scrollMargin <= scrollStep
if (isLastScroll) {
hideScrollButton(to)
adjustedScrollStep = to === "start" ? distToSide : buttons.scrollWidth
} else if (distToSide < scrollStep * 2) {
adjustedScrollStep = distToSide / 2
}
if (dir.value === "rtl") {
adjustedScrollStep = -adjustedScrollStep
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
as="VLink"
size="small"
has-icon-start
class="label-bold snap-start !bg-dark-charcoal-10 hover:!bg-dark-charcoal hover:text-white sm:!bg-tx"
class="label-bold !bg-dark-charcoal-10 hover:!bg-dark-charcoal hover:text-white sm:!bg-tx"
variant="transparent-gray"
:href="href"
>
Expand Down

0 comments on commit 7c35d62

Please sign in to comment.