Skip to content

Commit

Permalink
refactor(mon-pix): edit constant and create methode to calculate offset
Browse files Browse the repository at this point in the history
Co-authored-by: Clément Latzarus <[email protected]>
  • Loading branch information
dianeCdrPix and clemlatz authored Dec 4, 2024
1 parent ae1db30 commit a71644a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions mon-pix/app/services/modulix-auto-scroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,18 @@ import Service, { service } from '@ember/service';
export default class ModulixAutoScroll extends Service {
@service modulixPreviewMode;

#SCROLL_OFFSET_PX = 70;
#DISTANCE_BETWEEN_GRAIN_AND_NAVBAR_PX = 70;

@action
setHTMLElementScrollOffsetCssProperty(htmlElement) {
htmlElement.style.setProperty('--scroll-offset', `${this.#SCROLL_OFFSET_PX}px`);
htmlElement.style.setProperty('--scroll-offset', `${this.#getScrollOffset()}px`);
}

#getScrollOffset({ getNavbar } = { getNavbar: this.#getNavbar }) {
const navbarElement = getNavbar();
const navbarHeight = navbarElement ? navbarElement.getBoundingClientRect().height : 0;

return this.#DISTANCE_BETWEEN_GRAIN_AND_NAVBAR_PX + navbarHeight;
}

focusAndScroll(
Expand Down

0 comments on commit a71644a

Please sign in to comment.