0.0.30 • Published 5 years ago
@jiubao/gallery v0.0.30
gallery
- 18k before gzip
Demo
Gestures
- tap to open gallery
- swipe to next or previous image
- vertical pan to close
- double tap to zoom in or zoom out
- pinch to zoom in
- pan to drag
- pinch to zoom out or close
Install
$ npm install --save @jiubao/gallery
$ yarn add @jiubao/gallery
// using ES6 modules
import gallery from '@jiubao/gallery/dist/gallery.es'
The UMD build is available on unpkg:
<script src="https://unpkg.com/@jiubao/gallery"></script>
Usage
<div class="box">
<img src="./imgs/1.jpg" data-gallery-item alt="">
<img src="./imgs/2.jpg" data-gallery-item alt="">
<img src="./imgs/3.jpg" data-gallery-item alt="">
<img src="./imgs/4.jpg" data-gallery-item alt="">
<img src="./imgs/5.jpg" data-gallery-item alt="">
</div>
import gallery from '@jiubao/gallery/dist/gallery.es'
gallery()
Options
Attribute | Description | Type | Default | Values |
---|---|---|---|---|
selector | gallery item flag, start with data | string | data-gallery-item |
Methods
Name | Description | Parameters | Return |
---|---|---|---|
destroy | destroy gallery | ||
show | show gallery | img | |
hide | hide gallery | ||
on | add a event handler | event name, event handler | unregister function |
off | remove handler | event name, event handler |
Events
Name | Description | trigger | Parameters |
---|---|---|---|
show | show gallery | - | img |
hide | hide gallery | - | img |
single | single tap | - | points, target, phase, eventArg |
double | double tap | - | points, target, phase, eventArg |
scroll | vertical scroll | - | points, target, phase, eventArg |
scrollend | vertical scroll end | - | points, target, phase, eventArg |
pinch | pinch move | - | points, target, phase, eventArg |
pinchend | pinch end | - | points, target, phase, eventArg |
pan | pan move | - | points, target, phase, eventArg |
panend | pan end | - | points, target, phase, eventArg |
postpan | post pan end | - | |
start | touch start | - | points, target, phase, eventArg |
move | touch move | - | points, target, phase, eventArg |
end | touch end | - | points, target, phase, eventArg |
swipestart | swipe start | - | index |
swipe | swipe move | - | index |
swipeend | swipe end | - | index |
Event handler arguments
Name | Description |
---|---|
points | start, last, current |
target | target img |
phase | gesture phase |
eventArg | touch event argument |
Todos
add apiadd readme- two slide bug
- need figure out a one step close solution
- quick pan -> move back
- pan trigger swipe
- limit zoom in / out level
support wechatsupport alipaypan right () -> postpan -> tap (out) -> pan left -> post pan: a little slowpan right () -> postpan -> tap (out) -> pan left -> post pan: super slowdestroy swiper (events, elements)manage eventsmanage destroysupport landscapeswitch to landscapemulti events on documentdestroy & releasezoom out and zoom in: should not closetransparent issuedouble and quickly swipe issuetriple tappinch trigger postpanpan does not stop post pan animationpan out of boundary stop issuephone & scroll: not in middle issueafter scroll pinch breakpan accelerate & momentumremove swiper's !importantgap between slidesdisable swiper when gesturedisable gesture when swiperios / safari supportuse js to simulate animationpinch & pan: pending issuepinch -> pan: twitter- quick pinch: strange behaviors (bounce back, move far away ...)
- recover postpinch (current use postpan)
- do we need post pinch?
- window.resize: add a temp black bk, remove it after init
- manage zoom
- manage shape
- manage animations
- startSwiper | stopSwiper
- gesture.on: support on an object
- out of screen close animation
- desktop
0.0.30
5 years ago
0.0.29
5 years ago
0.0.28
5 years ago
0.0.27
5 years ago
0.0.26
5 years ago
0.0.25
5 years ago
0.0.24
5 years ago
0.0.23
5 years ago
0.0.22
5 years ago
0.0.21
5 years ago
0.0.20
5 years ago
0.0.19
5 years ago
0.0.18
5 years ago
0.0.17
5 years ago
0.0.16
5 years ago
0.0.15
5 years ago
0.0.14
5 years ago
0.0.13
5 years ago
0.0.12
5 years ago
0.0.11
5 years ago
0.0.10
5 years ago
0.0.9
5 years ago
0.0.8
5 years ago
0.0.7
5 years ago
0.0.6
5 years ago
0.0.5
5 years ago
0.0.4
5 years ago
0.0.3
5 years ago
0.0.2
6 years ago