feat: zero core slider marquee #27
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Documentation for the Slider component
A simple slider that uses named slots to pass in externally styled content and controls to slides/the slider.
The slider operates in one of two modes:
sliderormarqueewhich is passed as the value for themodeprop. Both modes make use of theslidesprop which should be an array of slides that will appear in either the slider or marquee.Slider mode
In slider mode, pass a single template slide into the slot named
slide. This template is duplicated behind the scenes by Nuxt to create a slide for each element in theslidesarray passed as a prop to the slider. A single slot prop,indexis returned to the slot so that the content of the slide template can use this index to look up it's respective slide content from the slides array.A second named slot called
controlsis available where buttons can be added to control the movement of slides. There is a single returned slot prop which is a function calledincrement(). Connect this function to the control button click handlers. Callingincrement()with an argument of-1will rotate all slides back to the left and supplying a value of1will rotate all slides forward to the right.Marquee mode
In marquee mode, the controls slot has no use and can simply be omitted. The marquee is more straightforward and will simply rotate through the array of slides provided using the template passed to the
slideslot to render each slide. The direction of the marquee rotation can be set by supplying the slider with amarquee-directionprop set to eitherleftorright.Common props
Both modes share a
displayprop, which sets how many slides are in view at once and aperiodprop which determines how long, in milliseconds, it takes for a slide to occupy the position of its next neighbour. In marquee mode, this value is multiplied by the number of slides present. Adjusting the period adjusts the speed of both the slider and marquee.Example
For an example of use, run the
sitepackage and navigate to the/sliderroute.