SwipeX.js
Smoothly swiper support horizontal and vertical mode.
🎉 support rax framework

>>>>>>>>>> 「source code 」<<<<<<<<<<
>>>>>>>>>> 「demo online 」<<<<<<<<<<
Quick Start
$ npm install swipex
html:
1 2 3
javascript:
window.mySwipeX = SwipeXcontainer
Usage
Swipex.js is a javascript library, you can custom define className in html
<!-- this is your business logic --> business logic
there is a few styles to your stylesheet
Docs
options
Param | Description | Type | Default value |
---|---|---|---|
auto | auto slideshow(milliseconds) | number | 0 |
startSlide | start index position | number | 0 |
speed | transitions speed(milliseconds) | number | 300 |
continuous | loop(infinite feel) | boolean | true |
direction | horizontal,vertical | horizontal | |
stopPropagation | boolean | - | |
disableScroll | stop touches on this container | boolean | - |
debounce | debounce for user slide | boolean | false |
framework | support rax framework | rax | - |
swiping | swiping percentage (0-1) | (res: number) => void | - |
callback | slider change | (index: number, element) => void | - |
transitionEnd | slider change (after callback ) | (index: number, element) => void | - |
Tips: 「debounce」 only work on user gesture operation, it not work at auto param or SwipeX.slide function
For example options:
debounce will not work at auto
mode, but it will work at user gesture operation
auto: 200 debounce: true
SwipeX.method()
Include:
SwipeX.prev()
slide to prev itemSwipeX.next()
slide to next itemSwipeX.getPos()
return current slide indexSwipeX.getNumSlides()
return total slide itemsSwipeX.slide(index: number, speed: number)
slide to index item with custom speed (speed: milliseconds)SwipeX.disableScrolling(disableScroll: boolean)
directly control scrolling (disableScroll: same as the config option )
Example:
windowmySwipeX =
contribute
clone
$ git clone https://github.com/zj1024/swipex.git
local run
install dependencies
npm install
start
npm run start # or you can run start:your-page npm run start:other
Tips:
-
swipe container use css: position: fixed window.resize will unexpected
-
width or height computed is slide item getBoundingClientRect(), if do not have slide item, it will find wrapper.