# Viewer.js
[![Build Status](https://img.shields.io/travis/fengyuanchen/viewerjs.svg)](https://travis-ci.org/fengyuanchen/viewerjs) [![Downloads](https://img.shields.io/npm/dm/viewerjs.svg)](https://www.npmjs.com/package/viewerjs) [![Version](https://img.shields.io/npm/v/viewerjs.svg)](https://www.npmjs.com/package/viewerjs)
> JavaScript image viewer.
- [Website](https://fengyuanchen.github.io/viewerjs)
- [jquery-viewer](https://github.com/fengyuanchen/jquery-viewer) - A jQuery plugin wrapper for Viewer.js.
## Table of contents
- [Features](#features)
- [Main](#main)
- [Getting started](#getting-started)
- [Keyboard support](#keyboard-support)
- [Options](#options)
- [Methods](#methods)
- [Events](#events)
- [No conflict](#no-conflict)
- [Browser support](#browser-support)
- [Contributing](#contributing)
- [Versioning](#versioning)
- [License](#license)
## Features
- Supports 42 [options](#options)
- Supports 23 [methods](#methods)
- Supports 9 [events](#events)
- Supports modal and inline modes
- Supports touch
- Supports move
- Supports zoom
- Supports rotation
- Supports scale (flip)
- Supports keyboard
- Cross-browser support
## Main
```text
dist/
├── viewer.css
├── viewer.min.css (compressed)
├── viewer.js (UMD)
├── viewer.min.js (UMD, compressed)
├── viewer.common.js (CommonJS, default)
└── viewer.esm.js (ES Module)
```
## Getting started
### Installation
```shell
npm install viewerjs
```
In browser:
```html
<link href="/path/to/viewer.css" rel="stylesheet">
<script src="/path/to/viewer.js"></script>
```
The [cdnjs](https://github.com/cdnjs/cdnjs) provides CDN support for Viewer.js's CSS and JavaScript. You can find the links [here](https://cdnjs.com/libraries/viewerjs).
### Usage
#### Syntax
```js
new Viewer(element[, options])
```
- **element**
- Type: `HTMLElement`
- The target image or container of images for viewing.
- **options** (optional)
- Type: `Object`
- The options for viewing. Check out the available [options](#options).
#### Example
```html
<!-- a block container is required -->
<div>
<img id="image" src="picture.jpg" alt="Picture">
</div>
<div>
<ul id="images">
<li><img src="picture-1.jpg" alt="Picture 1"></li>
<li><img src="picture-2.jpg" alt="Picture 2"></li>
<li><img src="picture-3.jpg" alt="Picture 3"></li>
</ul>
</div>
```
```js
// You should import the CSS file.
// import 'viewerjs/dist/viewer.css';
import Viewer from 'viewerjs';
// View an image
const viewer = new Viewer(document.getElementById('image'), {
inline: true,
viewed() {
viewer.zoomTo(1);
},
});
// Then, show the image by click it, or call `viewer.show()`.
// View a list of images
const gallery = new Viewer(document.getElementById('images'));
// Then, show one image by click it, or call `gallery.show()`.
```
## Keyboard support
> Only available in modal mode.
- `Esc`: Exit full screen or close the viewer or exit modal mode or stop play.
- `Space`: Stop play.
- `←`: View the previous image.
- `→`: View the next image.
- `↑`: Zoom in the image.
- `↓`: Zoom out the image.
- `Ctrl + 0`: Zoom out to initial size.
- `Ctrl + 1`: Zoom in to natural size.
[⬆ back to top](#table-of-contents)
## Options
You may set viewer options with `new Viewer(image, options)`.
If you want to change the global default options, You may use `Viewer.setDefaults(options)`.
### backdrop
- Type: `Boolean` or `String`
- Default: `true`
Enable a modal backdrop, specify `static` for a backdrop which doesn't close the modal on click.
### button
- Type: `Boolean`
- Default: `true`
Show the button on the top-right of the viewer.
### navbar
- Type: `Boolean` or `Number`
- Default: `true`
- Options:
- `0` or `false`: hide the navbar
- `1` or `true`: show the navbar
- `2`: show the navbar only when the screen width is greater than 768 pixels
- `3`: show the navbar only when the screen width is greater than 992 pixels
- `4`: show the navbar only when the screen width is greater than 1200 pixels
Specify the visibility of the navbar.
### title
- Type: `Boolean` or `Number` or `Function` or `Array`
- Default: `true`
- Options:
- `0` or `false`: hide the title
- `1` or `true` or `Function` or `Array`: show the title
- `2`: show the title only when the screen width is greater than 768 pixels
- `3`: show the title only when the screen width is greater than 992 pixels
- `4`: show the title only when the screen width is greater than 1200 pixels
- `Function`: customize the title content
- `[Number, Function]`: the first element indicate the visibility, the second element customize the title content
Specify the visibility and the content of the title.
> The name comes from the `alt` attribute of an image element or the image name parsed from URL.
For example, `title: 4` equals to:
```js
new Viewer(image, {
title: [4, (image, imageData) => `${image.alt} (${imageData.naturalWidth} × ${imageData.naturalHeight})`]
});
```
### toolbar
- Type: `Boolean` or `Number` or `Object`
- Default: `true`
- Options:
- `0` or `false`: hide the toolbar.
- `1` or `true`: show the toolbar.
- `2`: show the toolbar only when the screen width is greater than 768 pixels.
- `3`: show the toolbar only when the screen width is greater than 992 pixels.
- `4`: show the toolbar only when the screen width is greater than 1200 pixels.
- `{ key: Boolean | Number }`: show or hide the toolbar.
- `{ key: String }`: customize the size of the button.
- `{ key: Function }`: customize the click handler of the button.
- `{ key: { show: Boolean | Number, size: String, click: Function }`: customize each property of the button.
- Available keys: "zoomIn", "zoomOut", "oneToOne", "reset", "prev", "play", "next", "rotateLeft", "rotateRight", "flipHorizontal" and "flipVertical".
- Available sizes: "small", "medium" (default) and "large".
Specify the visibility and layout of the toolbar its buttons.
For example, `toolbar: 4` equals to:
```js
new Viewer(image, {
toolbar: {
zoomIn: 4,
zoomOut: 4,
oneToOne: 4,
reset: 4,
prev: 4,
play: {
show: 4,
size: 'large',
},
next: 4,
rotateLeft: 4,
rotateRight: 4,
flipHorizontal: 4,
flipVertical: 4,
},
});
```
### className
- Type: `String`
- Default: `''`
Custom class name(s) to add to the viewer's root element.
### container
- Type: `Element` or `String`
- Default: `'body'`
- An element or a valid selector for [Document.querySelector](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector)
The container to put the viewer in modal mode.
> Only available when the `inline` option is set to `false`.
### filter
- Type: `Function`
- Default: `null`
Filter the images for viewing (should return `true` if the image is viewable).
For example:
```js
new Viewer(image, {
filter(image) {
return image.complete;
},
});
```
### fullscreen
- Type: `Boolean`
- Default: `true`
Enable to request full screen when play.
> Requires the browser supports [Full Screen API](https://caniuse.com/fullscreen).
### initialViewIndex
- Type: `Number`
- Default: `0`
Define the initial index of image for viewing.
> Also used as the default parameter value of the `view` method.
### inline
- Type: `Boolean`
- Default: `false`
Enable inline mode.
### interval
- Type: `Number`
- Default: `5000`
The amount of time to delay between automatically cycling an image when playing.
### keyboard
- Type: `Boolean`
- Default: `true`
Enable keyboard support.
### loading
- Type: `Boolean`
- Default: `true`
Indicate if show a loading spinner when load image or not.
### loop
- Type: `Boolean`
- Default: `true`
Indicate if enable loop viewing or not.
> If the current image is the last one, then the next one to view is the first one, and vice versa.
### minWidth
- Type: `Number`
- Default: 200
Define the minimum width of the viewer.
> Only available in inline
没有合适的资源?快使用搜索试试~ 我知道了~
ForumWebsite-master.zip
共2000个文件
svg:1261个
js:707个
png:651个
0 下载量 156 浏览量
2023-01-31
19:41:22
上传
评论
收藏 24.09MB ZIP 举报
温馨提示
本项目为使用SpringBoot + MyBatis + Caffeine + Redis + MySql + Kafka等技术实现一个功能完善的论坛网站。本项目包括论坛模块、云盘模块、注册登录模块、个性化推荐模块、主页热门标签显示模块等。
资源推荐
资源详情
资源评论
收起资源包目录
ForumWebsite-master.zip (2000个子文件)
mejs-controls.ai 1.58MB
VideoMediaElement.as 18KB
HlsMediaElement.as 14KB
DashContext.as 14KB
FragmentLoader.as 13KB
DashMediaElement.as 12KB
DashNetStream.as 11KB
SegmentTemplate.as 11KB
WAVDecoder.as 9KB
AudioMediaElement.as 8KB
OggMediaElement.as 7KB
ManifestHandler.as 6KB
SegmentList.as 6KB
OggVorbisDecoder.as 6KB
SegmentTimeline.as 6KB
MediaSegmentHandler.as 5KB
SegmentRange.as 5KB
TrackFragmentRunBox.as 5KB
Manifest.as 4KB
Muxer.as 4KB
SampleEntry.as 4KB
DashNetLoader.as 4KB
DataSegmentLoader.as 4KB
IndexSegmentHandler.as 4KB
InitializationSegmentHandler.as 3KB
NalUnit.as 3KB
Console.as 3KB
ManifestLoader.as 2KB
SegmentIndexFactory.as 2KB
BandwidthMonitor.as 2KB
Representation.as 2KB
AudioDecoder.as 2KB
VideoSegmentHandler.as 2KB
AdaptiveSegmentDispatcher.as 2KB
TrackFragmentHeaderBox.as 2KB
MediaBox.as 2KB
SegmentHandler.as 2KB
TrackFragmentBox.as 2KB
MediaHeaderBox.as 2KB
MovieBox.as 1KB
AudioInfo.as 1KB
Box.as 1KB
SmoothMonitor.as 1KB
TrackBox.as 1KB
AudioSegmentHandler.as 1KB
SampleDescriptionBox.as 1KB
MovieFragmentBox.as 1KB
FullBox.as 1KB
FLVTag.as 1KB
InitializationVideoSegmentHandler.as 1KB
TrackHeaderBox.as 1KB
MediaDataSegment.as 1KB
SegmentEvent.as 1KB
InitializationAudioSegmentHandler.as 1KB
MovieExtendsBox.as 1KB
StreamEvent.as 1KB
DashTimeTrait.as 1KB
DashPlugin.as 1KB
TrackExtendsBox.as 1KB
SampleTableBox.as 1KB
MediaInformationBox.as 1KB
DataSegment.as 983B
FragmentEvent.as 978B
SegmentIndex.as 978B
SegmentLoader.as 947B
ReflexiveSegmentLoader.as 934B
ManifestEvent.as 921B
DashSeekTrait.as 864B
HandlerReferenceBox.as 842B
NullSegmentLoader.as 795B
Segment.as 739B
ReflexiveSegment.as 676B
Bytes.as 659B
DashPluginInfo.as 625B
IDecoder.as 486B
WaitSegment.as 463B
NullSegment.as 459B
AudioDecoderEvent.as 443B
AUTHORS 6KB
.babelrc 185B
.babelrc 168B
oggvorbis.c 12KB
semantic.css 735KB
semantic.min.css 537KB
bootstrap.css 193KB
bootstrap.css 193KB
bootstrap.min.css 156KB
bootstrap.css 143KB
bootstrap.min.css 118KB
button.css 88KB
editormd.css 76KB
button.min.css 71KB
grid.css 68KB
bootstrap-grid.css 66KB
editormd.min.css 60KB
ionicons.css 56KB
editormd.preview.css 55KB
grid.min.css 54KB
ionicons.min.css 52KB
icon.css 51KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
计算机毕设论文
- 粉丝: 1w+
- 资源: 399
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功