Skip to content

Commit

Permalink
Move overflow margin into CSS
Browse files Browse the repository at this point in the history
  • Loading branch information
felix-hoc committed Dec 19, 2024
1 parent 935380a commit 8b12637
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
3 changes: 3 additions & 0 deletions src/scss/skin-modern/components/_seekbarlabel.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@

> .#{$prefix}-container-wrapper {
@extend %center-on-left-edge;

padding-left: 1em;
padding-right: 1em;
}

// bottom arrow from http://www.cssarrowplease.com/
Expand Down
14 changes: 6 additions & 8 deletions src/ts/components/seekbarlabel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,14 @@ export class SeekBarLabel extends Container<SeekBarLabelConfig> {
'left': seekPositionPx + 'px',
});

// TODO move into CSS
const overflowMargin = 8;

const labelBounding = this.container.getDomElement().get(0).getBoundingClientRect();
// Check parent container as it has a padding that needs to be considered
const labelBounding = this.container.getDomElement().get(0).parentElement.getBoundingClientRect();

let preventOverflowOffset = 0;
if (labelBounding.right + overflowMargin > bounds.right) {
preventOverflowOffset = labelBounding.right - bounds.right + overflowMargin;
} else if (labelBounding.left - overflowMargin < bounds.left) {
preventOverflowOffset = labelBounding.left - bounds.left - overflowMargin;
if (labelBounding.right > bounds.right) {
preventOverflowOffset = labelBounding.right - bounds.right;
} else if (labelBounding.left < bounds.left) {
preventOverflowOffset = labelBounding.left - bounds.left;
}

if (preventOverflowOffset !== 0) {
Expand Down

0 comments on commit 8b12637

Please sign in to comment.