Skip to content

Commit

Permalink
Исправляет рассчёт scroll-margin
Browse files Browse the repository at this point in the history
  • Loading branch information
TatianaFokina committed May 21, 2024
1 parent 4738591 commit 5933427
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/scripts/modules/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class Header extends BaseComponent {
// const state = this.state
// state.stickyHeaderHeight = header.offsetHeight

// document.documentElement.style.setProperty('--sticky-header-height', state.stickyHeaderHeight)
// document.documentElement.style.setProperty('--header-height', state.stickyHeaderHeight)
// }

calculateScrollThreshold() {
Expand Down
8 changes: 7 additions & 1 deletion src/styles/blocks/article-heading.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
.article-heading {
scroll-margin-block: calc(var(--header-height) * 1px + 1rem);
font-size: var(--font-size);
line-height: var(--line-height);
scroll-margin: calc((var(--sticky-header-height, 0) * 1px) + 1rem);
}

@media (width >= 1024px) {
.article-heading {
scroll-margin-block: calc(var(--header-height) * 1px + 2rem);
}
}

.article-heading__title {
Expand Down
1 change: 0 additions & 1 deletion src/styles/blocks/article-nav.css
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
inset: 0;
}

/* TODO: поколдовать с размерами иконок */
.toggle-button__icon {
display: block;
margin: auto;
Expand Down
2 changes: 1 addition & 1 deletion src/styles/blocks/article.css
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@
}

.article__aside {
--header-offset: calc(var(--header-height, 0) * 1px);
--header-offset: calc(var(--header-height) * 1px);
position: sticky;
top: var(--header-offset, 0);
box-sizing: border-box;
Expand Down
8 changes: 7 additions & 1 deletion src/styles/blocks/articles-group.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.articles-group__title {
position: sticky;
top: calc(var(--offset, 0px) + var(--is-header-sticky, 0) * var(--header-height, 0) * 1px);
top: calc(var(--header-height) * 0.2px);
margin-top: 0;
margin-bottom: 12px;
box-sizing: border-box;
Expand All @@ -13,6 +13,12 @@
will-change: top;
}

@media (width >= 1024px) {
.articles-group__title {
top: calc(var(--header-height) * 1.5px);
}
}

.articles-group__sub-title {
margin-top: calc(14 / 15 * 1em);
margin-bottom: calc(17 / 15 * 1em);
Expand Down
16 changes: 1 addition & 15 deletions src/styles/blocks/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
font-family: var(--font-family, sans-serif);
color: var(--color-text);
background-color: var(--color-background);

/* Нам точно нужен этот префикс? */
-webkit-text-size-adjust: 100%;
scroll-behavior: smooth;
}
Expand All @@ -24,17 +22,5 @@
}

.base__body:has(.header--open > .header__controls--shrink) {
padding-top: var(--sticky-header-height);
}

/* TODO: разобраться, нужны ли эти стили */

@media not all and (width >= 768px) {
.base__body:has(.header--open) {
padding-top: 0;
}

.base__body:has(.header--open > .header__controls--shrink) {
padding-top: 0;
}
padding-top: var(--header-height);
}
8 changes: 7 additions & 1 deletion src/styles/blocks/index-section.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,20 @@
}

.index-section__item {
scroll-margin-block: calc(var(--header-height, 0) * 1px + 1em);
scroll-margin-block: calc(var(--header-height) * 1px + 1rem);
position: relative;
padding-bottom: var(--gutter);
display: flow-root;
page-break-inside: avoid;
break-inside: avoid;
}

@media (width >= 1024px) {
.index-section__item {
scroll-margin-block: calc(var(--header-height) * 1px + 2rem);
}
}

.index-section__item::before {
content: "";
opacity: 0;
Expand Down
2 changes: 1 addition & 1 deletion src/styles/blocks/people-page.css
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

.people-page__filter {
position: sticky;
top: calc(var(--is-header-sticky) * var(--header-height) * 1px + var(--offset));
top: calc(var(--header-height) * 1px);
flex: 0 0 14em;
box-sizing: border-box;
transition: top 0.6s;
Expand Down
2 changes: 1 addition & 1 deletion src/styles/blocks/person-page.css
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@

.person-page__avatar {
position: sticky;
top: calc(var(--is-header-sticky) * var(--header-height) * 1px);
top: calc(var(--header-height) * 1px);
transition: top 0.6s;
}

Expand Down

0 comments on commit 5933427

Please sign in to comment.