项目作者: petoem

项目描述 :
:circus_tent: ~30KB (gziped) Javascript lightbox gallery
高级语言: JavaScript
项目地址: git://github.com/petoem/circus-gallery.git
创建时间: 2018-11-14T11:43:44Z
项目社区:https://github.com/petoem/circus-gallery

开源协议:MIT License

下载




Circus Gallery


~30KB (gziped) Javascript lightbox gallery






Uses Preact, react-images for lightbox, parcel for bundling and a Gallery component from a previous project of mine.

circus-gallery demo image

Installation

Embed the dist/circus.js file into your document.

  1. <script src="https://cdn.jsdelivr.net/gh/petoem/circus-gallery@1/dist/circus.js"></script>

Usage

Add a div to your HTML document. (This div element will hold the gallery.)

  1. <div id="gallery"></div>

Finally you need to create the gallery and supply it a list of images.

  1. circusGallery.create(document.getElementById('gallery'), [
  2. {
  3. title: "Random example",
  4. images: [
  5. {
  6. src: "https://example.com/image_1.jpg",
  7. caption: "Random 1",
  8. alt:"1"
  9. },
  10. {
  11. src: "https://example.com/image_2.jpg",
  12. caption: "Random 2",
  13. alt:"2"
  14. },
  15. ...
  16. ]
  17. },
  18. {
  19. title: "Some more example images",
  20. images: [
  21. {
  22. src: "https://example.com/image_3.jpg",
  23. caption: "More 1",
  24. alt:"1"
  25. },
  26. ...
  27. ]
  28. },
  29. ...
  30. ]);

Bookmarking images

window.location.hash is used to make an open image bookmarkable. A base64 encoded version of the image src is used as a hash value.

Contributing

  1. Fork it!
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am ‘Add some feature’)
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

  • petoem Michael Petö - creator, maintainer

License

Code licensed under the MIT License

Circus Tent image from Twitter Emoji (Twemoji)

Example photos from Unsplash Source