Skip to content

Commit

Permalink
Show the back end header on scroll-up
Browse files Browse the repository at this point in the history
  • Loading branch information
leofeyer committed Nov 27, 2023
1 parent 9398d8e commit b08000e
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 12 deletions.
1 change: 1 addition & 0 deletions core-bundle/assets/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { definitionForModuleAndIdentifier, identifierForContextKey } from '@hotw
import './scripts/mootao.js'
import './scripts/core.js'
import './scripts/autofocus.js'
import './scripts/hide-header.js'
import './scripts/limit-height.js'
import './scripts/modulewizard.js'
import './scripts/sectionwizard.js'
Expand Down
21 changes: 21 additions & 0 deletions core-bundle/assets/scripts/hide-header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
window.addEventListener('DOMContentLoaded', function() {
const header = document.querySelector('header');
if (!header) return;

let lastScroll = 0;

window.addEventListener('scroll', function() {
// Make sure the scroll value is between 0 and maxScroll
const currentScroll = Math.max(0, Math.min(document.documentElement.scrollHeight - document.documentElement.clientHeight, window.scrollY));

if (lastScroll < currentScroll) {
header.classList.add('header--hidden');
} else if (lastScroll > currentScroll) {
header.classList.remove('header--hidden');
}

lastScroll = currentScroll;
}, {
passive: true
});
});
2 changes: 2 additions & 0 deletions core-bundle/contao/themes/flexible/backend.1517b9b9.css

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions core-bundle/contao/themes/flexible/backend.2d542cb5.css

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion core-bundle/contao/themes/flexible/entrypoints.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"entrypoints": {
"backend": {
"css": [
"/system/themes/flexible/backend.2d542cb5.css"
"/system/themes/flexible/backend.1517b9b9.css"
]
},
"confirm": {
Expand Down
4 changes: 2 additions & 2 deletions core-bundle/contao/themes/flexible/manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"backend.css": "/system/themes/flexible/backend.2d542cb5.css",
"backend.css": "/system/themes/flexible/backend.1517b9b9.css",
"confirm.css": "/system/themes/flexible/confirm.5231eaa5.css",
"conflict.css": "/system/themes/flexible/conflict.41a64ff6.css",
"diff.css": "/system/themes/flexible/diff.028ed04c.css",
Expand All @@ -8,7 +8,7 @@
"popup.css": "/system/themes/flexible/popup.751f0537.css",
"tinymce.css": "/system/themes/flexible/tinymce.e5009f94.css",
"tinymce-dark.css": "/system/themes/flexible/tinymce-dark.596023db.css",
"backend.2d542cb5.css.map": "/system/themes/flexible/backend.2d542cb5.css.map",
"backend.1517b9b9.css.map": "/system/themes/flexible/backend.1517b9b9.css.map",
"confirm.5231eaa5.css.map": "/system/themes/flexible/confirm.5231eaa5.css.map",
"conflict.41a64ff6.css.map": "/system/themes/flexible/conflict.41a64ff6.css.map",
"diff.028ed04c.css.map": "/system/themes/flexible/diff.028ed04c.css.map",
Expand Down
11 changes: 11 additions & 0 deletions core-bundle/contao/themes/flexible/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ body.popup {
min-height: 40px;
text-align: left;
background: var(--header-bg);
position: fixed;
top: 0;
width: 100%;
z-index: 4;
transition: transform .2s ease;
transform: none;
}

#header.header--hidden {
transform: translateY(-40px);
}

#header h1 {
Expand Down Expand Up @@ -273,6 +283,7 @@ body.popup {
#container {
display: flex;
min-height: calc(100vh - 40px);
padding-top: 40px;
}

.popup #container {
Expand Down
1 change: 0 additions & 1 deletion core-bundle/public/backend.6e5c28a4.js.map

This file was deleted.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions core-bundle/public/backend.e55e9ea3.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core-bundle/public/entrypoints.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"entrypoints": {
"backend": {
"js": [
"/bundles/contaocore/backend.6e5c28a4.js"
"/bundles/contaocore/backend.e55e9ea3.js"
]
}
}
Expand Down
4 changes: 2 additions & 2 deletions core-bundle/public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"backend.js": "/bundles/contaocore/backend.6e5c28a4.js",
"backend.6e5c28a4.js.map": "/bundles/contaocore/backend.6e5c28a4.js.map"
"backend.js": "/bundles/contaocore/backend.e55e9ea3.js",
"backend.e55e9ea3.js.map": "/bundles/contaocore/backend.e55e9ea3.js.map"
}

0 comments on commit b08000e

Please sign in to comment.