1 Star 0 Fork 0

Edsuns / image-swiper

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

Image Swiper

Version

English | 简体中文

特性

查看示例

  • 连贯顺滑的进入退出过渡动画
  • 图片热加载
  • 多图片组
  • 手势控制(上下左右滑、双击或双指缩合)

快速上手

安装依赖:

npm install image-swiper

用法(TypeScript 和 Vue 3):

<script setup lang="ts">
import { ref } from 'vue'
import { ImageViewer, Open } from 'image-swiper'

const imagesOne = ref([
  'https://swiperjs.com/demos/images/nature-1.jpg',
  'https://swiperjs.com/demos/images/nature-2.jpg',
  'https://swiperjs.com/demos/images/nature-3.jpg',
])
const imagesTwo = ref([
  'https://swiperjs.com/demos/images/nature-4.jpg',
  'https://swiperjs.com/demos/images/nature-5.jpg',
  'https://swiperjs.com/demos/images/nature-6.jpg',
])
// 1. 定义一个类型为 `Open` 的 `ref`.
const open = ref<Open>({ el: null })
// 2. 定义一个方法用来传递图片元素给 image-swiper.
const openImg = (ev: Event) => open.value.el = ev.target as HTMLElement
</script>

<template>
  <!-- 3. 添加 `image-viewer` 组件并绑定 `open` 变量. -->
  <image-viewer :open="open" />
  <h3>Group 1</h3>
  <!-- 4. 给所有的 `img` 标签的共同父标签添加属性 `gallery`. -->
  <div gallery>
    <!-- [注意] 要求使用 `img` 标签显示图片. -->
    <!-- [热加载支持] -->
    <!-- 可以使用 `src` 属性提供缩略图的 url 并使用 `data-src` 属性提供原图的 url. -->
    <!-- 以下是一个例子: -->
    <!-- <img src="path/to/thumbnail" data-src="path/to/full-size-image" /> -->

    <!-- 5. 给所有的 `img` 标签绑定 `click` 事件. -->
    <img v-for="url in imagesOne" :key="url" :src="url" width="200" @click="openImg" />
  </div>
  <h3>Group 2</h3>
  <!-- [可选] 想要有多个图片组, 添加另一个 `gallery` 即可. -->
  <div gallery>
    <img v-for="url in imagesTwo" :key="url" :src="url" width="200" @click="openImg" />
  </div>
</template>

<style>
div[gallery] {
  min-height: 200px;
}
</style>

空文件

简介

An image viewer with smooth enter and exit transitions, supports lazy-load and gesture control. 展开 收起
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/Edsuns/image-swiper.git
git@gitee.com:Edsuns/image-swiper.git
Edsuns
image-swiper
image-swiper
main

搜索帮助