{"id":22920824,"url":"https://github.com/capricorncd/zx-image-viewer","last_synced_at":"2025-08-19T20:18:22.084Z","repository":{"id":57406868,"uuid":"133814698","full_name":"capricorncd/zx-image-viewer","owner":"capricorncd","description":"Picture view plug-in, support switch, rotate, zoom, drag...图片查看插件，支持切换、旋转、缩放、拖动...","archived":false,"fork":false,"pushed_at":"2020-10-19T11:03:20.000Z","size":1035,"stargazers_count":38,"open_issues_count":4,"forks_count":19,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-08-09T19:49:58.865Z","etag":null,"topics":["javascript"],"latest_commit_sha":null,"homepage":"https://capricorncd.github.io/zx-image-viewer/dist/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/capricorncd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-17T13:06:28.000Z","updated_at":"2025-06-09T06:22:21.000Z","dependencies_parsed_at":"2022-09-26T17:01:28.840Z","dependency_job_id":null,"html_url":"https://github.com/capricorncd/zx-image-viewer","commit_stats":null,"previous_names":["capricorncd/image-view"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/capricorncd/zx-image-viewer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/capricorncd%2Fzx-image-viewer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/capricorncd%2Fzx-image-viewer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/capricorncd%2Fzx-image-viewer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/capricorncd%2Fzx-image-viewer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/capricorncd","download_url":"https://codeload.github.com/capricorncd/zx-image-viewer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/capricorncd%2Fzx-image-viewer/sbom","scorecard":{"id":265277,"data":{"date":"2025-08-11","repo":{"name":"github.com/capricorncd/zx-image-viewer","commit":"c43d297fdbd76f6620c2001a364adbe148ea1216"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.6,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-17T11:52:12.682Z","repository_id":57406868,"created_at":"2025-08-17T11:52:12.682Z","updated_at":"2025-08-17T11:52:12.682Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271215037,"owners_count":24720098,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-19T02:00:09.176Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript"],"created_at":"2024-12-14T07:17:06.614Z","updated_at":"2025-08-19T20:18:22.053Z","avatar_url":"https://github.com/capricorncd.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# zx-image-viewer\n\n图片预览插件，支持图片切换、旋转、缩放、移动...\n\n浏览器支持：IE10+, (IE9不支持旋转功能)\n\n\u003cp align=\"left\"\u003e\n  \u003ca href=\"https://npmcharts.com/compare/zx-image-viewer?minimal=true\"\u003e\u003cimg src=\"https://img.shields.io/npm/dm/zx-image-viewer.svg?sanitize=true\" alt=\"Downloads\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/zx-image-viewer\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/zx-image-viewer.svg?sanitize=true\" alt=\"Version\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/zx-image-viewer\"\u003e\u003cimg src=\"https://img.shields.io/npm/l/zx-image-viewer.svg?sanitize=true\" alt=\"License\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## 默认键盘操作\n\n\u003e 方向键：左`left`右`right`前后图片切换，上`up`下`down`顺时针逆时针旋转\n\n\u003e 滚动鼠标：缩放\n\n注：支持自定义按键配置，详见参数说明。\n\n## 使用 use\n\nnpm\n\n```\nnpm install zx-image-viewer --save-dev\n# 或\nnpm i zx-image-viewer -D\n```\n\nES6+\n\n```javascript\nimport { ZxImageViewer } from 'zx-image-viewer'\n```\n\n浏览器Browser\n\n```html\n\u003cdiv id=\"imgList\"\u003e\n  \u003cimg data-index=\"0\" src=\"a.jpg\"\u003e\n  \u003cimg data-index=\"1\" src=\"b.jpg\"\u003e\n  \u003cimg data-index=\"2\" src=\"c.jpg\"\u003e\n  \u003cimg data-index=\"3\" src=\"d.jpg\"\u003e\n\u003c/div\u003e\n\u003cscript src=\"dist/js/zx-image-viewer.min.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n  // 初始化参数\n  var options = {\n    // 见参数说明处\n  };\n\n  // 图片数组1\n  var imgArray1 = [\n    'http://xxx.com/a.jpg',\n    'http://xxx.com/b.jpg',\n    'http://xxx.com/c.jpg',\n    'http://xxx.com/d.jpg'\n  ];\n\n  // 图片数组2\n  var imgArray2 = [\n    {\n      url: 'http://xxx.com/a.jpg',\n      // 初始化旋转角度\n      angle: 90\n    },\n    {\n      url: 'http://xxx.com/b.jpg',\n      angle: 0\n    },\n    {\n      url: 'http://xxx.com/c.jpg',\n      angle: 180\n    },\n    {\n      url: 'http://xxx.com/d.jpg'\n      angle: 90\n    }\n  ];\n\u003c/script\u003e\n```\n\n使用方法 1\n\n```javascript\nvar ziv1 = new ZxImageViewer(options, imgArray1);\n\n// 点击缩略图，查看大图\nvar $el = document.getElementById('imgList');\n$el.addEventListener('click', function (e) {\n  if (this.nodeName === 'IMG') {\n    // 获取图片索引\n    var index = this.getAttribute('data-index');\n    // 查看图片\n    ziv1.view(index);\n  }\n})\n```\n\n使用方法 2\n\n```javascript\nvar ziv2 = new ZxImageViewer(imgArray2);\n```\n\n使用方法 3\n\n```javascript\nvar ziv3 = new ZxImageViewer();\nziv3.init(imgArray2);\n```\n\n使用方法 4\n\n```javascript\nvar ziv4 = new ZxImageViewer();\n// 业务场景，针对后台管理列表页，每条数据(动态)有多张图片，需独立预览，不需要多次实例化ZxImageViewer\n// 查看imgArray2第3张图片\nziv4.view(2, imgArray2);\n```\n\n开发调试\n\n```\nnpm run dev\n# http://localhost:9000/\n```\n\n## # 效果图 preview\n\n![zx-image-viewer](resource/view-1.jpg)\n\n![zx-image-viewer](resource/view-2.jpg)\n\n![zx-image-viewer](resource/mobile.jpg)\n\n## 参数 options\n\n|参数|类型|说明|\n|:--|:--|:--|\n|maskBackground|Floor|背景遮罩颜色，默认值`rgba(0, 0, 0, 0.6)`|\n|iconfont|String|iconfont图标字体css样式url地址(样式名见附录iconfont说明)|\n|keyboard|Object|键盘按钮(前/后一张、缩放、旋转、关闭)配置|\n|movable|Boolean|移动图片，默认值`true`|\n|paginationable|Boolean|分页mouseover切换图片，默认值`true`|\n|rotatable|Boolean|旋转图片，默认值`true`|\n|scalable|Boolean|缩放图片，默认值`true`|\n|showClose|Boolean|显示关闭预览窗口按钮，默认值`true`|\n|showPagination|Boolean|显示分页栏，默认值`true`|\n|showSwitchArrow|Boolean|显示左右切换箭头按钮，默认值`true`|\n|showToolbar|Boolean|显示工具栏，默认值`false`|\n|toolbarButtons|Array|工具栏按钮数量及顺序配置，可选值/默认值`['prev', 'enlarge', 'rotate', 'reduce', 'next']`|\n\n#### options.keyboard\n\n|参数|类型|可选键名|说明|\n|:--|:--|:--|:--|\n|close|String|关闭图片查看器|\n|next|String|任意键|下一张|\n|prev|String|任意键或`mousewheel`|上一张；为`mousewheel`时，next无效|\n|rotate|String或Array|任意键或`mousewheel`|图片旋转|\n|scale|String或Array|任意键或`mousewheel`|图片缩放|\n\n注意：参数中只能包含有且一个`mousewheel`配置；任何配置均不支持组合键。\n\nkeyboard参数可选属性见页尾--附录\n\n```javascript\n // 初始化参数\nlet _config = {\n  // 分页mouseover切换图片\n  paginationable: true,\n  // 显示关闭按钮\n  showClose: true,\n  // 显示上一张/下一张箭头\n  showSwitchArrow: true,\n  // 显示分页导航栏\n  showPagination: true,\n  // 缩放\n  scalable: true,\n  // 旋转\n  rotatable: true,\n  // 移动\n  movable: true,\n  // 键盘配置\n  keyboard: {\n    prev: 'a',\n    next: 'd',\n    rotate: ['up', 'down'],\n    scale: 'mousewheel'\n  }\n}\nnew ZxImageViewer(_config);\n```\n\n## 方法 methods\n\n* destroy() 销毁当前图片查看dom对象\n\n* init(imageArray, index) 初始化图片数据\n\n|参数|类型|必须|说明|\n|:--|:--|:--|:--|\n|imageArray|Array|是|图片url数组|\n|index|Number|否|imageArray的索引，默认显示的第`index + 1`张图片；默认为`0`; 如果`index \u003e imageArray.length`将被忽略|\n\n* view(index, angle, imageArray) 查看第`index + 1`张图片\n\n|参数|类型|必须|说明|\n|:--|:--|:--|:--|\n|index|Number|是|imageArray的索引，显示的第`index + 1`张图片|\n|angle|Number|否|图片旋转角度，90的整数倍|\n|imageArray|Array|否|图片url数组，将更新初始化的图片数组|\n\n## 附录\n\n* iconfont样式名说明\n\n字体样式`.zx`，图标样式如下图：\n\n![zx-image-viewer iconfont](resource/iconfont.png)\n\nhttp://www.iconfont.cn/\n\n* 支持自定义键盘按钮名/keyboard参数可选属性\n\n|属性|键名/说明|\n|:--|:--|\n|escape|Esc键|\n|主键盘| |\n|backquote| `~` 键|\n|digit1| `1(!)` 键 |\n|digit2| `2(@)` 键 |\n|digit3| `3(#)` 键 |\n|digit4| `4($)` 键 |\n|digit5| `5(%)` 键 |\n|digit6| `6(^)` 键 |\n|digit7| `7(\u0026)` 键 |\n|digit8| `8(*)` 键 |\n|digit9| `9(()` 键 |\n|digit0| `0())` 键 |\n|equal| `=(+)` 键 |\n|minus| `-(-)` 键 |\n|a-z|`A`至`Z`键|\n|bracketLeft| `[({)` 键 |\n|bracketRight| `](})` 键 |\n|semicolon| `;(:)` 键 |\n|quote| `'(\")` 键 |\n|backslash| `反斜线` 键 |\n|period| `,(\u003e)` 键 |\n|comma| `.(\u003c)` 键 |\n|slash| `/(?)` 键 |\n|space| 空格键 |\n|数字键盘||\n|numpad0| 0 |\n|numpad1| 1 |\n|numpad2| 2 |\n|numpad3| 3 |\n|numpad4| 4 |\n|numpad5| 5 |\n|numpad6| 6 |\n|numpad7| 7 |\n|numpad8| 8 |\n|numpad9| 9 |\n|numpadDivide| `/`分或除 |\n|numpadMultiply| `*`乘 |\n|numpadSubtract| `-`减 |\n|numpadAdd| `+`加 |\n|numpadDecimal| `.`小数点 |\n|编辑键区||\n|insert| Insert 键 |\n|home| Home 键 |\n|end| End 键 |\n|pageUp| PageUp 键 |\n|pageDown| PageDown |\n|delete| Delete 键 |\n|left| 方向键左(ArrowLeft) |\n|right| 方向键右(ArrowRight) |\n|up| 方向键上(ArrowUp) |\n|down| 方向键下(ArrowDown) |\n\n|鼠标滚动|说明|\n|:--|:--|\n|mousewheel|鼠标滚动键|\n\n## Copyright and license\n\nCode and documentation copyright 2018. capricorncd. Code released under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcapricorncd%2Fzx-image-viewer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcapricorncd%2Fzx-image-viewer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcapricorncd%2Fzx-image-viewer/lists"}