From ed61f3574360998c39bcbe699cd154de47822652 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E8=B4=A4=E6=96=8C?= Date: Wed, 20 Mar 2024 10:23:00 +0800 Subject: [PATCH 1/2] Update imgZoom.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复inStr函数的类型问题 --- src/imgZoom.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/imgZoom.js b/src/imgZoom.js index a69e706..bf3db12 100644 --- a/src/imgZoom.js +++ b/src/imgZoom.js @@ -227,10 +227,13 @@ function bing(){ //判断class字符串是否存在imgzoom function inStr(str, string) { var isin = false; - var arr = str.split(' '); - for (var i in arr) { - if (arr[i] == string) { - isin = true; + if (typeof str === "string") { + var arr = str.split(' '); + for (var i in arr) { + if (arr[i] === string) { + isin = true; + break; + } } } return isin; @@ -411,4 +414,4 @@ var imgZoom = function(){ }; }(); -export default imgZoom \ No newline at end of file +export default imgZoom From 8f516cbae9dd72d778d04804ac2332d0afef90d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E8=B4=A4=E6=96=8C?= Date: Mon, 1 Apr 2024 11:28:22 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=89=A7=E8=A1=8Ctype=E5=8F=8Auglify?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/imgZoom.d.ts.map | 2 +- package.json | 2 +- src/imgZoom.min.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dist/imgZoom.d.ts.map b/dist/imgZoom.d.ts.map index e1f4375..d13d138 100644 --- a/dist/imgZoom.d.ts.map +++ b/dist/imgZoom.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"imgZoom.d.ts","sourceRoot":"","sources":["../src/imgZoom.js"],"names":[],"mappings":";;;;;IA+YU;;;;;;MAUL;;AAjZD,4BAAiB;AACjB,0BAAoB;AACpB,2BAAqB;AAgVzB,2CAOC;AAGD,4CAOC;AA5HD,wCA+BC;AAGD,+BAKC;AAqCD,0DAgBC"} \ No newline at end of file +{"version":3,"file":"imgZoom.d.ts","sourceRoot":"","sources":["../src/imgZoom.js"],"names":[],"mappings":";;;;;IAkZU;;;;;;MAUL;;AApZD,4BAAiB;AACjB,0BAAoB;AACpB,2BAAqB;AAmVzB,2CAOC;AAGD,4CAOC;AA5HD,wCA+BC;AAGD,+BAKC;AAqCD,0DAgBC"} \ No newline at end of file diff --git a/package.json b/package.json index ed9010c..8deb9da 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "imgzoom-li", - "version": "0.9.4", + "version": "0.9.5", "description": "一个可以查看图片(可以缩放,拖拽)的JS插件", "main": "./src/imgZoom.min.js", "types": "./dist/imgZoom.d.ts", diff --git a/src/imgZoom.min.js b/src/imgZoom.min.js index cc56736..cbcc55d 100644 --- a/src/imgZoom.min.js +++ b/src/imgZoom.min.js @@ -22,4 +22,4 @@
-
`}function lastnext(n){let e=document.getElementById("_imgzoom").getElementsByClassName(n)[0];e.addEventListener("mousemove",function(){e.getElementsByTagName("p")[0].style.display="block"}),e.addEventListener("mouseout",function(){e.getElementsByTagName("p")[0].style.display="none"}),e.addEventListener("mousedown",function(e){e.stopPropagation()}),e.addEventListener("click",()=>{let i=void 0;var t=document.getElementsByClassName("imgZoom");for(let e=0;e{e.preventDefault(),Detail(e,t)}),t.addEventListener("DOMMouseScroll",e=>{e.preventDefault(),Detail(e,t)})}function Detail(e,t){var i;(e=e||window.event).wheelDelta<0?(e=Math.round(.9*t.offsetWidth),i=Math.round(.9*t.offsetHeight),(360{e/=t;e<=window.innerWidth/window.innerHeight?(t=(window.innerHeight-350)*e,n.style.width=t+"px"):n.style.width=window.innerWidth-200+"px"};t&&(t.preventDefault?t.preventDefault():t.returnValue=!1);t=document.getElementById("net").src;let n=document.getElementById("_imgzoom");var e=_CurrentImage.src;if(_size[e])i(_size[e].width,_size[e].height);else{console.log(555);let e=new Image;e.src=t,e.complete?i(e.width,e.height):e.onload=function(){i(e.width,e.height)}}}function ThemeSwitch(e,t){t&&(t.preventDefault?t.preventDefault():t.returnValue=!1),e&&(_theme=e),Array.from(document.getElementsByClassName("_imgzoom_box")).forEach(e=>{e.style.backgroundColor="day"==_theme?"black":"white"}),Array.from(document.getElementsByClassName("_imgzoom_title")).forEach(e=>{e.style.color="day"==_theme?"white":"black"}),_theme="night"==_theme?"day":"night"}function targetImg(e){e&&(e.preventDefault?e.preventDefault():e.returnValue=!1),_CurrentImage?window.open(_CurrentImage.src):console.error('F01: Imgzoom is not initialized, please execute "imgZoom.init()"')}function SetOption(e){e.width&&(_width=e.width),e.title&&(_title=e.title),e.top&&(_top=e.top),e.left&&(_left=e.left),e.theme&&(_theme=e.theme),e.svgCache&&(_svgCache=e.svgCache)}function SetTitle(e){try{document.querySelector("p._imgzoom_title").firstChild.nodeValue=e}catch(e){console.log(e)}}function isPE(){return/Android|webOS|iPhone|ipod|ipad|BlackBerry/i.test(navigator.userAgent)}function start(){create(),bing(),document.addEventListener("click",e=>{var t=e.target;"IMG"==t.nodeName&&inStr(t.className,"imgZoom")&&Open(t),(inStr(t.className,"imgzoom_shadow")||inStr(t.className,"imgzoom_close"))&&Close(),inStr(t.className,"imgzoom_resize")&&Resize(e),inStr(t.className,"imgzoom_check")&&ThemeSwitch(null,e),inStr(t.className,"imgzoom_imglink")&&targetImg(e)})}var imgZoom={Version:Version,Title:Title,Author:Author,init:function(){return imgLoad(),start(),{SetOption:SetOption,SetTitle:SetTitle,Open:Open,Close:Close,ThemeSwitch:ThemeSwitch}}};export default imgZoom; \ No newline at end of file + `}function lastnext(n){let e=document.getElementById("_imgzoom").getElementsByClassName(n)[0];e.addEventListener("mousemove",function(){e.getElementsByTagName("p")[0].style.display="block"}),e.addEventListener("mouseout",function(){e.getElementsByTagName("p")[0].style.display="none"}),e.addEventListener("mousedown",function(e){e.stopPropagation()}),e.addEventListener("click",()=>{let i=void 0;var t=document.getElementsByClassName("imgZoom");for(let e=0;e{e.preventDefault(),Detail(e,t)}),t.addEventListener("DOMMouseScroll",e=>{e.preventDefault(),Detail(e,t)})}function Detail(e,t){var i;(e=e||window.event).wheelDelta<0?(e=Math.round(.9*t.offsetWidth),i=Math.round(.9*t.offsetHeight),(360{e/=t;e<=window.innerWidth/window.innerHeight?(t=(window.innerHeight-350)*e,n.style.width=t+"px"):n.style.width=window.innerWidth-200+"px"};t&&(t.preventDefault?t.preventDefault():t.returnValue=!1);t=document.getElementById("net").src;let n=document.getElementById("_imgzoom");var e=_CurrentImage.src;if(_size[e])i(_size[e].width,_size[e].height);else{console.log(555);let e=new Image;e.src=t,e.complete?i(e.width,e.height):e.onload=function(){i(e.width,e.height)}}}function ThemeSwitch(e,t){t&&(t.preventDefault?t.preventDefault():t.returnValue=!1),e&&(_theme=e),Array.from(document.getElementsByClassName("_imgzoom_box")).forEach(e=>{e.style.backgroundColor="day"==_theme?"black":"white"}),Array.from(document.getElementsByClassName("_imgzoom_title")).forEach(e=>{e.style.color="day"==_theme?"white":"black"}),_theme="night"==_theme?"day":"night"}function targetImg(e){e&&(e.preventDefault?e.preventDefault():e.returnValue=!1),_CurrentImage?window.open(_CurrentImage.src):console.error('F01: Imgzoom is not initialized, please execute "imgZoom.init()"')}function SetOption(e){e.width&&(_width=e.width),e.title&&(_title=e.title),e.top&&(_top=e.top),e.left&&(_left=e.left),e.theme&&(_theme=e.theme),e.svgCache&&(_svgCache=e.svgCache)}function SetTitle(e){try{document.querySelector("p._imgzoom_title").firstChild.nodeValue=e}catch(e){console.log(e)}}function isPE(){return/Android|webOS|iPhone|ipod|ipad|BlackBerry/i.test(navigator.userAgent)}function start(){create(),bing(),document.addEventListener("click",e=>{var t=e.target;"IMG"==t.nodeName&&inStr(t.className,"imgZoom")&&Open(t),(inStr(t.className,"imgzoom_shadow")||inStr(t.className,"imgzoom_close"))&&Close(),inStr(t.className,"imgzoom_resize")&&Resize(e),inStr(t.className,"imgzoom_check")&&ThemeSwitch(null,e),inStr(t.className,"imgzoom_imglink")&&targetImg(e)})}var imgZoom={Version:Version,Title:Title,Author:Author,init:function(){return imgLoad(),start(),{SetOption:SetOption,SetTitle:SetTitle,Open:Open,Close:Close,ThemeSwitch:ThemeSwitch}}};export default imgZoom; \ No newline at end of file