0.0.12 โ€ข Published 2 years ago

svelte-interactive-carousel v0.0.12

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago
WARNING!This package is still under development. It does not do what it says it does (yet!).

Netlify Status

Interactive Carousel (for Svelte)

A smooth, draggable, stylable, responsive, friendly, interactive carousel that is basicly a marquee, but way cooler. Importable as a svelte-component.


๐Ÿ“”DocsFull Documentation & Examples
๐Ÿ“ฆNPMNode Module details
<!-- ๐Ÿ“REPLSvelte component demo -->
<!-- โคCodepenPlain JS component demo -->

features

  • โœจ fully customisable, stylable & accessible
  • ๐Ÿ‘† draggable
  • ๐Ÿ–ฑ scrollable (trackpad horizontal scrolling)
  • ๐Ÿ’ป responsive
  • ๐ŸŽญ animated

install

Open your project and use the command line to install the package;

pnpm add svelte-interactive-carousel --save-dev               # for pnpm
npm i svelte-interactive-carousel@latest --save-dev --force   # for npm
yarn add svelte-interactive-carousel --dev                    # for yarn

Tip:: If you're using npm/yarn, check out pnpm! It's 2x faster.

usage

in a svelte project

Assuming you have a Svelte app up and running;

<script>
  import {InteractiveCarousel, Slide} from "svelte-interactive-carousel";
</script>

<InteractiveCarousel values={[50]} pips>
    <Slide>1</Slide>
    <Slide>2</Slide>
    <Slide>3</Slide>
</InteractiveCarousel>

<!--

props (options)

carousel props

proptypedefaultdescription
valuesArray[50]Array of values to apply on the slider. Multiple values creates multiple handles. (note: A slider with range property set can only have two values max)
minNumber0Minimum value for the slider (should be < max)
maxNumber100Maximum value for the slider (should be > min)
stepNumber1Every nth value to allow handle to stop at (should be a positive value)
rangeBoolean/StringfalseWhether to style as a range picker. Use range='min' or range='max' for min/max variants
pushyBooleanfalseIf range is true, then this boolean decides if one handle will push the other along
floatBooleanfalseSet true to add a floating label above focussed handles
verticalBooleanfalseMake the slider render vertically (lower value on bottom)
pipsBooleanfalseWhether to show pips/notches on the slider
pipstepNumber1/10/20Every nth step to show a pip for. This has multiple defaults depending on values property
firstBoolean/StringfalseWhether to show a pip or label for the first value on slider. Use first='label' to show a label value
lastBoolean/StringfalseWhether to show a pip or label for the last value on slider. Use last='label' to show a label value
restBoolean/StringfalseWhether to show a pip or label for all other values. Use rest='label' to show a label value
allBoolean/StringfalseWhether to show a pip or label for all values. Same as combining first, last and rest. Use all='label' to show a label value
prefixString""A string to prefix to all displayed values
suffixString""A string to suffix to all displayed values
reversedBooleanfalseReverse the orientation of min/max
hoverableBooleantrueWhether hover styles are enabled for both handles and pips/values
disabledBooleanfalseDetermine if the slider is disabled, or enabled (only disables interactions, and events)
idString""Give the slider a unique ID for use in styling
formatterFunction(v,i,p) => vA function to re-format values before they are displayed (v = value, i = pip index, p = percent)
handleFormatterFunctionformatterA function to re-format values on the handle/float before they are displayed. Defaults to the same function given to the formatter property (v = value, i = handle index, p = percent)
springValuesObject{ stiffness: 0.15, damping: 0.4 }Svelte spring physics object to change the behaviour of the handle when moving
sliderElementundefinedDOM reference for binding to the main <div /> of the component (bind:slider='ref')

slider events (dispatched)

eventexampleevent.detaildescription
starton:start={(e) => { ... }}{ activeHandle: Integer, value: Float, values: Array }Event fired when the user begins interaction with the slider
changeon:change={(e) => { ... }}{ activeHandle: Integer, startValue: Float, previousValue: Float, value: Float, values: Array }Event fired when the user changes the value; returns the previous value, also
stopon:stop={(e) => { ... }}{ activeHandle: Integer, startValue: Float, value: Float, values: Array }Event fired when the user stops interacting with slider; returns the beginning value, also

๐Ÿ“”๐Ÿ“˜๐Ÿ“– Full Documentation & Examples

styling

Styling should mostly be done with CSS.
There's a bunch of css variables for controlling the colors of the elements. And the slider is fluid horizontally, with the size of things controlled by font-size. So you may change he font-size on the .rangeSlider base element to change the scale of everything.

If you require more fine control of the widths, heights, etc, then you may override the default css. This can be easier by using the id prop to give your slider a unique id.

Values of labels can be styled with CSS, and the format can be modified with the formatter() function prop. And animation of the handles is controlled by the springValues object prop.

contribute

I am very happy to accept;

  • ๐ŸŒŸ suggestions/requests for new features or changes
  • ๐Ÿ›  pull-requests for bug fixes, or issue resolution
  • ๐Ÿงช help with creating a proper test-suite

Read the CONTRIBUTING.md


support / donate

I'd be super excited if you find this project useful and wish to donate a small amount for my efforts!

ยฃ1 One Pound Donationยฃ1 GBP donation
ยฃ5 Five Pounds Donationยฃ5 GBP donation
ยฃ10 Ten Pounds Donationยฃ10 GBP donation-->