blob: 0163f545f951ace83417edd4012fced948078ee4 [file] [log] [blame]
Adrià Vilanova Martínezd269c622021-09-04 18:35:55 +02001import {getOptions} from '../common/optionsUtils.js';
2
avm99963cbea3142019-03-28 00:48:15 +01003var intersectionObserver;
4
avm99963847ee632019-03-27 00:57:44 +01005function intersectionCallback(entries, observer) {
avm99963847ee632019-03-27 00:57:44 +01006 entries.forEach(entry => {
7 if (entry.isIntersecting) {
8 entry.target.click();
9 }
10 });
11};
12
13var intersectionOptions = {
avm99963b69eb3d2020-08-20 02:03:44 +020014 threshold: 1.0,
15};
avm99963847ee632019-03-27 00:57:44 +010016
Adrià Vilanova Martínezd269c622021-09-04 18:35:55 +020017getOptions('list').then(options => {
avm99963b69eb3d2020-08-20 02:03:44 +020018 var button = document.querySelector('.thread-list-threads__load-more-button');
Adrià Vilanova Martínezd269c622021-09-04 18:35:55 +020019 if (options.list && button !== null) {
avm99963b69eb3d2020-08-20 02:03:44 +020020 intersectionObserver =
21 new IntersectionObserver(intersectionCallback, intersectionOptions);
avm99963cbea3142019-03-28 00:48:15 +010022 intersectionObserver.observe(button);
23 }
24});