Skip to content

Commit

Permalink
fix(RecentPagesWidget): Several improvements to pageslider
Browse files Browse the repository at this point in the history
* Handle missing pageslider element gracefully.
* Calculate `scrollLeftMax` since it's non-standard and only supported
  on Firefox for now.
* Hide scrollbar on Chrome and Edge.

Signed-off-by: Jonas <[email protected]>
  • Loading branch information
mejo- committed Aug 2, 2023
1 parent fe7b58a commit 331a903
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/components/Page/LandingPageWidgets/RecentPagesWidget.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ export default {
methods: {
updateButtons: debounce(function() {
const pagesliderEl = this.$refs.pageslider
if (!pagesliderEl) {
return
}
if (pagesliderEl.scrollLeft <= 0) {
this.$refs.buttonslideleft.classList.add('hidden')
} else {
Expand All @@ -98,7 +101,8 @@ export default {
slideRight() {
const pagesliderEl = this.$refs.pageslider
const newScrollLeft = Math.min(pagesliderEl.scrollLeftMax, pagesliderEl.scrollLeft += SLIDE_OFFSET)
const scrollLeftMax = pagesliderEl.scrollWidth - pagesliderEl.clientWidth
const newScrollLeft = Math.min(scrollLeftMax, pagesliderEl.scrollLeft += SLIDE_OFFSET)
pagesliderEl.scrollTo({
top: pagesliderEl.scrollTop,
left: pagesliderEl.scrollLeft = newScrollLeft,
Expand All @@ -123,7 +127,12 @@ export default {
max-width: 670px;
overflow-x: auto;
scroll-snap-type: x mandatory;
// Hide scrollbar
scrollbar-width: none;
-ms-overflow-style: none;
&::-webkit-scrollbar {
display: none;
}
}
}
Expand Down

0 comments on commit 331a903

Please sign in to comment.