Primitives / foldkit-primitives/interaction

Layers

namespace · packages/primitives/src/interaction/layers.ts:7

export * as Layers from './layers.js'

ScrollLock and HideOutside as Behaviors: each attaches its foldkit-primitives/dom Mount to a container slot. No Bundle, because the lock and the inert set are document facts Foldkit already refcounts and keys.

In the guides

Members

Layers.ContainerOptions

interface · packages/primitives/src/interaction/layers.ts:13

interface ContainerOptions<Slots> {
  readonly container: keyof Slots & string
}

Layers.hideOutside

const · packages/primitives/src/interaction/layers.ts:52

const hideOutside: {
  <Slots, Input, ParentMessage>(
    bound: SlotView.Bound<Slots, Input, ParentMessage>,
  ): (
    options: ContainerOptions<Slots>,
  ) => Behavior.NamedBehavior<Slots, Input, ParentMessage>
  <Slots>(
    slots: SlotView.Unbound<Slots>,
  ): <Input, ParentMessage>(
    options: ContainerOptions<Slots>,
  ) => Behavior.NamedBehavior<Slots, Input, ParentMessage>
}

Marks everything outside the container inert while it is mounted, and releases that set while the container itself is marked leaving.

Layers.hideOutsideMount

const · packages/primitives/src/dom/layers.ts:34

const hideOutsideMount: Mount.MountDefinitionNoArgs<'HideOutside', never>

Makes everything outside the element, and outside each layer opened after it, inert while it is mounted, and restores it after.

Layers.scrollLock

const · packages/primitives/src/interaction/layers.ts:46

const scrollLock: {
  <Slots, Input, ParentMessage>(
    bound: SlotView.Bound<Slots, Input, ParentMessage>,
  ): (
    options: ContainerOptions<Slots>,
  ) => Behavior.NamedBehavior<Slots, Input, ParentMessage>
  <Slots>(
    slots: SlotView.Unbound<Slots>,
  ): <Input, ParentMessage>(
    options: ContainerOptions<Slots>,
  ) => Behavior.NamedBehavior<Slots, Input, ParentMessage>
}

Locks the document's scroll while the container is mounted; nested locks release together.

Layers.scrollLockMount

const · packages/primitives/src/dom/layers.ts:20

const scrollLockMount: Mount.MountDefinitionNoArgs<'ScrollLock', never>

Locks the document's scroll while the element is mounted; nested locks release with the last.