Skip to content
Extraits de code Groupes Projets
Valider 70801b85 rédigé par ThibG's avatar ThibG Validation de Eugen Rochko
Parcourir les fichiers

Postpone scroll-to-detailed status after react components are loaded (#9773)

parent 5104b61b
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -33,6 +33,17 @@ function main() { ...@@ -33,6 +33,17 @@ function main() {
const Rellax = require('rellax'); const Rellax = require('rellax');
const createHistory = require('history').createBrowserHistory; const createHistory = require('history').createBrowserHistory;
const scrollToDetailedStatus = () => {
const history = createHistory();
const detailedStatuses = document.querySelectorAll('.public-layout .detailed-status');
const location = history.location;
if (detailedStatuses.length === 1 && (!location.state || !location.state.scrolledToDetailedStatus)) {
detailedStatuses[0].scrollIntoView();
history.replace(location.pathname, { ...location.state, scrolledToDetailedStatus: true });
}
};
ready(() => { ready(() => {
const locale = document.documentElement.lang; const locale = document.documentElement.lang;
...@@ -76,8 +87,14 @@ function main() { ...@@ -76,8 +87,14 @@ function main() {
ReactDOM.render(<MediaContainer locale={locale} components={reactComponents} />, content); ReactDOM.render(<MediaContainer locale={locale} components={reactComponents} />, content);
document.body.appendChild(content); document.body.appendChild(content);
scrollToDetailedStatus();
}) })
.catch(error => console.error(error)); .catch(error => {
console.error(error);
scrollToDetailedStatus();
});
} else {
scrollToDetailedStatus();
} }
const parallaxComponents = document.querySelectorAll('.parallax'); const parallaxComponents = document.querySelectorAll('.parallax');
...@@ -85,15 +102,6 @@ function main() { ...@@ -85,15 +102,6 @@ function main() {
if (parallaxComponents.length > 0 ) { if (parallaxComponents.length > 0 ) {
new Rellax('.parallax', { speed: -1 }); new Rellax('.parallax', { speed: -1 });
} }
const history = createHistory();
const detailedStatuses = document.querySelectorAll('.public-layout .detailed-status');
const location = history.location;
if (detailedStatuses.length === 1 && (!location.state || !location.state.scrolledToDetailedStatus)) {
detailedStatuses[0].scrollIntoView();
history.replace(location.pathname, { ...location.state, scrolledToDetailedStatus: true });
}
}); });
delegate(document, '.webapp-btn', 'click', ({ target, button }) => { delegate(document, '.webapp-btn', 'click', ({ target, button }) => {
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter