1.1.10 • Published 3 years ago

epic-slidy v1.1.10

Weekly downloads
115
License
SEE LICENSE IN UN...
Repository
github
Last release
3 years ago

Slidy

Read this before doing anything… 😛

to do: install, example, doc, etc…

I/O

Create a parent with children:

<ul class="if-you-want">
  <!-- or <div> or … -->
  <li><img /></li>
  <!-- or <div> or … -->
  <li>
    <img />
    <div>extra content</div>
  </li>
  …
</ul>

then a Slidy instance with some options (including your transition animation):

import Slidy from 'epic-slidy'

const transition = (
  currentSlide: HTMLElement | HTMLElement[],
  newSlide: HTMLElement | HTMLElement[],
  {
    animate: boolean,
    direction: 'prev' | 'next',
    currentIndex: number,
    currentGroup: number,
    newIndex: number,
    newGroup: number,
    trigger:
      'auto' |
      'click' |
      'tap' |
      'drag' |
      'swipe' |
      'nav' |
      'pagination' |
      'controls',
  } as TransitionInfos
) => Promise.resolve() // Do what you want here and return a promise…

// New slider with HTMLElement or CSS selector
const slider = new Slidy('.if-you-want', {
  controls: true,
  nav: true,
  transition,
})
// Use some hooks
slider.on('beforeInit', cb)
// Then init
slider.init()

and you will get this:

<div class="slidy-outer">
  <ul class="slidy what-you-want">
    <li class="slidy__item"><img /></li>
    <li class="slidy__item">
      <img />
      <div>extra content</div>
    </li>
    …
  </ul>
  <!-- if option controls -->
  <div class="slidy-controls">
    <button class="slidy-controls__item--prev">&lt;</button>
    <button class="slidy-controls__item--next">&gt;</button>
  </div>
  <!-- if option nav -->
  <ol class="slidy-nav">
    <li class="slidy-nav__item is-active">
      <button disabled="true">1</button>
    </li>
    <li class="slidy-nav__item">
      <button>2</button>
    </li>
    …
  </ol>
</div>
<!-- end .slidy-outer -->

Config / options

OptionValuesDefaultDescription
autobooleanfalseAuto-start
clickbooleantrueEnable next slide on click
controlsboolean or 'template string'falseNext / prev buttons (see examples)
debouncenumber100Debounce delay on resize
dragbooleanfalseEnable horizontal mouse drag
groupnumber or () => number'auto'Auto or pixel height
height'auto' or number'auto'Auto or pixel height
indexnumber0Initial index
intervalnumber2000Time (ms) betweeen 2 transitions
keyboardbooleanfalseEnable keyboard arrows controls
loopbooleantrueloop … or not
namespacestring'slidy'CSS custom classnamespace
navboolean, 'number', 'thumb' or 'template string'falseDisplay a navigation with numbers / thumbs within custom template (see examples)
paginationboolean or 'separator string'falseDisplay a pagination
pausebooleantruePause on hover
preserveGroupbooleantrueOn loop, force entire group (group: 2 -> 1 2 3 4 5)
queuenumber1Queue max items
resizebooleantrueEnable resize event and callback
reversebooleanfalseReverse directions / controls
swipebooleanfalseEnable horizontal swipe
tapbooleanfalseEnable next slide on tap
transitionFunctionnullAnimation function which returns a promise
zerofillboolean or numberfalse'Zerofill' (1 -> 01) numbers for both nav or pagination

controls details

  • controls: false -> no navigation
  • controls: true -> controls with < / >
  • controls: '<div>${label}</div>' -> <div>previous slide</div> / <div>next slide</div>

If slide elements have a data-slidy-nav attribute, this will override "number" or "thumb" content…

nav details

  • nav: false -> no navigation
  • nav: true -> navigation with numbers (1, 2, 3, …)
  • nav: 'number' -> same as true
  • nav: 'thumb' -> navigation with thumbs (image-name_thumb.ext)
  • nav: '<div>${number}</div>' -> custom "number" navigation
  • nav: '<div>${thumb}</div>' -> custom "thumb" navigation

If slide elements have a data-slidy-nav attribute, this will override "number" or "thumb" content…

Hooks

Usage

slider.on('hookName', function cb() {})

List

type beforeInit = (el: HTMLElement) => void
type afterInit = (el: HTMLElement) => void
type afterResize = (el: HTMLElement) => void
type preventSlide: (action: Action, manager: Manager) => void // You can acces and modify `manager.shouldPrevent` (boolean)
type beforeSlide = (infos: TransitionInfos) => void
type afterSlide = (infos: TransitionInfos) => void

How to contribute

If you want to report a bug or if you just want to request for a new feature/improvement, please follow those instructions before.

Thanks for taking time to contribute to slidy :tada: :+1:


License

See UNLICENSE.

1.1.10

3 years ago

1.1.9

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.0.4

4 years ago

1.1.0

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.9.1

5 years ago

0.9.0

5 years ago

0.8.0

5 years ago

0.7.0

5 years ago

0.6.5

5 years ago

0.6.4

5 years ago

0.6.3

5 years ago

0.6.2

5 years ago

0.6.1

5 years ago

0.6.0

5 years ago

0.5.3

6 years ago

0.5.2

6 years ago

0.5.1

6 years ago

0.5.0

6 years ago

0.4.16

6 years ago

0.4.15

7 years ago

0.4.14

7 years ago

0.4.13

7 years ago

0.4.12

7 years ago

0.4.11

7 years ago

0.4.10

7 years ago

0.4.9

7 years ago

0.4.8

7 years ago

0.4.7

7 years ago

0.4.6

7 years ago

0.4.5

7 years ago

0.4.4

7 years ago

0.4.3

7 years ago

0.4.2

7 years ago

0.4.1

7 years ago

0.4.0

7 years ago

0.3.0

7 years ago

0.2.0

7 years ago

0.1.8

7 years ago

0.1.7

7 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago