Logo di Menu Scrolling

Menu Scrolling

Community
asmyshlyaev177
menu-scrolling

Scorrimento imperativo per react-horizontal-scrolling-menu: scrollToItem(getItemById(id), behavior, inline, block), scrollNext/scrollPrev, apiRef per controllare il menu dall’esterno (richiama i metodi, non leggere i dati), getItemElementById/getItemElementByIndex per gli elementi appena aggiunti e navigazione pagina per pagina con slidingWindow + getItemsPos. Caricala quando devi scorrere fino a un elemento all’avvio o alla selezione, controllare il menu dall’esterno, scorrere dopo aver aggiunto elementi dinamicamente, oppure quando scrollToItem non fa nulla senza avvisi o l’intera pagina salta fino al menu.

Add to TypingMind

Panoramica

Pubblicato daasmyshlyaev177
Repositoryreact-horizontal-scrolling-menu
Nome della skillmenu-scrolling
Stelle
790
Fork
101
File inclusi
1
LicenzaMIT
Link
  • Istruzioni in Markdown

    Un file SKILL.md che il modello carica quando serve, consumando token solo quando una richiesta è effettivamente pertinente.

  • Funziona con qualsiasi LLM

    Le skill IA sono in semplice Markdown, non in codice specifico di un fornitore, quindi funzionano con GPT, Claude, Gemini, Grok o un modello locale.

  • File inclusi: 1

    Script, template e riferimenti che il modello può leggere mentre lavora. I file sono di sola lettura e non vengono mai eseguiti.

  • Open source

    Pubblicata da asmyshlyaev177 su GitHub. Leggi i sorgenti prima di installarla.

Installazione

Installa la skill IA Menu Scrolling in TypingMind per usarla con qualsiasi LLM, oppure copiala in un altro agente in grado di leggere SKILL.md.

1

Installa in TypingMind

TypingMind installa una skill direttamente dalla sua cartella GitHub: legge SKILL.md, raccoglie i file delle risorse e salva il risultato in locale.

  1. Apri l'app e vai su Plugin → Skill.
  2. Scegli "Installa da GitHub".
  3. Incolla l'URL della cartella della skill riportato qui sotto e conferma.
    https://github.com/asmyshlyaev177/react-horizontal-scrolling-menu/tree/master/skills/menu-scrolling
  4. Attiva la skill in ogni chat in cui vuoi averla a disposizione.
Plugin → Skill → Aggiungi skill → Da URL GitHub, poi incolla l'URL della cartella e premi Continua.
2

Installa in un altro agente

Qualsiasi agente che legge il formato Agent Skills può usare questa skill: copia la cartella della skill nella directory delle skill di quell'agente.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/asmyshlyaev177/react-horizontal-scrolling-menu.git /tmp/react-horizontal-scrolling-menu
mkdir -p .claude/skills
cp -r /tmp/react-horizontal-scrolling-menu/skills/menu-scrolling .claude/skills/menu-scrolling
Dopo la copia, riavvia Claude Code per caricare la nuova skill.

Usala in TypingMind

Attiva Menu Scrolling in qualsiasi chat di TypingMind e al resto pensa il modello. Il nome e la descrizione della skill sono nel prompt di sistema e, non appena arriva una richiesta pertinente, il modello carica da solo le istruzioni complete: non devi mai richiamarla manualmente e non consuma token finché non viene effettivamente usata.

Il modello carica automaticamente Menu Scrolling non appena riceve una richiesta pertinente.

Funziona con qualsiasi modello IA

Le skill IA sono semplici istruzioni in Markdown, non codice specifico di un fornitore, quindi Menu Scrolling non è vincolata al modello per cui è stata scritta. Installala una sola volta in TypingMind e usala con GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama o un modello locale che esegui tu, sempre con le tue chiavi API.

  • Caricata solo quando serve

    Il prompt di sistema contiene solo il nome e la descrizione. Le istruzioni vengono recuperate alla prima richiesta pertinente, quindi una skill inutilizzata non costa nulla.

  • Cambia modello durante la chat

    Poiché la skill è composta da istruzioni e non da codice, continua a funzionare anche se cambi modello: il nuovo modello legge lo stesso file SKILL.md.

Istruzioni della skill

Questo è il contenuto di SKILL.md che il modello carica. Leggilo prima dell'installazione: una skill è un insieme di istruzioni che il tuo modello seguirà.

Imperative Scrolling

Setup

Click an item to center it. The api object comes from VisibilityContext inside the menu, from the apiRef prop outside it, and as the first argument of every callback prop (onInit, onUpdate, onWheel, onScroll).

tsx
import React from 'react';
import {
  ScrollMenu,
  VisibilityContext,
  type publicApiType,
} from 'react-horizontal-scrolling-menu';
import 'react-horizontal-scrolling-menu/dist/styles.css';

const ids = ['item-0', 'item-1', 'item-2', 'item-3', 'item-4', 'item-5'];

function Card({ itemId, title }: { itemId: string; title: string }) {
  const api = React.useContext<publicApiType>(VisibilityContext);
  return (
    <div
      role="button"
      tabIndex={0}
      style={{ width: '160px' }}
      onClick={() =>
        api.scrollToItem(api.getItemById(itemId), 'smooth', 'center')
      }
    >
      {title}
    </div>
  );
}

export function Menu() {
  return (
    <ScrollMenu>
      {ids.map((id) => (
        <Card itemId={id} key={id} title={id} />
      ))}
    </ScrollMenu>
  );
}

The blessed form is api.scrollToItem(api.getItemById(id), 'smooth', 'center') — a bare string id is a silent no-op (see Common Mistakes). getItemElementById(id) / getItemElementByIndex(index) are the advanced form: they query the DOM directly by data-key / data-index, which makes them stale-proof for items added in the current render.

Defaults (src/helpers.tsx:60,68-69; src/createApi.ts:131-132,152-153):

Methodbehaviorinlineblock
scrollToItem'smooth''end''nearest'
scrollPrev'smooth''end''nearest'
scrollNext'smooth''start''nearest'

behavior accepts 'auto' | 'instant' | 'smooth' and falls back to the transitionBehavior prop when one is set. The optional trailing { duration, boundary } argument only takes effect with noPolyfill={false} — the default native scroll ignores it.

Core Patterns

Control the menu from outside with apiRef

Pass a ref to ScrollMenu; the full context value is assigned to it after mount. Use it to fire methods only — data read from it goes stale.

tsx
import React from 'react';
import {
  ScrollMenu,
  type publicApiType,
} from 'react-horizontal-scrolling-menu';
import 'react-horizontal-scrolling-menu/dist/styles.css';

const ids = ['item-0', 'item-1', 'item-2', 'item-3', 'item-4', 'item-5'];

function Card({ itemId, title }: { itemId: string; title: string }) {
  return <div style={{ width: '160px' }}>{title}</div>;
}

export function PageWithExternalControls() {
  const apiRef = React.useRef<publicApiType | null>(null);

  const centerItem = (id: string) => {
    const api = apiRef.current;
    if (api) api.scrollToItem(api.getItemById(id), 'smooth', 'center');
  };

  return (
    <div>
      <button onClick={() => apiRef.current?.scrollPrev()}>Prev</button>
      <button onClick={() => centerItem('item-3')}>Center item-3</button>
      <button onClick={() => apiRef.current?.scrollNext()}>Next</button>
      <ScrollMenu apiRef={apiRef}>
        {ids.map((id) => (
          <Card itemId={id} key={id} title={id} />
        ))}
      </ScrollMenu>
    </div>
  );
}

Scroll to an item on mount

onInit fires once the menu has rendered and measured its items, so the api is safe to use right away — no timers. Use 'auto' (instant) so the initial position does not animate.

tsx
import React from 'react';
import {
  ScrollMenu,
  type publicApiType,
} from 'react-horizontal-scrolling-menu';
import 'react-horizontal-scrolling-menu/dist/styles.css';

const ids = ['item-0', 'item-1', 'item-2', 'item-3', 'item-4', 'item-5'];

function Card({ itemId, title }: { itemId: string; title: string }) {
  return <div style={{ width: '160px' }}>{title}</div>;
}

export function MenuStartingAtItemFive() {
  const scrollToItemOnInit = (api: publicApiType) => {
    const el = api.getItemElementById('item-5');
    if (el) api.scrollToItem(el, 'auto', 'start');
  };

  return (
    <ScrollMenu onInit={scrollToItemOnInit}>
      {ids.map((id) => (
        <Card itemId={id} key={id} title={id} />
      ))}
    </ScrollMenu>
  );
}

Page-at-a-time navigation with slidingWindow and getItemsPos

scrollNext/scrollPrev already move one viewport-group. Use slidingWindow + getItemsPos when you need to control which item of the target group lands where — e.g. centering the next page:

tsx
import {
  getItemsPos,
  slidingWindow,
  type publicApiType,
} from 'react-horizontal-scrolling-menu';

function scrollOnePage(api: publicApiType, direction: 'prev' | 'next') {
  const visible = api.items.getVisible().map(([id]) => id);
  if (!visible.length) return;
  const group = slidingWindow(api.items.toItems(), visible)[direction]();
  const target = getItemsPos(group).center;
  api.scrollToItem(api.getItemById(target), 'smooth', 'center');
}

slidingWindow(allIds, visibleIds) returns { prev(), next() } — each an id array the size of the visible set, clamped at the row edges. getItemsPos(group) returns { first, center, last } ids of that group.

Common Mistakes

CRITICAL Passing an itemId string to scrollToItem

Wrong:

tsx
api.scrollToItem('item-3', 'smooth', 'center'); // nothing scrolls

Correct:

tsx
api.scrollToItem(api.getItemById('item-3'), 'smooth', 'center');

The JSDoc example shows a bare 'itemId', but scrollToItem unwraps target?.entry?.target — a string has no .entry and no .scrollIntoView, so the call is a silent no-op (the TS type ItemOrElement correctly rejects strings; plain JS gets no error at all).

Source: src/createApi.ts:307-313 (JSDoc) vs src/helpers.tsx:59-64; https://github.com/asmyshlyaev177/react-horizontal-scrolling-menu/issues/157

HIGH Reading data values from apiRef during render

Wrong:

tsx
const atEnd = apiRef.current?.isLastItemVisible; // in render: never re-renders

Correct:

tsx
const api = apiRef.current;
if (api) api.scrollToItem(api.getItemById('item-3'), 'smooth', 'center');

apiRef is a mutable object React cannot re-render on — values read from it during render go stale. Inside event handlers and timers the visibility getters read the live ItemsMap and are fine (on <= 8.3.1 they were frozen even there — read api.items.last()?.visible instead). Reactive state in components comes from the context hooks.

Source: README.md apiRef section; https://github.com/asmyshlyaev177/react-horizontal-scrolling-menu/issues/167

HIGH getItemById right after adding an item returns undefined

Wrong:

tsx
setItems((prev) => [...prev, newItem]);
const api = apiRef.current;
if (api) api.scrollToItem(api.getItemById(newItem.id)); // undefined target — no-op

Correct:

tsx
// after the state update commits (effect or callback):
const api = apiRef.current;
const el = api?.getItemElementById(newItem.id);
if (api && el) api.scrollToItem(el, 'smooth', 'end');

The ItemsMap lags children by one render, so the map does not know a just-appended item yet; getItemElementById/getItemElementByIndex query the DOM by data-key/data-index and are stale-proof for this case.

Source: https://github.com/asmyshlyaev177/react-horizontal-scrolling-menu/issues/167; discussion #295; stories/AddItemAndScrollToIt

HIGH Scroll methods drag the whole page to the menu

Wrong:

tsx
setInterval(() => apiRef.current?.scrollNext(), 3000); // page keeps jumping to the menu

Correct:

tsx
setInterval(() => {
  if (apiRef.current?.menuVisible.current) apiRef.current.scrollNext();
}, 3000);

Scrolling is scrollIntoView-based, so scroll methods called while the menu is off screen scroll ancestor containers too (the page jumps vertically to the menu) — gate every programmatic scroll on menuVisible.current.

Source: https://github.com/asmyshlyaev177/react-horizontal-scrolling-menu/issues/276 (#277, #174, #230)

MEDIUM Numeric itemIds compared as numbers

Wrong:

tsx
<Card itemId={idx} key={idx} title={String(idx)} />;
// later:
api.getItemById(idx + 1);

Correct:

tsx
<Card itemId={String(idx)} key={idx} title={String(idx)} />;
// later:
api.getItemById(String(idx + 1));

itemId is String()-coerced everywhere internally, so getItemById(5) looks up "5" — mixing number and string ids causes missed lookups.

Source: CHANGELOG v3.1.1 (#207); src/helpers.tsx:102

MEDIUM Calling apiRef.current methods before mount

Wrong:

tsx
const apiRef = React.useRef<publicApiType | null>(null);
apiRef.current.scrollNext(); // during render — crash or no-op

Correct:

tsx
const apiRef = React.useRef<publicApiType | null>(null);
React.useEffect(() => {
  apiRef.current?.scrollNext();
}, []);

apiRef is populated in a useEffect after mount (src/index.tsx:281-287); before that current is null (or an empty object internally) — call methods only from effects or event handlers, with optional chaining.

Source: src/index.tsx:148,281-287

MEDIUM Reimplementing page math instead of slidingWindow/getItemsPos

Wrong:

tsx
const all = api.items.toItems();
const firstVisible = api.items.getVisible()[0]?.[0];
const next = all[all.indexOf(firstVisible) + 3]; // breaks at edges, wrong in RTL

Correct:

tsx
const visible = api.items.getVisible().map(([id]) => id);
const next = slidingWindow(api.items.toItems(), visible).next();
api.scrollToItem(api.getItemById(getItemsPos(next).center), 'smooth', 'center');

Page-at-a-time and centering math is shipped — slidingWindow().prev()/.next() plus getItemsPos() handle row edges and RTL; hand-rolled index math misses both.

Source: README.md Other helpers; stories/OneItemScroll

Tensions

HIGH Tension: Trivial quick start vs total silence on misuse

The library contains zero throws or warnings — every contract violation (missing styles.css, missing/duplicate itemId, string to scrollToItem) fails silently with no error to debug from. Self-check the contracts before shipping. See skills/menu-setup/SKILL.md and skills/menu-visibility/SKILL.md.

HIGH Tension: Imperative convenience vs reactive truth

The api object mixes live methods, reactive hooks, non-reactive getters (isFirstItemVisible/isLastItemVisible) and mutable stores (items, apiRef). Fire methods imperatively; in components rendered under ScrollMenu read state through the hooks — render reads of the getters never update. See skills/menu-visibility/SKILL.md.

HIGH Tension: Native scroll correctness vs animation control

noPolyfill defaults to true, so the per-call { duration, boundary } ScrollOptions and the transition props are silently discarded; noPolyfill={false} restores animation control but re-imports polyfill edge bugs (RTL, page-level scrolling). See skills/menu-transitions-rtl/SKILL.md.

See also

  • skills/menu-visibility/SKILL.md — paging math consumes the visible set (items.getVisible()), and scroll gating uses menuVisible
  • skills/menu-recipes/SKILL.md — autoplay, infinite loop, load-more and center-on-click are recipes built from these scroll methods
  • skills/menu-transitions-rtl/SKILL.md — transition props and ScrollOptions modify how the scroll methods animate

References

File inclusi

Il modello legge questi file quando servono, mentre la skill è caricata. Sono accessibili in sola lettura e non vengono mai eseguiti.

Domande frequenti

Cosa fa la skill IA Menu Scrolling?

Scorrimento imperativo per react-horizontal-scrolling-menu: scrollToItem(getItemById(id), behavior, inline, block), scrollNext/scrollPrev, apiRef per controllare il menu dall’esterno (richiama i metodi, non leggere i dati), getItemElementById/getItemElementByIndex per gli elementi appena aggiunti e navigazione pagina per pagina con slidingWindow + getItemsPos. Caricala quando devi scorrere fino a un elemento all’avvio o alla selezione, controllare il menu dall’esterno, scorrere dopo aver aggiunto elementi dinamicamente, oppure quando scrollToItem non fa nulla senza avvisi o l’intera pagina...

Perché usare Menu Scrolling su TypingMind?

Perché la installi una volta e la usi con qualsiasi modello. Menu Scrolling è scritta in semplice Markdown anziché in codice specifico di un fornitore, quindi la stessa skill funziona con GPT-5, Claude, Gemini, Grok o un modello locale, e puoi cambiare modello durante la chat senza che la skill smetta di funzionare. TypingMind usa le tue chiavi API, quindi paghi direttamente i fornitori anziché un abbonamento per posto utente, e le tue skill e chat restano nel tuo spazio di archiviazione.

Come installo Menu Scrolling in TypingMind?

Apri Plugin → Skill → Installa da GitHub in TypingMind e incolla https://github.com/asmyshlyaev177/react-horizontal-scrolling-menu/tree/master/skills/menu-scrolling. TypingMind legge il file SKILL.md, include i file associati e installa la skill, che puoi abilitare per ogni singola chat.

Quali modelli IA possono usare Menu Scrolling?

Qualsiasi modello che colleghi a TypingMind. Le skill IA sono semplici istruzioni in Markdown anziché codice specifico di un fornitore, quindi GPT, Claude, Gemini, Grok e i modelli locali possono tutti caricare questa skill quando una richiesta corrisponde al suo scopo.

Quanti modelli IA posso usare con Menu Scrolling?

Quanti ne vuoi. Se un modello supporta le skill, puoi usarlo con Menu Scrolling: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e molti altri, tutti su TypingMind con le tue chiavi API.

La skill IA Menu Scrolling è gratuita?

Sì. È pubblicata su GitHub da asmyshlyaev177 con licenza MIT. Paghi solo il tuo fornitore IA per i token che usi.

Cosa sono le skill IA?

Una skill IA è un pacchetto di istruzioni riutilizzabili che insegna a un modello IA come svolgere un'attività specifica. Segue il formato aperto Agent Skills: un file SKILL.md con un nome e una descrizione, più eventuali script, template o file di riferimento di cui il modello potrebbe aver bisogno. Il modello legge le istruzioni solo quando la tua richiesta corrisponde alla skill, quindi una skill installata non comporta costi finché non viene usata.

In cosa si differenziano le skill IA dai plugin o dai server MCP?

Un plugin o un server MCP fornisce a un modello nuovi strumenti da richiamare: codice che viene eseguito da qualche parte e restituisce un risultato. Una skill IA, invece, fornisce al modello conoscenze e procedure: come affrontare un'attività, quali passaggi seguire e quali caratteristiche deve avere un buon output. Le skill sono semplici istruzioni in Markdown, quindi non richiedono server, chiavi API né ambienti di esecuzione e funzionano con qualsiasi modello.

Elenco completo

Crea subito il tuo spazio di lavoro AI

Iscriviti alla nostra newsletter per ricevere aggiornamenti sulle nuove funzionalità e sulle prossime iniziative a premi 👇