Skip to content
Open
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
27 changes: 14 additions & 13 deletions redaxo/src/core/assets/standard.js
Original file line number Diff line number Diff line change
Expand Up @@ -528,22 +528,23 @@ function getCookie(cookieName) {
return unescape(theCookie.substring(ind + cookieName.length + 1, ind1));
}

// scroll to anchor element + adjust scroll-padding-top
function scrollToAnchor() {
// scroll to anchor element
var scrollToAnchor = function () {
if (window.location.hash) {
var scrollPadding = window.getComputedStyle(document.documentElement).getPropertyValue('scroll-padding-top');
scrollPadding = parseInt(scrollPadding, 10); // so 65px will be 65
if (scrollPadding > 0) {
var anchorItem = document.querySelector(window.location.hash);
if (anchorItem) {
var anchorItemPosition = anchorItem.getBoundingClientRect().top;
if (!isNaN(scrollPadding) && scrollPadding > 0 && anchorItemPosition < scrollPadding) {
window.scrollBy(0, -scrollPadding);
}
}
var hash = window.location.hash;
var anchorItem = document.querySelector(hash);

if (anchorItem) {
// Ein minimaler Timeout (0-10ms) hilft oft Wunder bei Pjax-Updates
setTimeout(function () {
anchorItem.scrollIntoView({
block: "start",
behavior: "smooth"
});
}, 200);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

250 ms liefert noch ein besseres Ergebnis, ich weiss nur nicht wie ich hier den PR noch ändern kann :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Du musst den Wert nur in deinem branch ändern

}
}
}
};

var rex_loader = {
timeoutId: null,
Expand Down
Loading