Skip to content

Methods & properties ​

Constructor ​

ts
new InsigneSlider(target: HTMLElement | string, options?: Options): InsigneSlider
ParameterTypeDescription
targetHTMLElement | stringThe element (or a selector) whose children become slides. Must be able to host a shadow root.
optionsOptionsAny options. Merged over markup options (data-*, JSON).

If the element already has a slider, the existing instance is returned and the options are applied to it. Throws if the element is not found or cannot host a slider.

Static members ​

MemberSignatureDescription
InsigneSlider.get(target: Element | string | null) => InsigneSlider | undefinedThe instance of an element.
InsigneSlider.create(target, spec: SliderSpec) => InsigneSliderRenders slides from data and starts a slider. See JSON.
InsigneSlider.init(root?: ParentNode) => InsigneSlider[]Starts every [data-insigne] under root (default document).
InsigneSlider.autoInit() => voidinit() when the DOM is ready, and for elements added later.
InsigneSlider.define(sliderTag?, slideTag?) => voidRegisters <insigne-slider> / <insigne-slide> (idempotent).
InsigneSlider.effectsreadonly string[]All effect names.
InsigneSlider.optionsreadonly OptMeta[]Option metadata (name, type, default, values, range).
InsigneSlider.defaultsRecord<string, unknown>Default values.
InsigneSlider.versionstringLibrary version.

Instance methods ​

All methods return the instance, so they can be chained, unless noted.

MethodSignatureDescription
next() => thisNext slide (respects loop).
prev() => thisPrevious slide.
goTo(index: number, opts?: { instant?: boolean }) => thisGo to a slide (0-based). With a loop, takes the shortest way.
play() => thisStart autoplay (enables it if it was off).
pause() => thisStop autoplay until play().
update(options: Options) => thisChange options at runtime. The current slide is kept.
refresh() => thisRe-read slides from the DOM. Automatic when children change.
addSlide(content: Node | string, index?: number) => thisInsert a slide (element or HTML string). Default: at the end.
removeSlide(index: number) => thisRemove a slide.
on(event, handler) => () => voidSubscribe; returns an unsubscribe function. See events.
once(event, handler) => () => voidSubscribe for one call.
off(event, handler) => voidUnsubscribe.
destroy() => voidStop everything, restore your markup and inline styles, release WebGL.

Properties (read-only) ​

PropertyTypeDescription
elHTMLElementThe slider element.
indexnumberCurrent slide (0-based, always the real index).
countnumberNumber of slides.
slidesHTMLElement[]The slide elements (a copy of the list).
optionsReadonly<Record<string, any>>Resolved options (defaults + markup + constructor + updates).
isPlayingbooleanAutoplay is on and not stopped by the user (it may still be paused by hover or visibility).
isMovingbooleanA transition is running.

Element API ​

<insigne-slider> forwards the common members, so you rarely need the instance:

MemberDescription
el.sliderThe InsigneSlider instance (after the element is ready).
el.optionsGet the resolved options; set an object to update.
el.next(), el.prev(), el.goTo(i), el.play(), el.pause()As above.
el.index, el.countAs above.
el.on(event, fn)As above (after ready). Or listen to insigne:<event> DOM events.

Insigne Slider v1.0.0 · Free for any use with visible attribution · Atıf ile her kullanım için ücretsiz