好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

PhotoSwipe

photoswipe 介绍

photoswipe 是专为移动触摸设备设计的相册/画廊, photoswipe 提供给 用户 一个 熟悉又直观的相册交互界面。

photoswipe 兼容大量的移动设备以及所有流行的JavaScript类库/开发框架. 既有基于jQuery的版本,也有不依赖jQuery的版本,还有兼容jQuery Mobile的版本。当然,All In One,全在源码示例包里。?

photoswipe 是 一个 自身独立的JavaScript库,可以很方便地集成进你的网站。针对移动浏览器(webkit)进行了大量的优化,当然,对于桌面浏览器,以及jQueryMobile,在源码包内也提供了相应的版本。

类库引用

<!-- photoswipe 之前先引用klass,如果需要提高加载速度,可以给 script 加上 defer 标记 / 属性 -->

<script type="text/JavaScript" src="klass.min.js"></script>

<!-- 重要 提示 ,如果不使用jQuery版本,在IE下面会出错,当然,使用jQuery版本,则需要引入jQuery-->

<script type="text/JavaScript" src="code. photoswipe -3.0.5.min.js"></script>

调用 代码

/* 添加 DOMContentLoaded 事件监听,类似于jQuery的 ready 函数 .

默 认方式 examples/01-default.html

无 缩略图 模式请查看.examples/09-exclusive-mode-no-thumbnails.html

*/

// photoswipe .attach 方法 接收3个参数(html元素集合,可选配置信息,可选多实例时string类型的ID)

document.addEventListener('DOMContentLoaded',function(){

//设置 photoswipe 绑定为 id为 gal lery的容器下的所有<a> 标签 .点击就会激活

// 此处的对象,就是 photoswipe 实例,可以使用相应的 方法 ,例如 show(0),hide()等.

var my photoswipe = Code. photoswipe .attach( window.document.querySelectorAll('# gal lery a'),{ enableMouseWheel: false,enableKeyboard: false } );

},false);如果使用 jQuery ,则 调用 代码 如下:

//jQuery 版,对应的js 文件 也需要变化

// 示例详见examples/02-jquery.html

$(document).ready(function(){

// 此处的对象,就是 photoswipe 实例,可以使用相应的 方法 ,hide()等.

var my photoswipe = $("# gal lery a"). photoswipe ({ enableMouseWheel: false,enableKeyboard: false });

});

HTML代码

<!-- ul li 之类是用于 显示 缩略图 的,也可以根据需要调整.<a>下面的<img> 元素,即为 缩略图 ,如果不需要,则src设置为空即可 -->

<ul id=" gal lery">

<li><a href="images/full/01.jpg"><img src="images/thumb/01.jpg" alt="Image 01" /></a></li>

<li><a href="images/full/02.jpg"><img src="images/thumb/02.jpg" alt="Image 02" /></a></li>

<li><a href="images/full/03.jpg"><img src="images/thumb/03.jpg" alt="Image 03" /></a></li>

<li><a href="images/full/04.jpg"><img src="images/thumb/04.jpg" alt="Image 04" /></a></li>

<li><a href="images/full/05.jpg"><img src="images/thumb/05.jpg" alt="Image 05" /></a></li>

<li><a href="images/full/06.jpg"><img src="images/thumb/06.jpg" alt="Image 06" /></a></li>

</ul>

参数说明?

allowUserZoom: 允许 用户 双击放大/移动方式查看 图片 . 默 认值 = true

autoStartSlideshow: 当 photoswipe 激活后, 自动 播放 幻灯片 . 默 认值 = false

allowRotationOnUserZoom: 只有 iOS 支持 - 允许 用户 在缩放/平移模式下 用手势旋转图像. 默 认值 = false

backButtonHideEnabled: 按返回键隐藏相册 幻灯片 . 主要是 Android 和 Black Berry 使用. 支持 BB6,Android v2.1,iOS 4 以及更新版本. 默 认值 = true

captionAndToolb ara utoHideDelay: 标题 栏和工具栏 自动 隐藏的延迟时间. 默 认值为 = 5000(毫秒). 如果设为 0 则不会 自动 隐藏(tap/单击切换显隐)

captionAndToolbarFlipPosition: 标题 栏和工具栏切换位置(让 caption 显示 在 底部 而 toolbar 显示 在顶部). 默 认值 = false

captionAndToolbarHide: 隐藏 标题 栏和工具栏. 默 认值 = false

captionAndToolbarOpacity: 标题 栏和工具栏 的透明度(0-1). 默 认值 = 0.8

captionAndToolbarShowEmptyCaptions: 即使当前 图片 的 标题 是空,也 显示 标题 栏. 默 认值 = true

cacheMode: 缓存模式,Code. photoswipe .Cache.Mode. nor mal ( 默 认,正常) 或者 Code. photoswipe .Cache.Mode.aggressive(激进,积极). 决定 photoswipe 如何管理 图片 缓存 cache.

Aggressive 模式将会积极地地设置非 "当前,上一张,下一张"的 图片 为空的类型. 对于老版本iOS 浏览器下的大 图片 内存溢出将会很有用. 大多数情况下, nor mal模式就可以了。

doubleTapSpeed: 双击的最大间隔. 默 认值 = 300(毫秒)

doubleTapZoomLevel: 当 用户 双击的时候,放大的倍数, 默 认的 "zoom-in"(拉近) 级别. 默 认值 = 2.5

enableDrag: 允许拖动上一张/下一张 图片 到当前界面. 默 认值 = true

enableKeyboard: 允许 键盘 操作(左右箭头切换,Esc 退出 ,Enter 自动 播放,空格键 显/隐 标题 栏/ 退出 ). 默 认 = true

enableMouseWheel: 允许鼠标滚轮操作. 默 认 = true

fadeInSpeed: 淡入 效果 元素的速度(持续时间),毫秒. 默 认 = 250

fadeOutSpeed: 淡出 效果 元素的速度(持续时间),毫秒. 默 认 = 250

imageScaleMethod: 图片 缩放 方法 (模式). 可选值: "fit","fitNoUpscale" 和 "zoom". 模式"fit" 保证图像适应屏幕. "fitNoUpscale" 和 "fit"类似但是不会放大 图片 . "zoom"将 图片 全屏,但有可能 图片 缩放不是等比例的. 默 认 = "fit"

invertMouseWheel: 反转鼠标滚轮。 默 认情况下,鼠标向下滚动将切换到下一张,向上切换到上一张 . 默 认 = false

jQueryMobile: 指示 photoswipe 是否集成进了 jQuery Mobile 项目. 默 认情况下, photoswipe will try and work this out for you

jQueryMobileDialogHash: jQuery Mobile的window,dialog 页面 所使用的hash 标签 。 默 认值 = "&ui-state=dialog"

loop: 相册是否 自动 循环. 默 认 = true

margin: 两张图之 间的 间隔,单位是像素. 默 认 = 20

maxUserZoom: 最大放大倍数. 默 认 = 5.0 (设置为0将被忽略)

minUserZoom: 图像最小的缩小倍数. 默 认 = 0.5 (设置为0将会忽略)

mouseWheelSpeed: 响应鼠标滚轮的灵敏度. 默 认 = 500(毫秒)

nextPrev IoU sSlideSpeed: 当点击上一张,下一张按钮后,延迟多少毫秒执行切换. 默 认 = 0 (立即切换)

preventHide: 阻止 用户 关闭 photoswipe . 同时也会隐藏 工具栏上的"close" 关闭 按钮. 在独享的 页面 使用 (示例是源码中的 examples/08-exclusive-mode.html). 默 认 = false

preventSlideshow: 阻止 自动 播放模式. 同时也会隐藏工具栏里的播放按钮. 默 认 = false

slideshowDelay: 自动 播放模式下,多长时间播放下一张. Default = 3000(毫秒)

slideSpeed: 图片 滑进视图的时间. 默 认 = 250(毫秒)

swipeThreshold: 手指滑动多少像素才触发 一个 swipe 手势事件. 默 认 = 50

swipeTimeThreshold: 定义触发swipe(滑动)手势的最大毫秒数,太慢了则不会触发滑动,只会拖动当前照片的位置. 默 认 = 250

slideTimingFunction: 滑动时的 Easing function . 默 认 = "ease-out"

zIndex: 初始的zIndex值. 默 认 = 1000

ena bleu IWebViewRepositionTimeout: 检查设备的方向是否改变。 默 认 = false

uiWebViewResetPositionDelay: 定时检查设备的方向是否改变的时间 默 认 = 500(毫秒)

preventDefaultTouchEvents: 阻止 默 认的touch事件,比如 页面 滚动。 默 认 = true

target: 必须是 一个 合法的DOM元素(如div)。 默 认是window(全 页面 )。而如果是某个低级别的DOM,则在DOM内 显示 ,可能非全屏。

网站地址 : http://photoswipe.com

GitHub: https://github.com/dimsemenov/PhotoSwipe

网站描述: 为移动触摸设备设计的相册/画廊

PhotoSwipe官方网站

官方网站: http://photoswipe.com

如果觉得 网站内容还不错,欢迎将 网站 推荐给程序员好友。

查看更多关于PhotoSwipe的详细内容...

  阅读:47次

上一篇

下一篇

第1节:react-dates    第2节:Pica    第3节:Pikaday    第4节:scalable.js    第5节:date-fns    第6节:WOW.js    第7节:ngDialog    第8节:lazysizes.js    第9节:Flickity    第10节:react-swipeable-views    第11节:ueditor    第12节:screenfull.js    第13节:Darkmode.js    第14节:react-native-masonry    第15节:PhotoClip.js    第16节:vue-core-image-upload    第17节:PixelMatch    第18节:number-flip    第19节:hashids.js    第20节:vue-awesome-swiper    第21节:layzr.js    第22节:Kalendae    第23节:slideout.js    第24节:Layx    第25节:tinydate    第26节:soundmanager2.js    第27节:flv.js    第28节:vue2-animate    第29节:impress.js    第30节:angular-calendar    第31节:jsPDF    第32节:ReLaXed    第33节:xterm.js    第34节:Fawn    第35节:Glider.js    第36节:KindEditor    第37节:Pressure.js    第38节:Kiwi    第39节:FastDom    第40节:pnotify    第41节:vue-tour    第42节:Scene.js    第43节:galleria    第44节:smoothscroll.js    第45节:bubbly-bg.js    第46节:countUp.js    第47节:MediaElement.js    第48节:popper.js    第49节:Imager.js    第50节:quill.js    第51节:Split.js    第52节:vue-baidu-map    第53节:push.js    第54节:circles    第55节:SweetAlert2    第56节:ng2-toasty    第57节:gitmoji    第58节:sockette    第59节:Clusterize.js    第60节:Botpress    第61节:Awaity.js    第62节:zoom.js    第63节:Masonry    第64节:BetterScroll    第65节:atrament.js    第66节:vanilla-tilt.js    第67节:bignumber.js    第68节:uppy    第69节:dragula.js    第70节:placeholder.js    第71节:supercluster    第72节:angular-async-local-storage    第73节:PreloadJS    第74节:jwplayer    第75节:typeahead.js    第76节:tinyColor.js    第77节:tiptap    第78节:Bespoke.js    第79节:rrule.js    第80节:iScroll.js    第81节:maptalks.js    第82节:siema    第83节:Vidage.js    第84节:particles.js    第85节:SpreadJS    第86节:canvi.js    第87节:vue-virtual-scroller    第88节:Keypress.js    第89节:ng-file-upload    第90节:handsontable    第91节:remotestorage.js    第92节:vue-cute-timeline    第93节:pace.js    第94节:OwO    第95节:FrenchKiss.js    第96节:store.js    第97节:DPlayer    第98节:x2js    第99节:math-as-code    第100节:laverna    第101节:fine-uploader    第102节:Mermrender    第103节:proposal-bigint    第104节:packery    第105节:instantclick    第106节:simple-uploader.js    第107节:js-cookie    第108节:Draggable    第109节:CurrencyFormatter.js    第110节:reframe.js    第111节:hopscotch.js    第112节:mailgo.js    第113节:proj4js    第114节:AlloyFinger    第115节:delighters.js    第116节:UMeditor    第117节:lovefield    第118节:react-datasheet    第119节:BotUI    第120节:jsAnim    第121节:Video.js    第122节:highlight    第123节:polacode    第124节:Croppie.js    第125节:microlight    第126节:Odometer.js    第127节:Fuse.js    第128节:Moment Timezone    第129节:Drop.js    第130节:Headroom.js    第131节:tui.image-editor    第132节:Choices.js    第133节:lory    第134节:x-editable    第135节:vue-uploader    第136节:Algolia Places    第137节:TheaterJS    第138节:minigrid    第139节:ParticleEffectsButtons    第140节:anyupload    第141节:glide.js    第142节:Respond.js    第143节:vue-quill-editor    第144节:zeroclipboard    第145节:Keyboard    第146节:weapp.socket.io    第147节:qrcode.js    第148节:pjax    第149节:spy-debugger    第150节:nprogress    第151节:co.js    第152节:ajv    第153节:vue-grid-layout    第154节:reattempt    第155节:rapid.js    第156节:Proton    第157节:AgentMaps    第158节:Numeral.js    第159节:layDate    第160节:BigPicture.js    第161节:WebSlides    第162节:react-timeline-gantt    第163节:Stream.js    第164节:typed.js    第165节:accessible-html5-video-player    第166节:HTMLHint    第167节:AlloyCrop    第168节:collect.js    第169节:nanobar.js    第170节:logline    第171节:moment-timezone    第172节:Nimiq    第173节:list.js    第174节:cropper.js    第175节:vue-particles    第176节:Draggin.js    第177节:got    第178节:heatmap.js    第179节:react-color    第180节:forgJs    第181节:vue-good-table    第182节:TheoremJS    第183节:When.js    第184节:outils    第185节:SoundJS    第186节:Rythm.js    第187节:ripplet.js    第188节:cleave.js    第189节:ShuffleText    第190节:wangEditor    第191节:angularjs-slider    第192节:draft-js    第193节:vue-filepond    第194节:zooming.js    第195节:chroma.js    第196节:vue-tap    第197节:vue-snotify    第198节:sweetalert    第199节:mescroll.js    第200节:blurify.js    第201节:uos    第202节:Scraperjs    第203节:bricks.js    第204节:Please.js    第205节:a11y-dialog    第206节:Mercury Editor    第207节:GLightbox    第208节:superstruct    第209节:jeelizFaceFilter    第210节:Shepherd.js    第211节:monaco-editor    第212节:ImmortalDB    第213节:clipboard.js    第214节:Magenta.js    第215节:jsmpeg    第216节:notice.js    第217节:Ladda    第218节:slugify    第219节:Awesomplete    第220节:tinytime    第221节:translater.js    第222节:share.js    第223节:debug.js    第224节:eagle.js    第225节:Avgrund    第226节:src2png    第227节:vue-content-loader    第228节:tingle.js    第229节:DecorativeLetterAnimations    第230节:rangeslider.js    第231节:WebODM    第232节:cropbox.js    第233节:superplaceholder.js    第234节:shine.js    第235节:tastySelect    第236节:Fathom    第237节:FileAPI    第238节:Fitty    第239节:LABjs    第240节:vue-croppa    第241节:progress.js    第242节:prepack    第243节:wavesurfer.js    第244节:xo    第245节:Moment.js    第246节:lightgallery.js    第247节:Colorify.js    第248节:rellax    第249节:vue-js-popover    第250节:Liike.js    第251节:pieces.js    第252节:FastScan    第253节:ConditionerJS    第254节:qrious    第255节:Switch.js    第256节:widget    第257节:popbox.js    第258节:jsconsole    第259节:SVG-edit    第260节:Squire    第261节:JSZip    第262节:color-thief    第263节:Voca.js    第264节:Seen.js    第265节:layer    第266节:yall.js    第267节:imgResize    第268节:TremulaJS    第269节:vega    第270节:reveal.js    第271节:Keymaster.js    第272节:Barba.js    第273节:lozad.js    第274节:Pushbar.js    第275节:nodeppt    第276节:Luxon    第277节:Evaporate.js    第278节:humane.js    第279节:Watch.js    第280节:clamp.js    第281节:store    第282节:notie.js    第283节:regexgen    第284节:Driver.js    第285节:Feature.js    第286节:math.js    第287节:turbolinks    第288节:vue-tinder    第289节:Kibo    第290节:React LoadCon    第291节:cartodb    第292节:vue-i18n    第293节:jStorage    第294节:Ocrad.js    第295节:autosize    第296节:Animatic.js    第297节:vue-upload-component    第298节:fbt    第299节:Tone.js    第300节:dsa.js    第301节:cms.js    第302节:rainbow    第303节:trix    第304节:Day.js    第305节:zepto.fullpage    第306节:zingtouch    第307节:pdfkit    第308节:ZangoDB    第309节:join-monster    第310节:mailcheck.js    第311节:plyr    第312节:infinite-scroll    第313节:micron.js    第314节:emergence.js    第315节:miment    第316节:Vuescroll.js    第317节:lib-flexible    第318节:randomColor.js    第319节:nanoid    第320节:artipub    第321节:JavaScript-Load-Image    第322节:pdfmake.js    第323节:Awesome-qr.js    第324节:vee-validate    第325节:timeago.js    第326节:RegexHub    第327节:angular-file-upload    第328节:mock.js    第329节:Editor.js    第330节:validate.js    第331节:rcpress    第332节:hammer.js    第333节:NodePlayer.js    第334节:Amplitude.js    第335节:currency.js    第336节:iziToast    第337节:promise.js    第338节:PDF.js    第339节:bootlint.js    第340节:Notyf    第341节:canvas-nest.js    第342节:Canvas Gauges    第343节:ElasticProgress    第344节:qart.js    第345节:vue-lazyload    第346节:resumable.js    第347节:viz.js    第348节:marktext    第349节:onfire.js    第350节:in-view    第351节:You-Dont-Need-Momentjs    第352节:Slang    第353节:APlayer    第354节:localResizeIMG    第355节:history.js    第356节:intro.js    第357节:baffle.js    第358节:colorable    第359节:any-rule    第360节:basicScroll    第361节:iTyped.js    第362节:Summernote    第363节:BLazy.js    第364节:prism.js    第365节:Exif.js    第366节:PouchDB    第367节:Datomish    第368节:postcss-pxtorem    第369节:gmaps.js    第370节:alex    第371节:decimal.js    第372节:Simple-Ajax-Uploader    第373节:zxcvbn    第374节:webuploader    第375节:Jwerty    第376节:indigo-player    第377节:geo-maps    第378节:dancer.js    第379节:oraclejet    第380节:notification-logger    第381节:ScrollBooster    第382节:naivechain    第383节:baguetteBox.js    第384节:v-distpicker    第385节:Mousetrap    第386节:Simditor    第387节:Dropzone.js    第388节:box-js    第389节:ACE Editor    第390节:sentinel.js    第391节:tracking.js    第392节:Shave    第393节:smartcrop.js    第394节:wysihtml5    第395节:select2    第396节:Chance.js    第397节:bounce.js    第398节:ScrollingLettersAnimation    第399节:Filepond    第400节:stackedit    第401节:AR.js    第402节:libRmath.js    第403节:MProgress.js    第404节:howler.js    第405节:Ganja.js    第406节:labella.js    第407节:Parser    第408节:Waves    第409节:flatpickr    第410节:validator.js    第411节:saveSvgAsPng.js    第412节:responsive-nav.js    第413节:Vue.Draggable    第414节:Smartour    第415节:progressbar.js    第416节:vue-notification    第417节:Popcorn.js    第418节:Micromodal.js    第419节:ExpandingGridItemAnimation    第420节:Sortable.js    第421节:Echo.js    第422节:Cerebral    第423节:strman    第424节:PhotoSwipe    第425节:spop.js    第426节:CommentCoreLibrary    第427节:d8    第428节:Editor.md    第429节:proppy.js    第430节:UglifyJS    第431节:Tippy.js    第432节:Cashify    第433节:tui.editor    第434节:rome    第435节:Vue2Editor    第436节:Spacetime    第437节:Snap.js    第438节:tui.calendar    第439节:Timesheet.js    第440节:PDFObject