Closed hirasso closed 1 year ago
Description
Right now visit.fragmentVisit contains quite some unnecessary information:
visit.fragmentVisit
export type FragmentVisit = { rule: { from: Path, to: Path, containers: string[], matchesFrom: (path: Path) => boolean, matchesTo: (path: Path) => boolean, name?: string }, containers: string[] }
I'd propose to simplify it to this:
/** * The state of the current visit */ export type FragmentVisit = { name?: string, containers: string[]; };
Usage Example
Don't reset the scroll position for a fragment visit with name "my-fragment-visit":
swup.hooks.on('visit:start', async (visit) => { if (visit.fragmentVisit?.name === 'my-fragment-visit') { visit.scroll.reset = true; } })
visit.fragmentVisit.containers would be equal to visit.containers, but I would keep then around for debugging purposes.
visit.fragmentVisit.containers
visit.containers
Any other ideas?
Since visit.fragmentVisit is not documented yet, I would consider this a non-breaking change.
Checks
master
npm run lint
Looks good! Can't really say which keys might be useful here, but the two suggested should come in handy.
Description
Right now
visit.fragmentVisit
contains quite some unnecessary information:I'd propose to simplify it to this:
Usage Example
Don't reset the scroll position for a fragment visit with name "my-fragment-visit":
visit.fragmentVisit.containers
would be equal tovisit.containers
, but I would keep then around for debugging purposes.Any other ideas?
Since
visit.fragmentVisit
is not documented yet, I would consider this a non-breaking change.Checks
master
branchnpm run lint
)