From 0b0ce84673fb9e8ed413f5d7aac6f6bd96765fb2 Mon Sep 17 00:00:00 2001 From: vojtechrichter Date: Thu, 6 Aug 2026 10:58:41 +0200 Subject: [PATCH] feat: add x-paginator controller for scroll and snippet handling --- src/scripts/components/+.js | 1 + src/scripts/components/Paginator.js | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 src/scripts/components/Paginator.js diff --git a/src/scripts/components/+.js b/src/scripts/components/+.js index 95e27f6..c971d97 100644 --- a/src/scripts/components/+.js +++ b/src/scripts/components/+.js @@ -2,4 +2,5 @@ import './(ui)/+.js' import './App.js' import './ReCaptcha.js' import './Reveal.js' +import './Paginator.js' import './cookieconsent/+.js' diff --git a/src/scripts/components/Paginator.js b/src/scripts/components/Paginator.js new file mode 100644 index 0000000..347d364 --- /dev/null +++ b/src/scripts/components/Paginator.js @@ -0,0 +1,17 @@ +import { Controller, useStimulus } from '../composables/stimulus.js' + +useStimulus.register('x-paginator', class extends Controller { + static targets = ['append', 'scroll'] + + scroll() { + this.scrollTarget.scrollIntoView({ behavior: 'smooth', block: 'start' }) + } + + addSnippetAppend() { + this.appendTarget.setAttribute('data-naja-snippet-append', '') + } + + removeSnippetAppend() { + this.appendTarget.removeAttribute('data-naja-snippet-append') + } +})