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