wsemi 1.9.0 → 1.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (496) hide show
  1. package/README.md +1 -1
  2. package/dist/wsemi.umd.js +4 -4
  3. package/dist/wsemi.umd.js.map +1 -1
  4. package/docs/-_class.mjs.html +1 -1
  5. package/docs/-_const.mjs.html +1 -1
  6. package/docs/ab2blob.mjs.html +1 -1
  7. package/docs/ab2u8arr.mjs.html +1 -1
  8. package/docs/addExcelWorksheetFromData.mjs.html +1 -1
  9. package/docs/addMonth.mjs.html +1 -1
  10. package/docs/aes2str.mjs.html +1 -1
  11. package/docs/alive.mjs.html +1 -1
  12. package/docs/arr2dt.mjs.html +1 -1
  13. package/docs/arrAccum.mjs.html +1 -1
  14. package/docs/arrAdd.mjs.html +1 -1
  15. package/docs/arrAt.mjs.html +1 -1
  16. package/docs/arrDiff.mjs.html +1 -1
  17. package/docs/arrFilterByKeywords.mjs.html +1 -1
  18. package/docs/arrFilterByNum.mjs.html +1 -1
  19. package/docs/arrFilterByPnum.mjs.html +1 -1
  20. package/docs/arrFilterByPnumAndToLog.mjs.html +1 -1
  21. package/docs/arrFind.mjs.html +1 -1
  22. package/docs/arrGroupByMaxmin.mjs.html +1 -1
  23. package/docs/arrHas.mjs.html +1 -1
  24. package/docs/arrInsert.mjs.html +1 -1
  25. package/docs/arrLookupByMaxmin.mjs.html +1 -1
  26. package/docs/arrMax.mjs.html +1 -1
  27. package/docs/arrMin.mjs.html +1 -1
  28. package/docs/arrMulti.mjs.html +1 -1
  29. package/docs/arrNorm.mjs.html +1 -1
  30. package/docs/arrProduct.mjs.html +1 -1
  31. package/docs/arrPull.mjs.html +1 -1
  32. package/docs/arrPullAt.mjs.html +1 -1
  33. package/docs/arrReduce.mjs.html +1 -1
  34. package/docs/arrReverse.mjs.html +1 -1
  35. package/docs/arrSep.mjs.html +1 -1
  36. package/docs/arrSort.mjs.html +1 -1
  37. package/docs/asind.mjs.html +1 -1
  38. package/docs/atan2d.mjs.html +1 -1
  39. package/docs/atand.mjs.html +1 -1
  40. package/docs/attstr.mjs.html +1 -1
  41. package/docs/b642obj.mjs.html +1 -1
  42. package/docs/b642str.mjs.html +1 -1
  43. package/docs/b642u16arr.mjs.html +1 -1
  44. package/docs/b642u8arr.mjs.html +1 -1
  45. package/docs/binstr.mjs.html +1 -1
  46. package/docs/blob2ab.mjs.html +1 -1
  47. package/docs/blob2b64.mjs.html +1 -1
  48. package/docs/blob2str.mjs.html +1 -1
  49. package/docs/blob2u8arr.mjs.html +1 -1
  50. package/docs/blobs2b64s.mjs.html +1 -1
  51. package/docs/blobs2u8arrs.mjs.html +1 -1
  52. package/docs/bodyLog.mjs.html +1 -1
  53. package/docs/browserView.mjs.html +1 -1
  54. package/docs/browserViewFromBlob.mjs.html +1 -1
  55. package/docs/browserViewFromText.mjs.html +1 -1
  56. package/docs/browserViewFromU8arr.mjs.html +1 -1
  57. package/docs/bs2u8arr.mjs.html +1 -1
  58. package/docs/bufRead.mjs.html +1 -1
  59. package/docs/bufReadDbl.mjs.html +1 -1
  60. package/docs/bufWrite.mjs.html +1 -1
  61. package/docs/bufWriteDbl.mjs.html +1 -1
  62. package/docs/cache.mjs.html +1 -1
  63. package/docs/cacheBd.mjs.html +1 -1
  64. package/docs/cacheSt.mjs.html +1 -1
  65. package/docs/cbol.mjs.html +1 -1
  66. package/docs/cdbl.mjs.html +1 -1
  67. package/docs/ceil.mjs.html +1 -1
  68. package/docs/cfilesize.mjs.html +1 -1
  69. package/docs/cfinancial.mjs.html +1 -1
  70. package/docs/cint.mjs.html +1 -1
  71. package/docs/clearXSS.mjs.html +1 -1
  72. package/docs/clearXSSDyn.mjs.html +1 -1
  73. package/docs/color.mjs.html +1 -1
  74. package/docs/composeToTree.mjs.html +1 -1
  75. package/docs/convertToTree.mjs.html +1 -1
  76. package/docs/copyStrToClipboard.mjs.html +1 -1
  77. package/docs/cosd.mjs.html +1 -1
  78. package/docs/cotd.mjs.html +1 -1
  79. package/docs/createExcelWorkbook.mjs.html +1 -1
  80. package/docs/cscd.mjs.html +1 -1
  81. package/docs/cstr.mjs.html +1 -1
  82. package/docs/day2cht.mjs.html +1 -1
  83. package/docs/debounce.mjs.html +1 -1
  84. package/docs/delay.mjs.html +1 -1
  85. package/docs/dig.mjs.html +1 -1
  86. package/docs/digExp.mjs.html +1 -1
  87. package/docs/domAlert.mjs.html +1 -1
  88. package/docs/domAppend.mjs.html +1 -1
  89. package/docs/domCancelEvent.mjs.html +1 -1
  90. package/docs/domCompareText.mjs.html +1 -1
  91. package/docs/domConvertToPic.mjs.html +1 -1
  92. package/docs/domConvertToPicDyn.mjs.html +1 -1
  93. package/docs/domDetect.mjs.html +1 -1
  94. package/docs/domDrag.mjs.html +1 -1
  95. package/docs/domDragBarAndScroll.mjs.html +476 -333
  96. package/docs/domDragPreview.mjs.html +1 -1
  97. package/docs/domDropFiles.mjs.html +1 -1
  98. package/docs/domElementsFromPoint.mjs.html +1 -1
  99. package/docs/domFadeIn.mjs.html +1 -1
  100. package/docs/domFadeOut.mjs.html +1 -1
  101. package/docs/domFind.mjs.html +1 -1
  102. package/docs/domFinds.mjs.html +1 -1
  103. package/docs/domGetAttr.mjs.html +1 -1
  104. package/docs/domGetBoudRect.mjs.html +1 -1
  105. package/docs/domGetBoudRectRefSelf.mjs.html +1 -1
  106. package/docs/domGetFileAccept.mjs.html +1 -1
  107. package/docs/domGetFiles.mjs.html +1 -1
  108. package/docs/domGetParents.mjs.html +1 -1
  109. package/docs/domGetPointFromEvent.mjs.html +1 -1
  110. package/docs/domGetScrollableParent.mjs.html +1 -1
  111. package/docs/domGetWindowSize.mjs.html +1 -1
  112. package/docs/domIsClientXYIn.mjs.html +1 -1
  113. package/docs/domIsFocused.mjs.html +1 -1
  114. package/docs/domIsStable.mjs.html +1 -1
  115. package/docs/domIsVisible.mjs.html +1 -1
  116. package/docs/domPrepend.mjs.html +1 -1
  117. package/docs/domRemove.mjs.html +1 -1
  118. package/docs/domRenderMarkdownMind.mjs.html +1 -1
  119. package/docs/domRenderMarkdownMindDyn.mjs.html +1 -1
  120. package/docs/domRipple.mjs.html +1 -1
  121. package/docs/domScrollIntoView.mjs.html +1 -1
  122. package/docs/domScrollTo.mjs.html +1 -1
  123. package/docs/domSetAttr.mjs.html +1 -1
  124. package/docs/domShowImages.mjs.html +1 -1
  125. package/docs/domShowImagesDyn.mjs.html +1 -1
  126. package/docs/domShowInputAndGetFiles.mjs.html +1 -1
  127. package/docs/domShowInputAndGetFilesU8Arrs.mjs.html +1 -1
  128. package/docs/domShowInputDatatime.mjs.html +1 -1
  129. package/docs/domTooltip.mjs.html +1 -1
  130. package/docs/domTriggerEvent.mjs.html +1 -1
  131. package/docs/domVirtualCreate.mjs.html +1 -1
  132. package/docs/domVirtualCreateQueue.mjs.html +1 -1
  133. package/docs/downloadExcelFileFromData.mjs.html +1 -1
  134. package/docs/downloadExcelFileFromDataDyn.mjs.html +1 -1
  135. package/docs/downloadFileFromB64.mjs.html +1 -1
  136. package/docs/downloadFileFromBlob.mjs.html +1 -1
  137. package/docs/downloadFileFromText.mjs.html +1 -1
  138. package/docs/downloadFileFromU8Arr.mjs.html +1 -1
  139. package/docs/dtmapping.mjs.html +1 -1
  140. package/docs/dtpick.mjs.html +1 -1
  141. package/docs/estimateTicks.mjs.html +1 -1
  142. package/docs/evEmit.mjs.html +1 -1
  143. package/docs/evEmitDelay.mjs.html +1 -1
  144. package/docs/evem.mjs.html +1 -1
  145. package/docs/examples/ex-blob2b64.html +1 -1
  146. package/docs/examples/ex-clearXSS.html +1 -1
  147. package/docs/examples/ex-clearXSSDyn.html +1 -1
  148. package/docs/examples/ex-colorConverter.html +1 -1
  149. package/docs/examples/ex-domCompareText.html +1 -1
  150. package/docs/examples/ex-domConvertToPic.html +1 -1
  151. package/docs/examples/ex-domDrag.html +1 -1
  152. package/docs/examples/ex-domDropFiles.html +1 -1
  153. package/docs/examples/ex-domIsVisible.html +1 -1
  154. package/docs/examples/ex-domRenderMarkdownMind.html +1 -1
  155. package/docs/examples/ex-domRenderMarkdownMindDyn.html +1 -1
  156. package/docs/examples/ex-domRipple.html +1 -1
  157. package/docs/examples/ex-domScrollIntoView.html +1 -1
  158. package/docs/examples/ex-domScrollTo.html +1 -1
  159. package/docs/examples/ex-domShowImages.html +1 -1
  160. package/docs/examples/ex-domShowImagesDyn.html +1 -1
  161. package/docs/examples/ex-domShowInputAndGetFiles.html +1 -1
  162. package/docs/examples/ex-domTooltip.html +1 -1
  163. package/docs/examples/ex-getFileHash.html +1 -1
  164. package/docs/examples/ex-getUserAgent.html +1 -1
  165. package/docs/examples/ex-getUserAgentDyn.html +1 -1
  166. package/docs/examples/ex-html2str.html +1 -1
  167. package/docs/examples/ex-obj2u8arr-u8arr2obj.html +1 -1
  168. package/docs/examples/ex-openLink.html +1 -1
  169. package/docs/examples/ex-str2aes-aes2str.html +1 -1
  170. package/docs/examples/ex-str2b64-b642str.html +1 -1
  171. package/docs/examples/ex-strFindFuzz.html +1 -1
  172. package/docs/examples/ex-timeTZ2expire-timeTZ2past.html +1 -1
  173. package/docs/examples/ex-xlsx.html +1 -1
  174. package/docs/execCli.mjs.html +1 -1
  175. package/docs/execCliCore.mjs.html +1 -1
  176. package/docs/execCliJsonRpc.mjs.html +1 -1
  177. package/docs/execCliSession.mjs.html +1 -1
  178. package/docs/execJsCode.mjs.html +1 -1
  179. package/docs/execProcess.mjs.html +1 -1
  180. package/docs/execProcessKillPid.mjs.html +1 -1
  181. package/docs/filepathToTree.mjs.html +1 -1
  182. package/docs/files2data.mjs.html +1 -1
  183. package/docs/flattenToConn.mjs.html +1 -1
  184. package/docs/flattenTree.mjs.html +1 -1
  185. package/docs/floor.mjs.html +1 -1
  186. package/docs/fsBuildReadStreamText.mjs.html +1 -1
  187. package/docs/fsBuildWriteStreamText.mjs.html +1 -1
  188. package/docs/fsCleanFolder.mjs.html +1 -1
  189. package/docs/fsCleanFolderCore.mjs.html +1 -1
  190. package/docs/fsCopyFile.mjs.html +1 -1
  191. package/docs/fsCopyFileCore.mjs.html +1 -1
  192. package/docs/fsCopyFolder.mjs.html +1 -1
  193. package/docs/fsCopyFolderCore.mjs.html +1 -1
  194. package/docs/fsCreateFile.mjs.html +1 -1
  195. package/docs/fsCreateFileCore.mjs.html +1 -1
  196. package/docs/fsCreateFolder.mjs.html +1 -1
  197. package/docs/fsCreateFolderCore.mjs.html +1 -1
  198. package/docs/fsDeleteFile.mjs.html +1 -1
  199. package/docs/fsDeleteFileCore.mjs.html +1 -1
  200. package/docs/fsDeleteFileSafe.mjs.html +1 -1
  201. package/docs/fsDeleteFileSafeCore.mjs.html +1 -1
  202. package/docs/fsDeleteFolder.mjs.html +1 -1
  203. package/docs/fsDeleteFolderCore.mjs.html +1 -1
  204. package/docs/fsDeleteFolderSafe.mjs.html +1 -1
  205. package/docs/fsDeleteFolderSafeCore.mjs.html +1 -1
  206. package/docs/fsDownloadFile.mjs.html +1 -1
  207. package/docs/fsDownloadFileCore.mjs.html +1 -1
  208. package/docs/fsEvem.mjs.html +1 -1
  209. package/docs/fsExists.mjs.html +1 -1
  210. package/docs/fsExistsCore.mjs.html +1 -1
  211. package/docs/fsGetFileBasicHash.mjs.html +1 -1
  212. package/docs/fsGetFileBasicHashCore.mjs.html +1 -1
  213. package/docs/fsGetFileHash.mjs.html +1 -1
  214. package/docs/fsGetFileHashCore.mjs.html +1 -1
  215. package/docs/fsGetFileXxHash.mjs.html +1 -1
  216. package/docs/fsGetFileXxHashCore.mjs.html +1 -1
  217. package/docs/fsGetFilesInFolder.mjs.html +1 -1
  218. package/docs/fsGetFilesInFolderCore.mjs.html +1 -1
  219. package/docs/fsGetFilesWithHashInFolder.mjs.html +1 -1
  220. package/docs/fsGetFilesWithHashInFolderCore.mjs.html +1 -1
  221. package/docs/fsGetFolderBasicHash.mjs.html +1 -1
  222. package/docs/fsGetFolderBasicHashCore.mjs.html +1 -1
  223. package/docs/fsGetFoldersInFolder.mjs.html +1 -1
  224. package/docs/fsGetFoldersInFolderCore.mjs.html +1 -1
  225. package/docs/fsIsFile.mjs.html +1 -1
  226. package/docs/fsIsFileCore.mjs.html +1 -1
  227. package/docs/fsIsFolder.mjs.html +1 -1
  228. package/docs/fsIsFolderCore.mjs.html +1 -1
  229. package/docs/fsMergeFiles.mjs.html +1 -1
  230. package/docs/fsMergeFilesCore.mjs.html +1 -1
  231. package/docs/fsReadJson.mjs.html +1 -1
  232. package/docs/fsReadText.mjs.html +1 -1
  233. package/docs/fsReadTextCore.mjs.html +1 -1
  234. package/docs/fsRenameFile.mjs.html +1 -1
  235. package/docs/fsRenameFileCore.mjs.html +1 -1
  236. package/docs/fsRenameFolder.mjs.html +1 -1
  237. package/docs/fsRenameFolderCore.mjs.html +1 -1
  238. package/docs/fsSrlog.mjs.html +1 -1
  239. package/docs/fsSyncFolder.mjs.html +1 -1
  240. package/docs/fsSyncFolderCore.mjs.html +1 -1
  241. package/docs/fsTask.mjs.html +1 -1
  242. package/docs/fsTaskCp.mjs.html +1 -1
  243. package/docs/fsTreeFolder.mjs.html +1 -1
  244. package/docs/fsTreeFolderCore.mjs.html +1 -1
  245. package/docs/fsTreeFolderWithHash.mjs.html +1 -1
  246. package/docs/fsTreeFolderWithHashCore.mjs.html +1 -1
  247. package/docs/fsWatchFile.mjs.html +1 -1
  248. package/docs/fsWatchFolder.mjs.html +1 -1
  249. package/docs/fsWriteJson.mjs.html +1 -1
  250. package/docs/fsWriteText.mjs.html +1 -1
  251. package/docs/fsWriteTextCore.mjs.html +1 -1
  252. package/docs/genGradientColor.mjs.html +1 -1
  253. package/docs/genID.mjs.html +1 -1
  254. package/docs/genIDSeq.mjs.html +1 -1
  255. package/docs/genPm.mjs.html +1 -1
  256. package/docs/getBufferSize.mjs.html +1 -1
  257. package/docs/getClearPathName.mjs.html +1 -1
  258. package/docs/getCsvStrFromData.mjs.html +1 -1
  259. package/docs/getDataFromExcelFileU8Arr.mjs.html +1 -1
  260. package/docs/getDataFromExcelFileU8ArrDyn.mjs.html +1 -1
  261. package/docs/getEnv.mjs.html +1 -1
  262. package/docs/getErrorMessage.mjs.html +1 -1
  263. package/docs/getExcelU8ArrFromData.mjs.html +1 -1
  264. package/docs/getExcelU8ArrFromWorkbook.mjs.html +1 -1
  265. package/docs/getExcelWorkbookFromData.mjs.html +1 -1
  266. package/docs/getExcelWorkbookFromWorksheet.mjs.html +1 -1
  267. package/docs/getExcelWorksheetFromData.mjs.html +1 -1
  268. package/docs/getFileAccept.mjs.html +1 -1
  269. package/docs/getFileBasicHash.mjs.html +1 -1
  270. package/docs/getFileHash.mjs.html +1 -1
  271. package/docs/getFileName.mjs.html +1 -1
  272. package/docs/getFileNameExt.mjs.html +1 -1
  273. package/docs/getFileTrueName.mjs.html +1 -1
  274. package/docs/getFileType.mjs.html +1 -1
  275. package/docs/getFileXxHash.mjs.html +1 -1
  276. package/docs/getGlobal.mjs.html +1 -1
  277. package/docs/getObjSize.mjs.html +1 -1
  278. package/docs/getPathParent.mjs.html +1 -1
  279. package/docs/getTimeBetween.mjs.html +1 -1
  280. package/docs/getTimeFromUnit.mjs.html +1 -1
  281. package/docs/getTimeHp.mjs.html +1 -1
  282. package/docs/getTimeObject.mjs.html +1 -1
  283. package/docs/getTimeRange.mjs.html +1 -1
  284. package/docs/getUserAgent.mjs.html +1 -1
  285. package/docs/getUserAgentDyn.mjs.html +1 -1
  286. package/docs/getltdtkeys.mjs.html +1 -1
  287. package/docs/global.html +1 -1
  288. package/docs/haskey.mjs.html +1 -1
  289. package/docs/html2str.mjs.html +1 -1
  290. package/docs/htmlDecode.mjs.html +1 -1
  291. package/docs/htmlEncode.mjs.html +1 -1
  292. package/docs/importResources.mjs.html +1 -1
  293. package/docs/index.html +1 -1
  294. package/docs/interp1.mjs.html +1 -1
  295. package/docs/isDate.mjs.html +1 -1
  296. package/docs/isDev.mjs.html +1 -1
  297. package/docs/isEle.mjs.html +1 -1
  298. package/docs/isEleExistByID.mjs.html +1 -1
  299. package/docs/isEmail.mjs.html +1 -1
  300. package/docs/isErr.mjs.html +1 -1
  301. package/docs/isIE.mjs.html +1 -1
  302. package/docs/isNarrow.mjs.html +1 -1
  303. package/docs/isStrHasCapital.mjs.html +1 -1
  304. package/docs/isStrHasLetter.mjs.html +1 -1
  305. package/docs/isStrHasLowerCase.mjs.html +1 -1
  306. package/docs/isStrHasNumber.mjs.html +1 -1
  307. package/docs/isStrHasSpace.mjs.html +1 -1
  308. package/docs/isStrHasSymbol.mjs.html +1 -1
  309. package/docs/isUserIdentify.mjs.html +1 -1
  310. package/docs/isUserName.mjs.html +1 -1
  311. package/docs/isUserPw.mjs.html +1 -1
  312. package/docs/isWindow.mjs.html +1 -1
  313. package/docs/isab.mjs.html +1 -1
  314. package/docs/isarr.mjs.html +1 -1
  315. package/docs/isarr0.mjs.html +1 -1
  316. package/docs/isarr1.mjs.html +1 -1
  317. package/docs/isbigint.mjs.html +1 -1
  318. package/docs/isblob.mjs.html +42 -23
  319. package/docs/isbol.mjs.html +1 -1
  320. package/docs/isday.mjs.html +1 -1
  321. package/docs/isearr.mjs.html +1 -1
  322. package/docs/iseobj.mjs.html +1 -1
  323. package/docs/iser.mjs.html +1 -1
  324. package/docs/isernot.mjs.html +1 -1
  325. package/docs/isestr.mjs.html +1 -1
  326. package/docs/isfile.mjs.html +2 -2
  327. package/docs/isfun.mjs.html +1 -1
  328. package/docs/isint.mjs.html +1 -1
  329. package/docs/ismonth.mjs.html +1 -1
  330. package/docs/isn0int.mjs.html +1 -1
  331. package/docs/isn0num.mjs.html +1 -1
  332. package/docs/isnan.mjs.html +1 -1
  333. package/docs/isnbr.mjs.html +1 -1
  334. package/docs/isnint.mjs.html +1 -1
  335. package/docs/isnnum.mjs.html +1 -1
  336. package/docs/isnull.mjs.html +1 -1
  337. package/docs/isnum.mjs.html +1 -1
  338. package/docs/isobj.mjs.html +1 -1
  339. package/docs/isobj0.mjs.html +1 -1
  340. package/docs/isp0int.mjs.html +1 -1
  341. package/docs/isp0num.mjs.html +1 -1
  342. package/docs/ispint.mjs.html +1 -1
  343. package/docs/ispm.mjs.html +1 -1
  344. package/docs/ispnum.mjs.html +1 -1
  345. package/docs/isstr.mjs.html +1 -1
  346. package/docs/isstr0.mjs.html +1 -1
  347. package/docs/istime.mjs.html +1 -1
  348. package/docs/istimeTZ.mjs.html +1 -1
  349. package/docs/istimems.mjs.html +1 -1
  350. package/docs/istimemsTZ.mjs.html +1 -1
  351. package/docs/isu16arr.mjs.html +1 -1
  352. package/docs/isu8arr.mjs.html +1 -1
  353. package/docs/isundefined.mjs.html +1 -1
  354. package/docs/j2o.mjs.html +1 -1
  355. package/docs/judge.mjs.html +1 -1
  356. package/docs/keysmat2ltdt.mjs.html +1 -1
  357. package/docs/ltdt2vrtsable.mjs.html +1 -1
  358. package/docs/ltdtDiff.mjs.html +1 -1
  359. package/docs/ltdtDiffByKey.mjs.html +1 -1
  360. package/docs/ltdtkeys2mat.mjs.html +1 -1
  361. package/docs/ltdtkeysheads2mat.mjs.html +1 -1
  362. package/docs/ltdtmapping.mjs.html +1 -1
  363. package/docs/ltdtmerge.mjs.html +1 -1
  364. package/docs/ltdtpick.mjs.html +1 -1
  365. package/docs/ltdtpull.mjs.html +1 -1
  366. package/docs/mat2ltdt.mjs.html +1 -1
  367. package/docs/matConcat.mjs.html +1 -1
  368. package/docs/matDiff.mjs.html +1 -1
  369. package/docs/matat.mjs.html +1 -1
  370. package/docs/now2str.mjs.html +1 -1
  371. package/docs/now2strp.mjs.html +1 -1
  372. package/docs/nowDay2str.mjs.html +1 -1
  373. package/docs/nowms2str.mjs.html +1 -1
  374. package/docs/nowms2strp.mjs.html +1 -1
  375. package/docs/o2j.mjs.html +1 -1
  376. package/docs/obj2b64.mjs.html +1 -1
  377. package/docs/obj2pb64.mjs.html +1 -1
  378. package/docs/obj2str.mjs.html +1 -1
  379. package/docs/obj2stru8arr.mjs.html +1 -1
  380. package/docs/obj2u8arr.mjs.html +1 -1
  381. package/docs/objSortBy.mjs.html +1 -1
  382. package/docs/objSortByKeys.mjs.html +1 -1
  383. package/docs/oo.mjs.html +1 -1
  384. package/docs/openLink.mjs.html +1 -1
  385. package/docs/pb642obj.mjs.html +1 -1
  386. package/docs/pmChain.mjs.html +1 -1
  387. package/docs/pmConvertResolve.mjs.html +1 -1
  388. package/docs/pmDebounce.mjs.html +1 -1
  389. package/docs/pmHook.mjs.html +1 -1
  390. package/docs/pmHookReject.mjs.html +1 -1
  391. package/docs/pmIni.mjs.html +1 -1
  392. package/docs/pmInvResolve.mjs.html +1 -1
  393. package/docs/pmKeyMutex.mjs.html +1 -1
  394. package/docs/pmMap.mjs.html +1 -1
  395. package/docs/pmQueue.mjs.html +1 -1
  396. package/docs/pmSeries.mjs.html +1 -1
  397. package/docs/pmThrottle.mjs.html +1 -1
  398. package/docs/pmTimeout.mjs.html +1 -1
  399. package/docs/preciseNum.mjs.html +1 -1
  400. package/docs/pseudoRandom.mjs.html +1 -1
  401. package/docs/pseudoRandomIntRange.mjs.html +1 -1
  402. package/docs/pseudoRandomIntsNdpRange.mjs.html +1 -1
  403. package/docs/pseudoRandomIntsRange.mjs.html +1 -1
  404. package/docs/pseudoRandomRange.mjs.html +1 -1
  405. package/docs/pseudoRandomsRange.mjs.html +1 -1
  406. package/docs/queue.mjs.html +1 -1
  407. package/docs/random.mjs.html +1 -1
  408. package/docs/randomIntRange.mjs.html +1 -1
  409. package/docs/randomIntsNdpRange.mjs.html +1 -1
  410. package/docs/randomIntsRange.mjs.html +1 -1
  411. package/docs/randomRange.mjs.html +1 -1
  412. package/docs/randomsRange.mjs.html +1 -1
  413. package/docs/rang.mjs.html +1 -1
  414. package/docs/rep.mjs.html +1 -1
  415. package/docs/repObj.mjs.html +1 -1
  416. package/docs/replace.mjs.html +1 -1
  417. package/docs/replaceObj.mjs.html +1 -1
  418. package/docs/replacePlus.mjs.html +1 -1
  419. package/docs/round.mjs.html +1 -1
  420. package/docs/secd.mjs.html +1 -1
  421. package/docs/sep.mjs.html +1 -1
  422. package/docs/sepInt.mjs.html +1 -1
  423. package/docs/setIntervalHp.mjs.html +1 -1
  424. package/docs/setTimeoutHp.mjs.html +1 -1
  425. package/docs/sind.mjs.html +1 -1
  426. package/docs/split.mjs.html +1 -1
  427. package/docs/str2aes.mjs.html +1 -1
  428. package/docs/str2b64.mjs.html +1 -1
  429. package/docs/str2hint.mjs.html +1 -1
  430. package/docs/str2md5.mjs.html +1 -1
  431. package/docs/str2obj.mjs.html +1 -1
  432. package/docs/str2sha.mjs.html +1 -1
  433. package/docs/str2sha512.mjs.html +1 -1
  434. package/docs/str2u8arr.mjs.html +1 -1
  435. package/docs/strCompare.mjs.html +1 -1
  436. package/docs/strCompareForVersion.mjs.html +1 -1
  437. package/docs/strDiff.mjs.html +1 -1
  438. package/docs/strDiffToHtml.mjs.html +1 -1
  439. package/docs/strFindFuzz.mjs.html +1 -1
  440. package/docs/strFindSimilar.mjs.html +1 -1
  441. package/docs/strTruncate.mjs.html +1 -1
  442. package/docs/strdelleft.mjs.html +1 -1
  443. package/docs/strdelright.mjs.html +1 -1
  444. package/docs/strleft.mjs.html +1 -1
  445. package/docs/strmid.mjs.html +1 -1
  446. package/docs/strright.mjs.html +1 -1
  447. package/docs/stru8arr2obj.mjs.html +1 -1
  448. package/docs/tand.mjs.html +1 -1
  449. package/docs/time2day.mjs.html +1 -1
  450. package/docs/time2hour.mjs.html +1 -1
  451. package/docs/time2min.mjs.html +1 -1
  452. package/docs/timeTZ2day.mjs.html +1 -1
  453. package/docs/timeTZ2expire.mjs.html +1 -1
  454. package/docs/timeTZ2hour.mjs.html +1 -1
  455. package/docs/timeTZ2min.mjs.html +1 -1
  456. package/docs/timeTZ2past.mjs.html +1 -1
  457. package/docs/timems2day.mjs.html +1 -1
  458. package/docs/timems2hour.mjs.html +1 -1
  459. package/docs/timems2min.mjs.html +1 -1
  460. package/docs/timems2time.mjs.html +1 -1
  461. package/docs/timemsTZ2day.mjs.html +1 -1
  462. package/docs/timemsTZ2expire.mjs.html +1 -1
  463. package/docs/timemsTZ2hour.mjs.html +1 -1
  464. package/docs/timemsTZ2min.mjs.html +1 -1
  465. package/docs/timemsTZ2past.mjs.html +1 -1
  466. package/docs/timemsTZ2time.mjs.html +1 -1
  467. package/docs/treeObj.mjs.html +1 -1
  468. package/docs/treeToFilepath.mjs.html +1 -1
  469. package/docs/trim.mjs.html +1 -1
  470. package/docs/u16arr2b64.mjs.html +1 -1
  471. package/docs/u16arr2u8arr.mjs.html +1 -1
  472. package/docs/u8arr2ab.mjs.html +1 -1
  473. package/docs/u8arr2b64.mjs.html +1 -1
  474. package/docs/u8arr2blob.mjs.html +1 -1
  475. package/docs/u8arr2bs.mjs.html +1 -1
  476. package/docs/u8arr2obj.mjs.html +1 -1
  477. package/docs/u8arr2str.mjs.html +1 -1
  478. package/docs/u8arr2u16arr.mjs.html +1 -1
  479. package/docs/urlParse.mjs.html +1 -1
  480. package/docs/verifyValue.mjs.html +1 -1
  481. package/docs/waitFun.mjs.html +1 -1
  482. package/docs/wsemi.html +66 -11
  483. package/package.json +1 -1
  484. package/src/_getDiff2Html.mjs +44 -38
  485. package/src/domDragBarAndScroll.mjs +475 -332
  486. package/src/isblob.mjs +41 -22
  487. package/src/isfile.mjs +1 -1
  488. package/test/_getDiff2Html.test.mjs +56 -0
  489. package/test/blob2ab.test.mjs +6 -0
  490. package/test/domDragBarAndScroll.test.mjs +1163 -11
  491. package/test/isblob.test.mjs +28 -1
  492. package/test/isfile.test.mjs +11 -1
  493. package/toolfp/dist/wsemip.umd.js +2 -2
  494. package/toolg/gDistRollup.mjs +2 -0
  495. package/toolparfor/dist/wpf.umd.js +1 -1
  496. package/toolparfor/dist/wpf_pmSeries.umd.js +1 -1
@@ -1,332 +1,475 @@
1
- import get from 'lodash-es/get.js'
2
- import isBoolean from 'lodash-es/isBoolean.js'
3
- import isFunction from 'lodash-es/isFunction.js'
4
- import evem from './evem.mjs'
5
- import domCancelEvent from './domCancelEvent.mjs'
6
-
7
-
8
- /**
9
- * 前端針對指定panel與bar的DOM元素監聽滾輪與拖曳bar事件
10
- *
11
- * Unit Test: {@link https://github.com/yuda-lyu/wsemi/blob/master/test/domDragBarAndScroll.test.mjs Github}
12
- * @memberOf wsemi
13
- * @param {HTMLElement} panel 輸入panel元素
14
- * @param {HTMLElement} bar 輸入bar元素
15
- * @param {Object} [opt={}] 輸入設定物件,預設{}
16
- * @param {Function} [getHeighRatio=()=>1] 輸入取得高度比例函數,因組件本身或內容物可能會調整尺寸, 故需由外部給予函數取得當前heighRatio,預設()=>1
17
- * @param {Function} [getWidthRatio=()=>1] 輸入取得寬度比例函數,因組件本身或內容物可能會調整尺寸, 故需由外部給予函數取得當前widthRatio,預設()=>1
18
- * @param {Boolean} [stopScrollPropagationForPanel=false] 輸入是否停用滑鼠捲動事件向上傳遞布林值,預設false
19
- * @param {Boolean} [stopTouchDragPropagationForPanel=false] 輸入是否停用手機拖曳事件向上傳遞布林值,預設false
20
- * @param {Boolean} [useTouchDragForPanel=true] 輸入是否使用手機拖曳事件布林值,預設true
21
- * @returns {Object} 回傳物件,可使用on與clear函數,on可監聽pressBar、dragBar、freeBar事件,clear為釋放監聽
22
- * @example
23
- * need test in browser
24
- *
25
- * //監聽dom
26
- * let divPanel = document.querySelector('#id_panel')
27
- * let divBar = document.querySelector('#id_bar')
28
- * let getHeighRatio = () => 0.9
29
- * let das = domDragBarAndScroll(divPanel, divBar, { getHeighRatio, stopScrollPropagationForPanel: true, stopTouchDragPropagationForPanel: true })
30
- * das.on('scrollPanel', () => {})
31
- * das.on('pressBar', () => {})
32
- * das.on('dragBar', () => {})
33
- * das.on('freeBar', () => {})
34
- *
35
- * //釋放監聽
36
- * das.clear()
37
- *
38
- */
39
- function domDragBarAndScroll(panel, bar, opt = {}) {
40
- let fPanelWheel = null
41
- let fPanelTouchstart = null
42
- let fPanelTouchmove = null
43
- let fPanelTouchend = null
44
- let fBarMousedown = null
45
- let fBarMouseup = null
46
- let fBarTouchstart = null
47
- let fBarTouchmove = null
48
- let fBarTouchend = null
49
- let fWindowMousemove = null
50
- let fWindowMouseup = null
51
- let fWindowScroll = null
52
- let fWindowWheel = null
53
- let fDocumentScroll = null
54
- let fDocumentWheel = null
55
- let barPressing = false
56
-
57
- //getHeighRatio, 因組件本身或內容物可能會調整尺寸, 故需由外部給予函數取得當前heighRatio
58
- let getHeighRatio = get(opt, 'getHeighRatio', null)
59
- if (!isFunction(getHeighRatio)) {
60
- getHeighRatio = () => 1
61
- }
62
-
63
- //getWidthRatio, 因組件本身或內容物可能會調整尺寸, 故需由外部給予函數取得當前widthRatio
64
- let getWidthRatio = get(opt, 'getWidthRatio', null)
65
- if (!isFunction(getWidthRatio)) {
66
- getWidthRatio = () => 1
67
- }
68
-
69
- //stopScrollPropagationForPanel
70
- let stopScrollPropagationForPanel = get(opt, 'stopScrollPropagationForPanel', null)
71
- if (!isBoolean(stopScrollPropagationForPanel)) {
72
- stopScrollPropagationForPanel = false
73
- }
74
-
75
- //stopTouchDragPropagationForPanel
76
- let stopTouchDragPropagationForPanel = get(opt, 'stopTouchDragPropagationForPanel', null)
77
- if (!isBoolean(stopTouchDragPropagationForPanel)) {
78
- stopTouchDragPropagationForPanel = false
79
- }
80
-
81
- //useTouchDragForPanel
82
- let useTouchDragForPanel = get(opt, 'useTouchDragForPanel', null)
83
- if (!isBoolean(useTouchDragForPanel)) {
84
- useTouchDragForPanel = true
85
- }
86
-
87
- //ele
88
- let elePanel = panel
89
- let eleBar = bar
90
-
91
- //ev
92
- let ev = evem()
93
-
94
- function add() {
95
-
96
- //fPanelWheel
97
- fPanelWheel = (e) => {
98
- let ry = e.deltaY / Math.abs(e.deltaY)
99
- let rx = e.deltaX / Math.abs(e.deltaX)
100
- ev.emit('scrollPanel', { ratioY: ry, ratioX: rx }) //寬版頁面, 用滾輪上下捲動, 實際是傳移動距離給bar
101
- if (stopScrollPropagationForPanel) {
102
- domCancelEvent(e) //要禁止外部元素如body被滑鼠捲動
103
- }
104
- }
105
- elePanel.addEventListener('wheel', fPanelWheel)
106
-
107
- //fPanelTouchstart
108
- fPanelTouchstart = (e) => {
109
- if (useTouchDragForPanel) {
110
-
111
- //acy, acx
112
- let acy = get(e, `touches.0.clientY`, 0)
113
- let acx = get(e, `touches.0.clientX`, 0)
114
-
115
- //cy, cx
116
- let cy = -acy * getHeighRatio()
117
- let cx = -acx * getWidthRatio()
118
-
119
- //barPressing
120
- barPressing = true
121
-
122
- //emit
123
- ev.emit('pressBar', { clientY: cy, clientX: cx }) //窄版頁面, 上鎖與紀錄頁面點擊y座標, 僅紀錄第一觸擊點座標, 另需被heighRatio修正比例
124
-
125
- //cancel
126
- if (stopTouchDragPropagationForPanel) {
127
- domCancelEvent(e)
128
- }
129
-
130
- }
131
- }
132
- elePanel.addEventListener('touchstart', fPanelTouchstart)
133
-
134
- //fPanelTouchmove
135
- fPanelTouchmove = (e) => {
136
- if (useTouchDragForPanel && barPressing) {
137
-
138
- //acy, acx
139
- let acy = get(e, `touches.0.clientY`, 0)
140
- let acx = get(e, `touches.0.clientX`, 0)
141
-
142
- // //check, 若水平向分量滑動較多, 則清空垂直向移動並結束
143
- // if (acx > 0 && acy > 0 && Math.abs(acx) >= Math.abs(acy)) {
144
- // e.touches[0].clientY = 0 //Cannot set property clientY of #<Touch> which has only a getter
145
- // return
146
- // }
147
-
148
- //cy, cx
149
- let cy = -acy * getHeighRatio()
150
- let cx = -acx * getWidthRatio()
151
-
152
- //emit
153
- ev.emit('dragBar', { clientY: cy, clientX: cx }) //窄版頁面, 用滑動距離拖曳頁面, 實際是傳移動距離給bar, 僅紀錄第一觸擊點座標, 另需被heighRatio修正比例
154
-
155
- //cancel
156
- if (stopTouchDragPropagationForPanel) {
157
- domCancelEvent(e) //要禁止外部元素如body被拖曳移動畫面, 此會導致無法左右拖曳元素(導致開啟overflow-x:auto無法使用)
158
- }
159
-
160
- }
161
- }
162
- elePanel.addEventListener('touchmove', fPanelTouchmove, { passive: false }) //必須使用passive=false否則無法cancel
163
-
164
- //fPanelTouchend
165
- fPanelTouchend = (e) => {
166
- if (useTouchDragForPanel && barPressing) {
167
-
168
- //barPressing
169
- barPressing = false
170
-
171
- //emit
172
- ev.emit('freeBar') //窄版頁面, 解鎖
173
-
174
- //cancel
175
- if (stopTouchDragPropagationForPanel) {
176
- domCancelEvent(e)
177
- }
178
-
179
- }
180
- }
181
- elePanel.addEventListener('touchend', fPanelTouchend)
182
-
183
- //fBarMousedown
184
- fBarMousedown = (e) => {
185
- barPressing = true
186
- ev.emit('pressBar', { clientY: e.clientY, clientX: e.clientX }) //寬版bar, 上鎖與紀錄點擊y座標
187
- //domCancelEvent(e)
188
- }
189
- eleBar.addEventListener('mousedown', fBarMousedown)
190
-
191
- //fBarMouseup, 可由fWindowMouseup自動解鎖, 不過若嵌入panel有攔截mouseup事件(例如popup)會導致外面window收不到mouseup事件, 故bar的mouseup事件仍需要監聽處理解鎖行為
192
- fBarMouseup = (e) => {
193
- if (barPressing) {
194
- barPressing = false
195
- ev.emit('freeBar') //窄版bar, 解鎖
196
- //domCancelEvent(e)
197
- }
198
- }
199
- eleBar.addEventListener('mouseup', fBarMouseup)
200
-
201
- //fBarTouchstart
202
- fBarTouchstart = (e) => {
203
- barPressing = true
204
- ev.emit('pressBar', { clientY: e.touches[0].clientY, clientX: e.touches[0].clientX }) //窄版bar, 上鎖與紀錄bar點擊y座標
205
- //domCancelEvent(e)
206
- }
207
- eleBar.addEventListener('touchstart', fBarTouchstart)
208
-
209
- //fBarTouchmove
210
- fBarTouchmove = (e) => {
211
- if (barPressing) {
212
- ev.emit('dragBar', { clientY: e.touches[0].clientY, clientX: e.touches[0].clientX }) //窄版bar, 用滑動距離拖曳bar, 實際是傳移動距離給bar
213
- domCancelEvent(e) //要禁止外部元素如body被拖曳移動畫面
214
- }
215
- }
216
- eleBar.addEventListener('touchmove', fBarTouchmove, { passive: false }) //必須使用passive=false否則無法cancel
217
-
218
- //fBarTouchend
219
- fBarTouchend = (e) => {
220
- if (barPressing) {
221
- barPressing = false
222
- ev.emit('freeBar') //窄版bar, 解鎖
223
- //domCancelEvent(e)
224
- }
225
- }
226
- eleBar.addEventListener('touchend', fBarTouchend)
227
-
228
- //fWindowMousemove
229
- fWindowMousemove = (e) => {
230
- if (barPressing) {
231
- ev.emit('dragBar', { clientY: e.clientY, clientX: e.clientX }) //寬版bar, 用鎖與滑動距離拖曳bar
232
- //domCancelEvent(e)
233
- }
234
- }
235
- window.addEventListener('mousemove', fWindowMousemove)
236
-
237
- //fWindowMouseup
238
- fWindowMouseup = (e) => {
239
- if (barPressing) {
240
- barPressing = false
241
- ev.emit('freeBar') //寬版bar, 解鎖
242
- if (stopScrollPropagationForPanel) {
243
- domCancelEvent(e) //要禁止回傳否則會連外部body捲軸一起移動畫面
244
- }
245
- }
246
- }
247
- window.addEventListener('mouseup', fWindowMouseup)
248
-
249
- //fWindowScroll
250
- fWindowScroll = (e) => {
251
- // if (barPressing) {
252
- // console.log('cancel window scroll')
253
- // //若已經為滑鼠捲動或觸控拖曳時, 則取消傳遞至外部的scroll事件, 避免例如手機拖曳觸底時會另外呼叫window的scroll事件
254
- // //此事件無法取消(cancelable=false), 即便使用passive=false
255
- // domCancelEvent(e)
256
- // }
257
- }
258
- window.addEventListener('scroll', fWindowScroll, { passive: false })
259
-
260
- //fWindowWheel
261
- fWindowWheel = (e) => {
262
- // if (barPressing) {
263
- // console.log('cancel window wheel')
264
- // //若已經為滑鼠捲動或觸控拖曳時, 則取消傳遞至外部的scroll事件, 避免例如手機拖曳觸底時會另外呼叫window的scroll事件
265
- // //此事件無法取消(cancelable=false), 即便使用passive=false
266
- // domCancelEvent(e)
267
- // }
268
- }
269
- window.addEventListener('wheel', fWindowWheel, { passive: false })
270
-
271
- //fDocumentScroll
272
- fDocumentScroll = (e) => {
273
- // if (barPressing) {
274
- // console.log('cancel document scroll')
275
- // //若已經為滑鼠捲動或觸控拖曳時, 則取消傳遞至外部的scroll事件, 避免例如手機拖曳觸底時會另外呼叫window的scroll事件
276
- // //此事件無法取消(cancelable=false), 即便使用passive=false
277
- // domCancelEvent(e)
278
- // }
279
- }
280
- document.addEventListener('scroll', fDocumentScroll, { passive: false })
281
-
282
- //fDocumentWheel
283
- fDocumentWheel = (e) => {
284
- // if (barPressing) {
285
- // console.log('cancel document wheel')
286
- // //若已經為滑鼠捲動或觸控拖曳時, 則取消傳遞至外部的scroll事件, 避免例如手機拖曳觸底時會另外呼叫window的scroll事件
287
- // //此事件無法取消(cancelable=false), 即便使用passive=false
288
- // domCancelEvent(e)
289
- // }
290
- }
291
- document.addEventListener('wheel', fDocumentWheel, { passive: false })
292
-
293
- }
294
-
295
- function clear() {
296
-
297
- //elePanel remove wheel, touchstart, touchmove, touchend
298
- elePanel.removeEventListener('wheel', fPanelWheel)
299
- elePanel.removeEventListener('touchstart', fPanelTouchstart)
300
- elePanel.removeEventListener('touchmove', fPanelTouchmove)
301
- elePanel.removeEventListener('touchend', fPanelTouchend)
302
-
303
- //eleBar remove mousedown, mouseup, touchstart, touchmove, touchend
304
- eleBar.removeEventListener('mousedown', fBarMousedown)
305
- eleBar.removeEventListener('mouseup', fBarMouseup)
306
- eleBar.removeEventListener('touchstart', fBarTouchstart)
307
- eleBar.removeEventListener('touchmove', fBarTouchmove)
308
- eleBar.removeEventListener('touchend', fBarTouchend)
309
-
310
- //window remove mousemove, mouseup, wheel
311
- window.removeEventListener('mousemove', fWindowMousemove)
312
- window.removeEventListener('mouseup', fWindowMouseup)
313
- window.removeEventListener('scroll', fWindowScroll)
314
- window.removeEventListener('wheel', fWindowWheel)
315
-
316
- //document remove scroll, wheel
317
- document.removeEventListener('scroll', fDocumentScroll)
318
- document.removeEventListener('wheel', fDocumentWheel)
319
-
320
- }
321
-
322
- //add
323
- add()
324
-
325
- //save
326
- ev.clear = clear
327
-
328
- return ev
329
- }
330
-
331
-
332
- export default domDragBarAndScroll
1
+ import get from 'lodash-es/get.js'
2
+ import isBoolean from 'lodash-es/isBoolean.js'
3
+ import isFunction from 'lodash-es/isFunction.js'
4
+ import evem from './evem.mjs'
5
+ import domCancelEvent from './domCancelEvent.mjs'
6
+
7
+
8
+ /**
9
+ * 前端針對指定panel與bar的DOM元素監聽滾輪與拖曳bar事件
10
+ *
11
+ * 同時只服務一條通道(bar滑鼠、bar觸控、panel觸控),pressBar與freeBar恆成對,dragBar只出現於兩者之間。bar位於panel之內時,bar上起手之觸控只由bar通道處理,不因冒泡而重複發事件。bar通道發絕對座標,panel觸控通道發經比例縮放之相對位移,兩者語義不同
12
+ *
13
+ * 滑鼠僅主鍵可上鎖;拖出瀏覽器視窗外放開時收不到mouseup,回到視窗內移動時以buttons為0自我解鎖(以`new MouseEvent`合成mousemove時須自行給buttons,其預設值0會被視為已放開)。bar與window之mouseup刻意不判來源與按鍵,作為觸控通道遺失touchend時的最後救援。已上鎖時再按下主鍵視為接手,先替既有之鎖補發freeBar再發pressBar
14
+ *
15
+ * 觸控以起手那一指之identifier鎖定,其餘手指之落下、移動與放開皆不影響本次拖曳,手勢被系統中斷(touchcancel)時只解鎖不定值。起手元素於拖曳途中被移出DOM時(如消費端重繪bar之內容),瀏覽器不再把後續之touchmove與touchend送達bar,鎖因而殘留;下一次touchstart時以touches驗證起手指是否仍在,不在即視為殘鎖,先補發freeBar再重新上鎖。事件未帶足觸點資訊時(合成事件),有identifier者改自touches比對,無identifier者取第一點,無從判斷時一律採解鎖側
16
+ *
17
+ * 呼叫端須自備樣式:bar需`user-select:none`避免拖曳時選取文字,觸控場景另需`touch-action`避免瀏覽器接手捲動。拖曳期間勿重繪或移除bar內之元素,起手元素一旦脫離DOM,當次觸控拖曳即中斷(下一次觸控會自行復原)
18
+ *
19
+ * 已知限制:同一panel掛兩個實例時一次滾輪會各發一次scrollPanel;單指輕點bar時瀏覽器另會補發相容滑鼠事件,故pressBar與freeBar各發兩次;拖曳中呼叫clear只停止而不補發freeBar
20
+ *
21
+ * Unit Test: {@link https://github.com/yuda-lyu/wsemi/blob/master/test/domDragBarAndScroll.test.mjs Github}
22
+ * @memberOf wsemi
23
+ * @param {HTMLElement} panel 輸入panel元素
24
+ * @param {HTMLElement} bar 輸入bar元素
25
+ * @param {Object} [opt={}] 輸入設定物件,預設{}
26
+ * @param {Function} [opt.getHeighRatio=()=>1] 輸入取得高度比例函數,因組件本身或內容物可能會調整尺寸, 故需由外部給予函數取得當前heighRatio,預設()=>1
27
+ * @param {Function} [opt.getWidthRatio=()=>1] 輸入取得寬度比例函數,因組件本身或內容物可能會調整尺寸, 故需由外部給予函數取得當前widthRatio,預設()=>1
28
+ * @param {Boolean} [opt.stopScrollPropagationForPanel=false] 輸入是否停用滑鼠捲動事件向上傳遞布林值,預設false
29
+ * @param {Boolean} [opt.stopTouchDragPropagationForPanel=false] 輸入是否停用手機拖曳事件向上傳遞布林值,預設false
30
+ * @param {Boolean} [opt.useTouchDragForPanel=true] 輸入是否使用手機拖曳事件布林值,預設true
31
+ * @returns {Object} 回傳物件,可使用on與clear函數,on可監聽scrollPanel、pressBar、dragBar、freeBar事件,clear為釋放監聽。scrollPanel帶{ratioY,ratioX}為該軸之滾動方向(1、-1或0),pressBar與dragBar帶{clientY,clientX},freeBar不帶參數
32
+ * @example
33
+ * need test in browser
34
+ *
35
+ * //監聽dom
36
+ * let divPanel = document.querySelector('#id_panel')
37
+ * let divBar = document.querySelector('#id_bar')
38
+ * let getHeighRatio = () => 0.9
39
+ * let das = domDragBarAndScroll(divPanel, divBar, { getHeighRatio, stopScrollPropagationForPanel: true, stopTouchDragPropagationForPanel: true })
40
+ * das.on('scrollPanel', () => {})
41
+ * das.on('pressBar', () => {})
42
+ * das.on('dragBar', () => {})
43
+ * das.on('freeBar', () => {})
44
+ *
45
+ * //釋放監聽
46
+ * das.clear()
47
+ *
48
+ */
49
+ function domDragBarAndScroll(panel, bar, opt = {}) {
50
+
51
+ //getHeighRatio, 因組件本身或內容物可能會調整尺寸, 故需由外部給予函數取得當前heighRatio
52
+ let getHeighRatio = get(opt, 'getHeighRatio', null)
53
+ if (!isFunction(getHeighRatio)) {
54
+ getHeighRatio = () => 1
55
+ }
56
+
57
+ //getWidthRatio, 因組件本身或內容物可能會調整尺寸, 故需由外部給予函數取得當前widthRatio
58
+ let getWidthRatio = get(opt, 'getWidthRatio', null)
59
+ if (!isFunction(getWidthRatio)) {
60
+ getWidthRatio = () => 1
61
+ }
62
+
63
+ //stopScrollPropagationForPanel
64
+ let stopScrollPropagationForPanel = get(opt, 'stopScrollPropagationForPanel', null)
65
+ if (!isBoolean(stopScrollPropagationForPanel)) {
66
+ stopScrollPropagationForPanel = false
67
+ }
68
+
69
+ //stopTouchDragPropagationForPanel
70
+ let stopTouchDragPropagationForPanel = get(opt, 'stopTouchDragPropagationForPanel', null)
71
+ if (!isBoolean(stopTouchDragPropagationForPanel)) {
72
+ stopTouchDragPropagationForPanel = false
73
+ }
74
+
75
+ //useTouchDragForPanel
76
+ let useTouchDragForPanel = get(opt, 'useTouchDragForPanel', null)
77
+ if (!isBoolean(useTouchDragForPanel)) {
78
+ useTouchDragForPanel = true
79
+ }
80
+
81
+ //ele
82
+ let elePanel = panel
83
+ let eleBar = bar
84
+
85
+ //ev
86
+ let ev = evem()
87
+
88
+ //pressFrom, 目前上鎖之通道, 為'barMouse'、'barTouch'、'panelTouch'之一, 未上鎖時為''
89
+ let pressFrom = ''
90
+
91
+ //pressTouchId, 觸控通道之起手指identifier; 滑鼠通道, 或起手事件未帶identifier時為null
92
+ let pressTouchId = null
93
+
94
+ //listeners, 已掛上之監聽, clear時逐一移除, 使掛上與移除天然成對
95
+ let listeners = []
96
+
97
+ //evBarTouchstart, bar通道最近一次收到之touchstart事件, 供panel通道辨識冒泡上來之同一事件
98
+ let evBarTouchstart = null
99
+
100
+ //isLocked
101
+ function isLocked() {
102
+ return pressFrom !== ''
103
+ }
104
+
105
+ //lock, 上鎖之唯一寫法, 全部狀態成套設定
106
+ function lock(from, id) {
107
+ pressFrom = from
108
+ pressTouchId = (id === undefined) ? null : id
109
+ }
110
+
111
+ //unlock, 解鎖之唯一寫法, 全部狀態成套歸零
112
+ // 解鎖規則若手寫於各處, 任一處漏改即造成狀態殘留(如觸控起手後被mouseup打斷, 殘留之identifier會讓滑鼠通道永久失效)
113
+ function unlock() {
114
+ pressFrom = ''
115
+ pressTouchId = null
116
+ }
117
+
118
+ //press, 上鎖並發pressBar之唯一寫法
119
+ // 已上鎖時為接手既有之鎖, 先替該鎖補發freeBar, 使pressBar與freeBar恆成對; 狀態一律先於emit異動, 監聽器拋錯時才不會留下半套狀態
120
+ function press(from, id, msg) {
121
+ let taken = isLocked()
122
+ lock(from, id)
123
+ if (taken) {
124
+ ev.emit('freeBar')
125
+
126
+ //check, freeBar之監聽器內呼叫clear時已解鎖, 不得再發pressBar
127
+ if (!isLocked()) {
128
+ return
129
+ }
130
+
131
+ }
132
+ ev.emit('pressBar', msg)
133
+ }
134
+
135
+ //free, 解鎖並發freeBar之唯一寫法
136
+ function free() {
137
+ unlock()
138
+ ev.emit('freeBar')
139
+ }
140
+
141
+ //listen, 掛監聽之唯一寫法, 同步記錄供clear移除
142
+ function listen(target, type, fun, options) {
143
+ target.addEventListener(type, fun, options)
144
+ listeners.push({ target, type, fun })
145
+ }
146
+
147
+ //getSign, 取滾動方向; 不可用delta/Math.abs(delta), 一般滑鼠滾輪之deltaX恆為0, 該式會得NaN
148
+ function getSign(v) {
149
+ if (v > 0) {
150
+ return 1
151
+ }
152
+ if (v < 0) {
153
+ return -1
154
+ }
155
+ return 0
156
+ }
157
+
158
+ //getTouches, 取事件內指定之觸點清單, 無該清單或清單為空時回null
159
+ function getTouches(e, key) {
160
+ let ts = get(e, key, null)
161
+ if (!ts || !(ts.length > 0)) {
162
+ return null
163
+ }
164
+ return ts
165
+ }
166
+
167
+ //findTouch, 自觸點清單取指定identifier者, 無則回null
168
+ function findTouch(ts, id) {
169
+ for (let i = 0; i < ts.length; i++) {
170
+ let t = ts[i]
171
+ if (t && t.identifier === id) {
172
+ return t
173
+ }
174
+ }
175
+ return null
176
+ }
177
+
178
+ //getTouchNew, 取本次新落下之觸點, 無則回null
179
+ // changedTouches為本次變動者, touches為當前全部接觸點, 故起手須取前者; 合成事件可能只帶touches, 此時退而取之
180
+ function getTouchNew(e) {
181
+ let ts = getTouches(e, 'changedTouches')
182
+ if (ts === null) {
183
+ ts = getTouches(e, 'touches')
184
+ }
185
+ if (ts === null) {
186
+ return null
187
+ }
188
+ return ts[0] || null
189
+ }
190
+
191
+ //getTouchOwn, 取起手那一指, 本次事件與該指無關時回null
192
+ // changedTouches有內容時只認它, 不可再退至touches, 否則他指移動時會以起手指之舊座標重複發dragBar
193
+ function getTouchOwn(e) {
194
+ let ts = getTouches(e, 'changedTouches')
195
+ if (ts === null) {
196
+ ts = getTouches(e, 'touches')
197
+ }
198
+ if (ts === null) {
199
+ return null
200
+ }
201
+
202
+ //起手事件未帶identifier時無從比對, 沿用取第一點之行為
203
+ if (pressTouchId === null) {
204
+ return ts[0] || null
205
+ }
206
+
207
+ return findTouch(ts, pressTouchId)
208
+ }
209
+
210
+ //isTouchOwnReleased, 本次touchend或touchcancel是否為起手指放開或被取消
211
+ function isTouchOwnReleased(e) {
212
+
213
+ //起手事件未帶identifier時無從比對, 沿用任一touchend皆解鎖之行為
214
+ if (pressTouchId === null) {
215
+ return true
216
+ }
217
+
218
+ //changedTouches為本次放開或被取消者
219
+ let ts = getTouches(e, 'changedTouches')
220
+ if (ts !== null) {
221
+ return findTouch(ts, pressTouchId) !== null
222
+ }
223
+
224
+ //合成事件可能只帶touches(仍在接觸者), 起手指不在其中即已放開
225
+ ts = getTouches(e, 'touches')
226
+ if (ts !== null) {
227
+ return findTouch(ts, pressTouchId) === null
228
+ }
229
+
230
+ //無任何觸點資訊時採安全側, 寧可解鎖也不留殘鎖
231
+ return true
232
+ }
233
+
234
+ //isLockAlive, 觸控起手時既有之鎖是否仍有效; 無從證明有效者一律視為殘留, 寧可重新上鎖也不讓觸控就此失效
235
+ // 起手元素於拖曳途中被移出DOM時, 後續之touchmove與touchend不再送達, 鎖即殘留; 若一律忽略已上鎖時之touchstart, 觸控將無法再拖曳
236
+ function isLockAlive(e, t) {
237
+
238
+ //滑鼠之鎖無從由觸控事件驗證, 視為有效; 其殘留另由mousemove之buttons、mouseup與再次mousedown處理
239
+ if (pressFrom === 'barMouse') {
240
+ return true
241
+ }
242
+
243
+ //起手事件未帶identifier, 無從比對
244
+ if (pressTouchId === null) {
245
+ return false
246
+ }
247
+
248
+ //新落下者與起手指同identifier: 同時接觸之手指其identifier不重複, 故原起手指早已離開(Chrome與Firefox之identifier自0起重用)
249
+ if (t.identifier === pressTouchId) {
250
+ return false
251
+ }
252
+
253
+ //touches為當前全部接觸點, 起手指仍在其中才是有效之鎖(iOS之identifier不重用, 須靠此判定)
254
+ let ts = getTouches(e, 'touches')
255
+ if (ts === null) {
256
+ return false
257
+ }
258
+ return findTouch(ts, pressTouchId) !== null
259
+ }
260
+
261
+ //addMouseChannel, bar之滑鼠通道
262
+ function addMouseChannel() {
263
+
264
+ //mousedown
265
+ listen(eleBar, 'mousedown', (e) => {
266
+
267
+ //check, 只處理主鍵, 中鍵與右鍵不得上鎖; 以'button' in e判定使無button屬性之合成事件維持原本可上鎖之行為
268
+ if ('button' in e && e.button !== 0) {
269
+ return
270
+ }
271
+
272
+ //press, 已上鎖時亦接手: 滑鼠之鎖此時必為殘留(mouseup遺失且其間無mousemove), 觸控之鎖則以滑鼠為其救援通道
273
+ press('barMouse', null, { clientY: e.clientY, clientX: e.clientX }) //寬版bar, 上鎖與紀錄點擊y座標
274
+
275
+ })
276
+
277
+ //mouseup, 可由window之mouseup自動解鎖, 不過若嵌入panel有攔截mouseup事件(例如popup)會導致外面window收不到mouseup事件, 故bar的mouseup事件仍需要監聽處理解鎖行為
278
+ // 刻意不判來源與按鍵: 此為觸控通道遺失touchend時的最後救援, 與split.js、MUI之終止側作法一致
279
+ listen(eleBar, 'mouseup', () => {
280
+ if (isLocked()) {
281
+ free() //窄版bar, 解鎖
282
+ }
283
+ })
284
+
285
+ //mousemove
286
+ listen(window, 'mousemove', (e) => {
287
+
288
+ //check, 僅服務滑鼠通道; 觸控上鎖時不得以絕對座標發dragBar, 否則會污染panel通道之縮放座標語義
289
+ if (pressFrom !== 'barMouse') {
290
+ return
291
+ }
292
+
293
+ //check, 拖出瀏覽器視窗外放開時收不到mouseup, 回到視窗內移動時以buttons為0自我解鎖
294
+ if (e.buttons === 0) {
295
+ free()
296
+ return
297
+ }
298
+
299
+ //emit
300
+ ev.emit('dragBar', { clientY: e.clientY, clientX: e.clientX }) //寬版bar, 用鎖與滑動距離拖曳bar
301
+
302
+ })
303
+
304
+ //mouseup, 刻意不判來源與按鍵, 理由同bar之mouseup
305
+ listen(window, 'mouseup', (e) => {
306
+ if (!isLocked()) {
307
+ return
308
+ }
309
+
310
+ //cancel, 須先於emit, 否則監聽器拋錯時本行不會執行而漏擋
311
+ if (stopScrollPropagationForPanel) {
312
+ domCancelEvent(e) //要禁止回傳否則會連外部body捲軸一起移動畫面
313
+ }
314
+
315
+ free() //寬版bar, 解鎖
316
+
317
+ })
318
+
319
+ }
320
+
321
+ //addWheelChannel, panel之滾輪通道
322
+ // window與document之scroll與wheel不掛監聽: 曾嘗試於上鎖時取消該二者, 以避免手機拖曳觸底時連帶捲動外層頁面, 但其於該處無法取消(cancelable=false), 即便使用passive=false亦然
323
+ // 且Chrome對掛於window與document之wheel監聽預設視為passive以加速捲動, 明確給passive:false反會放棄該處理
324
+ function addWheelChannel() {
325
+ listen(elePanel, 'wheel', (e) => {
326
+
327
+ //cancel, 須先於emit, 否則監聽器拋錯時本行不會執行而漏擋
328
+ if (stopScrollPropagationForPanel) {
329
+ domCancelEvent(e) //要禁止外部元素如body被滑鼠捲動
330
+ }
331
+
332
+ //emit
333
+ ev.emit('scrollPanel', { ratioY: getSign(e.deltaY), ratioX: getSign(e.deltaX) }) //寬版頁面, 用滾輪上下捲動, 實際是傳移動方向給bar
334
+
335
+ })
336
+ }
337
+
338
+ //addTouchChannel, bar與panel之觸控通道除元素、座標語義與擋預設行為之時機外規則完全相同, 故共用同一組處理器, 每條規則只寫一處
339
+ function addTouchChannel(ele, from, getMsg, cancel) {
340
+
341
+ //touchstart
342
+ listen(ele, 'touchstart', (e) => {
343
+
344
+ //check, bar上起手之觸控只由bar通道處理; bar位於panel之內, bar上之touchstart會冒泡至panel, 若不擋則同一次觸控會發兩次pressBar且第二次為縮放座標
345
+ // 不可改以「已上鎖即忽略」判定: identifier重用時, 冒泡上來之同一事件與殘鎖後之新觸控無從區分
346
+ if (from === 'barTouch') {
347
+ evBarTouchstart = e
348
+ }
349
+ else if (e === evBarTouchstart) {
350
+ evBarTouchstart = null
351
+ return
352
+ }
353
+
354
+ //t, 無觸點時忽略, 不可直接取用而拋錯
355
+ let t = getTouchNew(e)
356
+ if (t === null) {
357
+ return
358
+ }
359
+
360
+ //check, 已上鎖且該鎖仍有效者為他指落下, 不得重新定錨; 該鎖為殘留者則由press接手
361
+ if (isLocked() && isLockAlive(e, t)) {
362
+ return
363
+ }
364
+
365
+ //cancel, 須先於getMsg與emit, 否則比例函數或監聽器拋錯時本行不會執行而漏擋
366
+ if (cancel.start) {
367
+ domCancelEvent(e)
368
+ }
369
+
370
+ //press
371
+ press(from, t.identifier, getMsg(t))
372
+
373
+ })
374
+
375
+ //touchmove
376
+ listen(ele, 'touchmove', (e) => {
377
+
378
+ //check, 通道互斥須為顯式判定, 不可依賴domCancelEvent之stopPropagation副作用(事件不可取消時該副作用不會發生)
379
+ if (pressFrom !== from) {
380
+ return
381
+ }
382
+
383
+ //cancel, 須先於起手指判定與emit, 否則他指移動或監聽器拋錯時本行不會執行, 拖曳期間頁面即可被捲動
384
+ if (cancel.move) {
385
+ domCancelEvent(e) //要禁止外部元素如body被拖曳移動畫面
386
+ }
387
+
388
+ //t, 非起手指之移動不得搶值
389
+ let t = getTouchOwn(e)
390
+ if (t === null) {
391
+ return
392
+ }
393
+
394
+ //emit
395
+ ev.emit('dragBar', getMsg(t))
396
+
397
+ }, { passive: false }) //必須使用passive=false否則無法cancel
398
+
399
+ //touchend與touchcancel共用, 兩者皆只解鎖不定值; touchcancel為手勢被系統中斷(如瀏覽器接手捲動、長按選單), 其座標不可信
400
+ // touchcancel依規範不可取消, domCancelEvent對其無作用
401
+ let funTouchend = (e) => {
402
+
403
+ //check
404
+ if (pressFrom !== from) {
405
+ return
406
+ }
407
+
408
+ //check, 非起手指放開或被取消不終止本次拖曳
409
+ if (!isTouchOwnReleased(e)) {
410
+ return
411
+ }
412
+
413
+ //cancel
414
+ if (cancel.end) {
415
+ domCancelEvent(e)
416
+ }
417
+
418
+ free()
419
+
420
+ }
421
+ listen(ele, 'touchend', funTouchend)
422
+ listen(ele, 'touchcancel', funTouchend)
423
+
424
+ }
425
+
426
+ function add() {
427
+
428
+ //addMouseChannel
429
+ addMouseChannel()
430
+
431
+ //addWheelChannel
432
+ addWheelChannel()
433
+
434
+ //addTouchChannel, 窄版bar, 發絕對座標; 拖曳期間一律禁止頁面被拖曳捲動, touchstart與touchend不擋, 否則輕點bar後瀏覽器不再產生click
435
+ addTouchChannel(eleBar, 'barTouch', (t) => {
436
+ return { clientY: t.clientY, clientX: t.clientX }
437
+ }, { start: false, move: true, end: false })
438
+
439
+ //addTouchChannel, 窄版頁面, 用滑動距離拖曳頁面, 實際是傳移動距離給bar, 僅取起手觸擊點座標, 另需被heighRatio與widthRatio修正比例
440
+ // 是否擋預設行為由旗標控制, 因擋下會導致無法左右拖曳元素(開啟overflow-x:auto者無法使用)
441
+ // 停用時不掛監聽, 避免panel平白多一個passive:false之touchmove監聽
442
+ if (useTouchDragForPanel) {
443
+ let b = stopTouchDragPropagationForPanel
444
+ addTouchChannel(elePanel, 'panelTouch', (t) => {
445
+ return { clientY: -t.clientY * getHeighRatio(), clientX: -t.clientX * getWidthRatio() }
446
+ }, { start: b, move: b, end: b })
447
+ }
448
+
449
+ }
450
+
451
+ function clear() {
452
+
453
+ //unlock, 釋放監聽時一併歸零狀態; 拖曳中呼叫時只停止, 不補發freeBar
454
+ unlock()
455
+ evBarTouchstart = null
456
+
457
+ //removeEventListener
458
+ for (let l of listeners) {
459
+ l.target.removeEventListener(l.type, l.fun)
460
+ }
461
+ listeners = []
462
+
463
+ }
464
+
465
+ //add
466
+ add()
467
+
468
+ //save
469
+ ev.clear = clear
470
+
471
+ return ev
472
+ }
473
+
474
+
475
+ export default domDragBarAndScroll