项目作者: bravecow

项目描述 :
native image gallery in ~100 lines of code
高级语言: JavaScript
项目地址: git://github.com/bravecow/native-gallery.git
创建时间: 2020-05-06T11:10:52Z
项目社区:https://github.com/bravecow/native-gallery

开源协议:

下载


native-gallery

native image gallery in ~ 100 lines of code.

How it works

Usage

npm package: native-gallery

  1. import NativeGallery from 'native-gallery';
  2. const target = document.querySelector('native-gallery');
  3. const gallery = new NativeGallery(target);
  4. // navigation:
  5. gallery.prev();
  6. gallery.next();
  7. // events are fired on target DOM node:
  8. target.addEventListener('change', (event) => {
  9. console.log(`${event.detail.current} / ${event.detail.count}`);
  10. });
  1. <!-- include CSS file -->
  2. <link href="styles.css" rel="stylesheet">
  3. <!-- gallery markup -->
  4. <native-gallery>
  5. <img src="1.jpg" width="1600" height="900" alt="">
  6. <img src="2.jpg" width="675" height="900" alt="" loading="lazy">
  7. <img src="3.jpg" width="1600" height="900" alt="" loading="lazy">
  8. <img src="4.jpg" width="1600" height="900" alt="" loading="lazy">
  9. <img src="5.jpg" width="1600" height="900" alt="" loading="lazy">
  10. </native-gallery>