Table of Contents
Default keyboard operation
# Rendering preview
方法 methods
Appendix
Home Web Front-end JS Tutorial Regarding the zx-image-view image preview plug-in, it supports rotation, scaling, and moving related operations.

Regarding the zx-image-view image preview plug-in, it supports rotation, scaling, and moving related operations.

Jun 11, 2018 pm 05:58 PM

Image preview plug-in, supports image switching, rotation, scaling, moving...

Browser support: IE10, (IE9 does not support rotation function)

Source code address: https://github .com/zx1984/image-view

Demo address: https://zx1984.github.io/image-view/dist/

Default keyboard operation

Direction keys: leftleftrightrightswitch the front and back pictures, upupdowndownrotate clockwise and counterclockwise

Rolling mouse: zoom

Note: Supports custom button configuration, see parameter description for details.

# Rendering preview

Regarding the zx-image-view image preview plug-in, it supports rotation, scaling, and moving related operations.

Regarding the zx-image-view image preview plug-in, it supports rotation, scaling, and moving related operations.

Regarding the zx-image-view image preview plug-in, it supports rotation, scaling, and moving related operations.

##Demo address: https:// zx1984.github.io/image-view/dist/

Use use

npm

npm install zx-image-view --save-dev# 或npm i zx-image-view -D
Copy after login

ES6

import { ZxImageView } from 'zx-image-view'
Copy after login

BrowserBrower

<p id="imgList">
  <img  src="/static/imghw/default1.png"  data-src="a.jpg"  class="lazy"  data-index="0"  alt="Regarding the zx-image-view image preview plug-in, it supports rotation, scaling, and moving related operations." >
  <img  src="/static/imghw/default1.png"  data-src="b.jpg"  class="lazy"  data-index="1"  alt="Regarding the zx-image-view image preview plug-in, it supports rotation, scaling, and moving related operations." >
  <img  src="/static/imghw/default1.png"  data-src="c.jpg"  class="lazy"  data-index="2"  alt="Regarding the zx-image-view image preview plug-in, it supports rotation, scaling, and moving related operations." >
  <img  src="/static/imghw/default1.png"  data-src="d.jpg"  class="lazy"  data-index="3"  alt="Regarding the zx-image-view image preview plug-in, it supports rotation, scaling, and moving related operations." ></p><script src="dist/js/zx-image-view.min.js"></script><script>
  // 初始化参数
  var options = {    // 见参数说明处
  };  // 图片数组1
  var imgArray1 = [    &#39;http://xxx.com/a.jpg&#39;,    &#39;http://xxx.com/b.jpg&#39;,    &#39;http://xxx.com/c.jpg&#39;,    &#39;http://xxx.com/d.jpg&#39;
  ];  // 图片数组2
  var imgArray2 = [
    {
      url: &#39;http://xxx.com/a.jpg&#39;,      // 初始化旋转角度
      angle: 90
    },
    {
      url: &#39;http://xxx.com/b.jpg&#39;,
      angle: 0
    },
    {
      url: &#39;http://xxx.com/c.jpg&#39;,
      angle: 180
    },
    {
      url: &#39;http://xxx.com/d.jpg&#39;
      angle: 90
    }
  ];</script>
Copy after login

Using method 1

var ziv1 = new ZxImageView(options, imgArray1);// 点击缩略图,查看大图var $el = document.getElementById(&#39;imgList&#39;);
$el.addEventListener(&#39;click&#39;, function (e) {
  if (this.nodeName === &#39;IMG&#39;) {    // 获取图片索引
    var index = this.getAttribute(&#39;data-index&#39;);    // 查看图片
    ziv1.view(index);
  }
})
Copy after login

Using method 2

var ziv2 = new ZxImageView(imgArray2);
Copy after login

Using method 3

var ziv3 = new ZxImageView();
ziv3.init(imgArray2);
Copy after login

Using method 4

var ziv4 = new ZxImageView();// 业务场景,针对后台管理列表页,每条数据(动态)有多张图片,需独立预览,不需要多次实例化ZxImageView// 查看imgArray2第3张图片ziv4.view(2, imgArray2);
Copy after login

Development and debugging

npm run start# http://localhost:9000/
Copy after login

Parameter options

ParameterTypeDescriptionbackgroundOpacityFloorBackground mask (black) transparency, value iconfontStringiconfont icon font css style url address (see the appendix iconfont description for the style name)keyboardObjectKeyboard button (previous/next, zoom, rotate, close) configurationmovableBooleanMove pictures, default valuepaginationableBooleanPagination mouseover switches pictures, default valuerotatableBooleanRotate the image, default valuescalableBooleanScale the image, default valueshowClose BooleanShow close preview window button, default valueshowPaginationBooleanShow pagination column, default valueshowSwitchArrowBooleanDisplay left and right switching arrow buttons, default valueshowToolbarBooleanShow toolbar, default value
0-1, default value 0.6
true
true
true
true
true
true
true
false
options.keyboard

ParametersTypeOptional key nameDescriptioncloseStringClose image viewernextStringAny keyNextprev StringAny key or previous; when it is rotateString or ArrayAny key or Picture rotationscaleString or ArrayAny key or Picture zoom

注意:参数中只能包含有且一个mousewheel配置;任何配置均不支持组合键。

keyboard参数可选属性见页尾–附录

 // 初始化参数let _config = {  // 分页mouseover切换图片
  paginationable: true,  // 显示关闭按钮
  showClose: true,  // 显示上一张/下一张箭头
  showSwitchArrow: true,  // 显示分页导航栏
  showPagination: true,  // 缩放
  scalable: true,  // 旋转
  rotatable: true,  // 移动
  movable: true,  // 键盘配置
  keyboard: {
    prev: &#39;a&#39;,
    next: &#39;d&#39;,
    rotate: [&#39;up&#39;, &#39;down&#39;],
    scale: &#39;mousewheel&#39;
  }
}new ZxImageView(_config);
Copy after login

方法 methods

  • destroy() 销毁当前图片查看dom对象

  • init(imageArray, index) 初始化图片数据


mousewheelmousewheel, next is invalid
mousewheel
mousewheel
参数 类型 必须 说明
imageArray Array 图片url数组
index Number imageArray的索引,默认显示的第index + 1张图片;默认为0; 如果index > imageArray.length将被忽略

* view(index, angle, imageArray) 查看第index + 1张图片

参数 类型 必须 说明
index Number imageArray的索引,显示的第index + 1张图片
angle Number 图片旋转角度,90的整数倍
imageArray Array 图片url数组,将更新初始化的图片数组

Appendix

  • iconfont style name description

Font style.zx, icon style is as shown below:

zx-image-view iconfont

http://www.iconfont.cn/

  • Support custom keyboard button name/keyboard parameter optional attributes

##backquotedigit1digit2digit3digit4digit5##5( %)digit66(^)digit77(&)digit88(*)digit99(()digit00( ))equal=( )minus-(-)a-zAbracketLeft[({)##bracketRight Key;(:)'(")backslash,(>).( key/(?)Space bar0123456789/*-.Insert keyHome keyEnd KeyPageUp KeyPageDownDelete keyArrowLeftArrowRightArrowUpDown arrow key(ArrowDown)##Mouse scroll
Attributes Key name/Description
escape Esc key
Main keyboard
~ Key
1(!) Key
2(@) key
3(#) key
4($) key
key
key
key
key
key
key
key
Key
to ZKey
key
](}) ##semicolon
Key quote
key backslash
key period
key comma
slash
key space
Number pad

numpad0
numpad1
numpad2
numpad3
numpad4
numpad5
numpad6
numpad7
numpad8
numpad9
numpadpide
divide or divide numpadMultiply
multiply numpadSubtract
Subtract numpadAdd
Add numpadDecimal
Decimal point Edit keypad

insert
home
end
pageUp
pageDown
delete
left
right
up
down
DescriptionmousewheelMouse scroll key

The above is the detailed content of Regarding the zx-image-view image preview plug-in, it supports rotation, scaling, and moving related operations.. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What should I do if I encounter garbled code printing for front-end thermal paper receipts? What should I do if I encounter garbled code printing for front-end thermal paper receipts? Apr 04, 2025 pm 02:42 PM

Frequently Asked Questions and Solutions for Front-end Thermal Paper Ticket Printing In Front-end Development, Ticket Printing is a common requirement. However, many developers are implementing...

Demystifying JavaScript: What It Does and Why It Matters Demystifying JavaScript: What It Does and Why It Matters Apr 09, 2025 am 12:07 AM

JavaScript is the cornerstone of modern web development, and its main functions include event-driven programming, dynamic content generation and asynchronous programming. 1) Event-driven programming allows web pages to change dynamically according to user operations. 2) Dynamic content generation allows page content to be adjusted according to conditions. 3) Asynchronous programming ensures that the user interface is not blocked. JavaScript is widely used in web interaction, single-page application and server-side development, greatly improving the flexibility of user experience and cross-platform development.

Who gets paid more Python or JavaScript? Who gets paid more Python or JavaScript? Apr 04, 2025 am 12:09 AM

There is no absolute salary for Python and JavaScript developers, depending on skills and industry needs. 1. Python may be paid more in data science and machine learning. 2. JavaScript has great demand in front-end and full-stack development, and its salary is also considerable. 3. Influencing factors include experience, geographical location, company size and specific skills.

How to merge array elements with the same ID into one object using JavaScript? How to merge array elements with the same ID into one object using JavaScript? Apr 04, 2025 pm 05:09 PM

How to merge array elements with the same ID into one object in JavaScript? When processing data, we often encounter the need to have the same ID...

Is JavaScript hard to learn? Is JavaScript hard to learn? Apr 03, 2025 am 12:20 AM

Learning JavaScript is not difficult, but it is challenging. 1) Understand basic concepts such as variables, data types, functions, etc. 2) Master asynchronous programming and implement it through event loops. 3) Use DOM operations and Promise to handle asynchronous requests. 4) Avoid common mistakes and use debugging techniques. 5) Optimize performance and follow best practices.

How to achieve parallax scrolling and element animation effects, like Shiseido's official website?
or:
How can we achieve the animation effect accompanied by page scrolling like Shiseido's official website? How to achieve parallax scrolling and element animation effects, like Shiseido's official website? or: How can we achieve the animation effect accompanied by page scrolling like Shiseido's official website? Apr 04, 2025 pm 05:36 PM

Discussion on the realization of parallax scrolling and element animation effects in this article will explore how to achieve similar to Shiseido official website (https://www.shiseido.co.jp/sb/wonderland/)...

The difference in console.log output result: Why are the two calls different? The difference in console.log output result: Why are the two calls different? Apr 04, 2025 pm 05:12 PM

In-depth discussion of the root causes of the difference in console.log output. This article will analyze the differences in the output results of console.log function in a piece of code and explain the reasons behind it. �...

How to implement panel drag and drop adjustment function similar to VSCode in front-end development? How to implement panel drag and drop adjustment function similar to VSCode in front-end development? Apr 04, 2025 pm 02:06 PM

Explore the implementation of panel drag and drop adjustment function similar to VSCode in the front-end. In front-end development, how to implement VSCode similar to VSCode...

See all articles