npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

basic-sliding-carousel

v0.8.0

Published

Lets the user slide laterally through a sequence of child elements.

Downloads

2

Readme

API Documentation

SlidingCarousel ⇐ ElementBase

Lets the user navigate laterally through a sequence of child elements.

Live demo

basic-sliding-carousel is an implementation of the carousel user interface pattern, commonly used for navigating between images, pages, and other elements. This pattern presents the user with a linear sequence of elements, only one of which is shown at a time. The user can navigate to the next/previous element with a variety of input methods.

basic-sliding-carousel is a simpler variation of the more sophisticated basic-carousel component. The latter includes support for wrapping (going forward from the last item to the first, and vice versa), and more complex visual transitions. Those transitions entail use of the Web Animation API, which requires a polyfill in older browsers. Hence, the simpler basic-sliding-carousel may be a more appropriate choice if factors such as download size are critical.

Beyond those differences, basic-sliding-carousel offers the same API, usage recommendations, and support for keyboard/touch/mouse and assistive devices. See that component for more details on use.

Kind: global class Extends: ElementBase
Mixes: ContentAsItems , DirectionSelection , DistributedChildrenAsContent , Generic , ItemsSelection , Keyboard , KeyboardDirection , ObserveContentChanges , SelectionAriaActive , SwipeDirection , TargetInCollective , TrackpadDirection

slidingCarousel.applySelection(item, selected)

Apply the selection state to a single item.

Invoke this method to signal that the selected state of the indicated item has changed. By default, this applies a selected CSS class if the item is selected, and removed it if not selected.

Kind: instance method of SlidingCarousel. Defined by ContentAsItems mixin.

| Param | Type | Description | | --- | --- | --- | | item | HTMLElement | The item whose selection state has changed. | | selected | boolean | True if the item is selected, false if not. |

slidingCarousel.applySelection(item, selected)

Apply the indicate selection state to the item.

The default implementation of this method does nothing. User-visible effects will typically be handled by other mixins.

Kind: instance method of SlidingCarousel. Defined by ItemsSelection mixin.

| Param | Type | Description | | --- | --- | --- | | item | HTMLElement | the item being selected/deselected | | selected | boolean | true if the item is selected, false if not |

slidingCarousel.canSelectNext : boolean

True if the selection can be moved to the next item, false if not (the selected item is the last item in the list).

Kind: instance property of SlidingCarousel. Defined by ItemsSelection mixin.

slidingCarousel.canSelectPrevious : boolean

True if the selection can be moved to the previous item, false if not (the selected item is the first one in the list).

Kind: instance property of SlidingCarousel. Defined by ItemsSelection mixin.

slidingCarousel.content : Array.<HTMLElement>

The content of this component, defined to be the flattened array of children distributed to the component.

Kind: instance property of SlidingCarousel. Defined by DistributedChildrenAsContent mixin.

"content-changed"

This event is raised when the component's contents (including distributed children) have changed.

Kind: event emitted by SlidingCarousel. Defined by ObserveContentChanges mixin.

slidingCarousel.contentChanged()

Invoked when the contents of the component (including distributed children) have changed.

This method is also invoked when a component is first instantiated; the contents have essentially "changed" from being nothing. This allows the component to perform initial processing of its children.

Kind: instance method of SlidingCarousel. Defined by ObserveContentChanges mixin.

slidingCarousel.generic : Boolean

True if the component would like to receive generic styling.

This property is true by default — set it to false to turn off all generic styles. This makes it easier to apply custom styling; you won't have to explicitly override styling you don't want.

Kind: instance property of SlidingCarousel. Defined by Generic mixin. Default: true

slidingCarousel.goDown()

Invoked when the user wants to go/navigate down. The default implementation of this method does nothing.

Kind: instance method of SlidingCarousel. Defined by KeyboardDirection mixin.

slidingCarousel.goEnd()

Invoked when the user wants to go/navigate to the end (e.g., of a list). The default implementation of this method does nothing.

Kind: instance method of SlidingCarousel. Defined by KeyboardDirection mixin.

slidingCarousel.goLeft()

Invoked when the user wants to go/navigate left. The default implementation of this method does nothing.

Kind: instance method of SlidingCarousel. Defined by TrackpadDirection mixin.

slidingCarousel.goLeft()

Invoked when the user wants to go/navigate left. The default implementation of this method does nothing.

Kind: instance method of SlidingCarousel. Defined by KeyboardDirection mixin.

slidingCarousel.goLeft()

Invoked when the user wants to go/navigate left. The default implementation of this method does nothing.

Kind: instance method of SlidingCarousel. Defined by SwipeDirection mixin.

slidingCarousel.goRight()

Invoked when the user wants to go/navigate right. The default implementation of this method does nothing.

Kind: instance method of SlidingCarousel. Defined by TrackpadDirection mixin.

slidingCarousel.goRight()

Invoked when the user wants to go/navigate right. The default implementation of this method does nothing.

Kind: instance method of SlidingCarousel. Defined by KeyboardDirection mixin.

slidingCarousel.goRight()

Invoked when the user wants to go/navigate right. The default implementation of this method does nothing.

Kind: instance method of SlidingCarousel. Defined by SwipeDirection mixin.

slidingCarousel.goStart()

Invoked when the user wants to go/navigate to the start (e.g., of a list). The default implementation of this method does nothing.

Kind: instance method of SlidingCarousel. Defined by KeyboardDirection mixin.

slidingCarousel.goUp()

Invoked when the user wants to go/navigate up. The default implementation of this method does nothing.

Kind: instance method of SlidingCarousel. Defined by KeyboardDirection mixin.

slidingCarousel.itemAdded(item)

This method is invoked whenever a new item is added to the list.

The default implementation of this method does nothing. You can override this to perform per-item initialization.

Kind: instance method of SlidingCarousel. Defined by ContentAsItems mixin.

| Param | Type | Description | | --- | --- | --- | | item | HTMLElement | The item that was added. |

slidingCarousel.itemAdded(item)

Handle a new item being added to the list.

The default implementation of this method simply sets the item's selection state to false.

Kind: instance method of SlidingCarousel. Defined by ItemsSelection mixin.

| Param | Type | Description | | --- | --- | --- | | item | HTMLElement | the item being added |

slidingCarousel.items : Array.<HTMLElement>

The current set of items in the list. See the top-level documentation for mixin for a description of how items differ from plain content.

Kind: instance property of SlidingCarousel. Defined by ContentAsItems mixin.

"items-changed"

Fires when the items in the list change.

Kind: event emitted by SlidingCarousel. Defined by ContentAsItems mixin.

slidingCarousel.itemsChanged()

This method is invoked when the underlying contents change. It is also invoked on component initialization – since the items have "changed" from being nothing.

Kind: instance method of SlidingCarousel. Defined by ContentAsItems mixin.

slidingCarousel.keydown(event) ⇒ boolean

Handle the indicated keyboard event.

The default implementation of this method does nothing. This will typically be handled by other mixins.

Kind: instance method of SlidingCarousel. Defined by Keyboard mixin. Returns: boolean - true if the event was handled

| Param | Type | Description | | --- | --- | --- | | event | KeyboardEvent | the keyboard event |

slidingCarousel.navigationAxis : string

Indicates the direction of permitted navigation with the keyboard.

Accepted values are "horizontal", "vertical", or "both" (the default). If this property is "horizontal", the Up Arrow and Down Arrow keys will be ignored. Conversely, if this is "vertical", the Left Arrow and Right Arrow keys will be ignored.

Kind: instance property of SlidingCarousel. Defined by KeyboardDirection mixin.

"selected-index-changed"

Fires when the selectedIndex property changes.

Kind: event emitted by SlidingCarousel. Defined by ItemsSelection mixin.

| Param | Type | Description | | --- | --- | --- | | detail.selectedIndex | number | The new selected index. |

"selected-item-changed"

Fires when the selectedItem property changes.

Kind: event emitted by SlidingCarousel. Defined by ItemsSelection mixin.

| Param | Type | Description | | --- | --- | --- | | detail.selectedItem | HTMLElement | The new selected item. | | detail.previousItem | HTMLElement | The previously selected item. |

slidingCarousel.selectedIndex : number

The index of the item which is currently selected.

If selectionWraps is false, the index is -1 if there is no selection. In that case, setting the index to -1 will deselect any currently-selected item.

Kind: instance property of SlidingCarousel. Defined by ItemsSelection mixin.

slidingCarousel.selectedItem : object

The currently selected item, or null if there is no selection.

Setting this property to null deselects any currently-selected item.

Kind: instance property of SlidingCarousel. Defined by ItemsSelection mixin.

slidingCarousel.selectFirst()

Select the first item in the list.

Kind: instance method of SlidingCarousel. Defined by ItemsSelection mixin.

slidingCarousel.selectionRequired : boolean

True if the list should always have a selection (if it has items).

Kind: instance property of SlidingCarousel. Defined by ItemsSelection mixin. Default: false

slidingCarousel.selectionWraps : boolean

True if selection navigations wrap from last to first, and vice versa.

Kind: instance property of SlidingCarousel. Defined by ItemsSelection mixin. Default: false

slidingCarousel.selectLast()

Select the last item in the list.

Kind: instance method of SlidingCarousel. Defined by ItemsSelection mixin.

slidingCarousel.selectNext()

Select the next item in the list.

Kind: instance method of SlidingCarousel. Defined by ItemsSelection mixin.

slidingCarousel.selectPrevious()

Select the previous item in the list.

Kind: instance method of SlidingCarousel. Defined by ItemsSelection mixin.

slidingCarousel.showTransition : boolean

Determine whether a transition should be shown during selection.

Components like carousels often define animated CSS transitions for sliding effects. Such a transition should usually not be applied while the user is dragging, because a CSS animation will introduce a lag that makes the swipe feel sluggish. Instead, as long as the user is dragging with their finger down, the transition should be suppressed. When the user releases their finger, the transition can be restored, allowing the animation to show the carousel sliding into its final position.

Note: This property is only intended to let a component cooperate with mixins that may be applied to it, and is not intended to let someone using component permanently enable or disable transition effects.

Kind: instance property of SlidingCarousel

slidingCarousel.target : HTMLElement

Gets/sets the current target of the component.

Set this to point to another element. That target element will be implicitly added to the component's collective. That is, the component and its target will share responsibility for handling keyboard events.

You can set this property yourself, or you can use the ContentFirstChildTarget mixin to automatically set the target to the component's first child.

Kind: instance property of SlidingCarousel. Defined by TargetInCollective mixin.

slidingCarousel.travelFraction : number

The distance the first touchpoint has traveled since the beginning of a drag, expressed as a fraction of the element's width.

Kind: instance property of SlidingCarousel. Defined by SwipeDirection mixin.

slidingCarousel.travelFraction : number

The distance the user has moved the first touchpoint since the beginning of a trackpad/wheel operation, expressed as a fraction of the element's width.

Kind: instance property of SlidingCarousel. Defined by TrackpadDirection mixin.