Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/js/constants/selectors-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
* file that was distributed with this source code.
*/

export const layout = {
stickyHeader: '.js-sticky-header',
};

export const facetedsearch = {
range: '.js-faceted-slider',
rangeContainer: '.js-faceted-slider-container',
Expand Down Expand Up @@ -145,6 +149,7 @@ export const passwordPolicy = {
};

const selectorsMap = {
layout,
qtyInput,
alert: {
selector: '#notifications .container',
Expand Down
22 changes: 22 additions & 0 deletions src/js/helpers/scrollPadding.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

import SelectorsMap from '@constants/selectors-map';

const setScrollPaddingTop = () => {
const header = document.querySelector(SelectorsMap.layout.stickyHeader) as HTMLElement;

if (header) {
const headerHeight = header.offsetHeight;
document.documentElement.style.setProperty('scroll-padding-top', `${headerHeight}px`);
}
};

const initScrollPaddingTop = () => {
window.addEventListener('load', setScrollPaddingTop);
window.addEventListener('resize', setScrollPaddingTop);
};

export default initScrollPaddingTop;
2 changes: 2 additions & 0 deletions src/js/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import './modules/facetedsearch';
import initDesktopMenu from './modules/ps_mainmenu';
import initFormValidation from './form-validation';
import initCategoryTree from './modules/ps_categorytree';
import initScrollPaddingTop from './helpers/scrollPadding';

initEmitter();

Expand All @@ -52,6 +53,7 @@ $(() => {
initErrorHandler();
usePasswordPolicy('.field-password-policy');
initCategoryTree();
initScrollPaddingTop();

prestashop.on(events.responsiveUpdate, () => {
initSearchbar();
Expand Down
2 changes: 1 addition & 1 deletion templates/layouts/layout-both-columns.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
{include file='catalog/_partials/product-activation.tpl'}
{/block}

<header id="header" class="header">
<header id="header" class="header js-sticky-header">
{block name='header'}
{include file='_partials/header.tpl'}
{/block}
Expand Down