From 25cdaebed6c254518f2829764de9f794c5be15a8 Mon Sep 17 00:00:00 2001 From: morethanwords Date: Fri, 6 Nov 2020 19:51:51 +0200 Subject: [PATCH] Fix scroll to element if it is bigger than client --- src/components/scrollable.ts | 4 ++-- src/scss/partials/popups/_datePicker.scss | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/scrollable.ts b/src/components/scrollable.ts index 86b59876..2a5b730c 100644 --- a/src/components/scrollable.ts +++ b/src/components/scrollable.ts @@ -484,7 +484,7 @@ export default class Scrollable extends ScrollableBase { const clientHeight = this.container.clientHeight; const height = element.scrollHeight; - const d = (clientHeight - height) / 2; + const d = height >= clientHeight ? 0 : (clientHeight - height) / 2; offset -= d; this.scrollTo(offset, 'top', smooth); @@ -558,7 +558,7 @@ export class ScrollableX extends ScrollableBase { const clientWidth = this.container.clientWidth; const width = element.scrollWidth; - const d = (clientWidth - width) / 2; + const d = width >= clientWidth ? 0 : (clientWidth - width) / 2; offset -= d; this.scrollTo(offset, 'left', smooth, undefined, scrollTime); diff --git a/src/scss/partials/popups/_datePicker.scss b/src/scss/partials/popups/_datePicker.scss index ea9f2bf0..fc20f4ab 100644 --- a/src/scss/partials/popups/_datePicker.scss +++ b/src/scss/partials/popups/_datePicker.scss @@ -70,6 +70,7 @@ &-months { margin-top: 7px; margin-bottom: 1.5rem; + user-select: none; } &-month {