Adrià Vilanova Martínez | d269c62 | 2021-09-04 18:35:55 +0200 | [diff] [blame] | 1 | import {getOptions} from '../common/optionsUtils.js'; |
| 2 | |
avm99963 | cbea314 | 2019-03-28 00:48:15 +0100 | [diff] [blame] | 3 | var intersectionObserver; |
| 4 | |
avm99963 | 847ee63 | 2019-03-27 00:57:44 +0100 | [diff] [blame] | 5 | function intersectionCallback(entries, observer) { |
avm99963 | 847ee63 | 2019-03-27 00:57:44 +0100 | [diff] [blame] | 6 | entries.forEach(entry => { |
| 7 | if (entry.isIntersecting) { |
| 8 | entry.target.click(); |
| 9 | } |
| 10 | }); |
| 11 | }; |
| 12 | |
| 13 | var intersectionOptions = { |
avm99963 | b69eb3d | 2020-08-20 02:03:44 +0200 | [diff] [blame] | 14 | threshold: 1.0, |
| 15 | }; |
avm99963 | 847ee63 | 2019-03-27 00:57:44 +0100 | [diff] [blame] | 16 | |
Adrià Vilanova Martínez | d269c62 | 2021-09-04 18:35:55 +0200 | [diff] [blame] | 17 | getOptions('list').then(options => { |
avm99963 | b69eb3d | 2020-08-20 02:03:44 +0200 | [diff] [blame] | 18 | var button = document.querySelector('.thread-list-threads__load-more-button'); |
Adrià Vilanova Martínez | d269c62 | 2021-09-04 18:35:55 +0200 | [diff] [blame] | 19 | if (options.list && button !== null) { |
avm99963 | b69eb3d | 2020-08-20 02:03:44 +0200 | [diff] [blame] | 20 | intersectionObserver = |
| 21 | new IntersectionObserver(intersectionCallback, intersectionOptions); |
avm99963 | cbea314 | 2019-03-28 00:48:15 +0100 | [diff] [blame] | 22 | intersectionObserver.observe(button); |
| 23 | } |
| 24 | }); |