demarches-normaliennes/app/javascript/new_design/messagerie.js

18 lines
402 B
JavaScript
Raw Normal View History

2018-10-09 11:43:38 +02:00
import { scrollTo, scrollToBottom } from '@utils';
2018-08-09 11:53:59 +02:00
export function scrollMessagerie() {
2018-10-09 11:43:38 +02:00
const ul = document.querySelector('.messagerie ul');
2018-10-09 11:43:38 +02:00
if (ul) {
const elementToScroll = document.querySelector('.date.highlighted');
2018-10-09 11:43:38 +02:00
if (elementToScroll) {
scrollTo(ul, elementToScroll);
} else {
2018-10-09 11:43:38 +02:00
scrollToBottom(ul);
}
}
}
addEventListener('turbolinks:load', scrollMessagerie);