Skip to content

Commit

Permalink
fix: sticky bar behavior on fixed heights
Browse files Browse the repository at this point in the history
  • Loading branch information
MarioCastigliano committed Jan 31, 2024
1 parent 3dfb296 commit e2b6faf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/components/container/sticky-bar/sticky-bar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@
transition-duration: var(--sbb-sticky-bar-animation-duration);
transition-timing-function: var(--sbb-sticky-bar-animation-easing);

// To push the .sbb-sticky-bar__intersector up without using absolute position we need a negative block margin.
margin-block-end: #{sbb.px-to-rem-build(-1)};

:host(:not([data-expanded])) & {
@include sbb.page-spacing;
}
Expand All @@ -84,10 +87,7 @@
}

.sbb-sticky-bar__intersector {
position: absolute;
width: 100%;

// In order to make the intersection observer work properly on windows the intersector needs to have a defined height
height: #{sbb.px-to-rem-build(1)};
transform: translateY(calc(#{sbb.px-to-rem-build(1)} * -1));
width: 100%;
}
8 changes: 1 addition & 7 deletions src/components/container/sticky-bar/sticky-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,7 @@ export class SbbStickyBarElement extends LitElement {

protected override render(): TemplateResult {
return html`
<div
class="sbb-sticky-bar__wrapper"
@transitionend=${{
handleEvent: () => toggleDatasetEntry(this, 'disableAnimation', false),
once: true,
}}
>
<div class="sbb-sticky-bar__wrapper">
<div class="sbb-sticky-bar">
<slot></slot>
</div>
Expand Down

0 comments on commit e2b6faf

Please sign in to comment.