| ... | ... |
@@ -194,4 +194,44 @@ |
| 194 | 194 |
|
| 195 | 195 |
|
| 196 | 196 |
</script> |
| 197 |
+ |
|
| 198 |
+<script> |
|
| 199 |
+ document.addEventListener("DOMContentLoaded", function() {
|
|
| 200 |
+ |
|
| 201 |
+ window.scrollToNextSection = function () {
|
|
| 202 |
+ let sections = document.querySelectorAll('#main .inside > .mod_article, #footer');
|
|
| 203 |
+ var section; |
|
| 204 |
+ |
|
| 205 |
+ for (let i = 0; i < sections.length; i++) |
|
| 206 |
+ {
|
|
| 207 |
+ section = sections[i]; |
|
| 208 |
+ let boundingArea = section.getBoundingClientRect(); |
|
| 209 |
+ let viewportTrigger = window.innerHeight; |
|
| 210 |
+ |
|
| 211 |
+ if (boundingArea.top < viewportTrigger-15) |
|
| 212 |
+ {
|
|
| 213 |
+ continue; |
|
| 214 |
+ } |
|
| 215 |
+ |
|
| 216 |
+ scrollTo({
|
|
| 217 |
+ top: getOffsetTop(section), |
|
| 218 |
+ behavior: "smooth" |
|
| 219 |
+ }); |
|
| 220 |
+ break; |
|
| 221 |
+ } |
|
| 222 |
+ return section; |
|
| 223 |
+ } |
|
| 224 |
+ |
|
| 225 |
+ function getOffsetTop(element,offset=0) {
|
|
| 226 |
+ let offsetTop = 0; |
|
| 227 |
+ while(element) {
|
|
| 228 |
+ offsetTop += element.offsetTop; |
|
| 229 |
+ element = element.offsetParent; |
|
| 230 |
+ } |
|
| 231 |
+ return offsetTop-offset; |
|
| 232 |
+ } |
|
| 233 |
+ |
|
| 234 |
+ }); |
|
| 235 |
+</script> |
|
| 236 |
+ |
|
| 197 | 237 |
<?php $this->endblock(); ?> |