|
34 | 34 |
|
35 | 35 | {% macro sparql_to_iframe(panel) -%} |
36 | 36 | // {{ panel }} iframe |
37 | | -sparqlToIframe2("{{ sparql_endpoint }}", "{{ sparql_editURL }}", |
38 | | -"{{ sparql_embedURL }}", `# tool: scholia |
39 | | -{% include aspect + '_' + panel + '.sparql' %}`, |
40 | | -"#{{ panel }}-iframe", "{{ aspect }}_{{ panel }}.sparql"); |
| 37 | +console.log('adding an observer to: #{{ panel }}-iframe'); |
| 38 | +const {{ panel | replace("-", "") }}Observer = new IntersectionObserver({{ panel | replace("-", "") }}HandleIntersection); |
| 39 | +{{ panel | replace("-", "") }}Observer.observe(document.querySelector('#{{ panel }}-iframe')); |
| 40 | +function {{ panel | replace("-", "") }}HandleIntersection(entries, observer){ |
| 41 | + entries.forEach(entry => { |
| 42 | + if (entry.intersectionRatio > 0) { |
| 43 | + console.log('Element is in the viewport! #{{ panel }}-iframe'); |
| 44 | + sparqlToIframe2("{{ sparql_endpoint }}", "{{ sparql_editURL }}", |
| 45 | + "{{ sparql_embedURL }}", `# tool: scholia |
| 46 | + {% include aspect + '_' + panel + '.sparql' %}`, |
| 47 | + "#{{ panel }}-iframe", "{{ aspect }}_{{ panel }}.sparql" |
| 48 | + ); |
| 49 | + {{ panel | replace("-", "") }}Observer.unobserve(entry.target); |
| 50 | + } |
| 51 | + }); |
| 52 | +} |
| 53 | + |
| 54 | + |
41 | 55 | {%- endmacro %} |
42 | 56 |
|
43 | 57 | {% macro sparql_to_matrix(panel) -%} |
|
0 commit comments