@clickview/library-editor 1.1.19-rc.2 → 1.1.19

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 (456) hide show
  1. package/dist/css/12.chunk.css +17 -7
  2. package/dist/css/13.chunk.css +7 -7
  3. package/dist/css/14.chunk.css +10 -4
  4. package/dist/css/16.chunk.css +1 -1
  5. package/dist/css/17.chunk.css +1 -1
  6. package/dist/css/19.chunk.css +34 -0
  7. package/dist/css/20.chunk.css +15 -7
  8. package/dist/css/21.chunk.css +14 -8
  9. package/dist/css/22.chunk.css +13 -5
  10. package/dist/css/23.chunk.css +12 -6
  11. package/dist/css/24.chunk.css +7 -7
  12. package/dist/css/25.chunk.css +9 -5
  13. package/dist/css/26.chunk.css +5 -5
  14. package/dist/css/27.chunk.css +6 -4
  15. package/dist/css/29.chunk.css +4 -4
  16. package/dist/css/3.chunk.css +2 -15
  17. package/dist/css/30.chunk.css +5 -3
  18. package/dist/css/31.chunk.css +3 -3
  19. package/dist/css/42.chunk.css +1 -1
  20. package/dist/css/43.chunk.css +1 -1
  21. package/dist/css/44.chunk.css +1 -1
  22. package/dist/css/45.chunk.css +1 -1
  23. package/dist/css/46.chunk.css +1 -1
  24. package/dist/css/47.chunk.css +1 -1
  25. package/dist/css/49.chunk.css +1 -34
  26. package/dist/css/5.chunk.css +3 -13
  27. package/dist/css/50.chunk.css +1 -1
  28. package/dist/css/53.chunk.css +2 -0
  29. package/dist/css/54.chunk.css +1 -1
  30. package/dist/css/55.chunk.css +1 -1
  31. package/dist/css/56.chunk.css +1 -1
  32. package/dist/css/57.chunk.css +1 -1
  33. package/dist/css/58.chunk.css +1 -1
  34. package/dist/css/60.chunk.css +1 -17
  35. package/dist/css/61.chunk.css +1 -1
  36. package/dist/projects/library-editor/src/app.d.ts +1 -0
  37. package/dist/scripts/0-2be1201a7f.chunk.js +1 -0
  38. package/dist/scripts/1-d3c96b4670.chunk.js +1 -0
  39. package/dist/scripts/10-2cebec08a5.chunk.js +1 -0
  40. package/dist/scripts/{11-805aab3b80.chunk.js → 11-f6440b4817.chunk.js} +1 -1
  41. package/dist/scripts/12-b168953b47.chunk.js +1 -0
  42. package/dist/scripts/13-8e3a8d1629.chunk.js +1 -0
  43. package/dist/scripts/14-1c1b7086df.chunk.js +1 -0
  44. package/dist/scripts/15-6df8e05fe9.chunk.js +1 -0
  45. package/dist/scripts/16-19085b3dd0.chunk.js +1 -0
  46. package/dist/scripts/17-b7c4c476aa.chunk.js +1 -0
  47. package/dist/scripts/19-affb19e639.chunk.js +1 -0
  48. package/dist/scripts/2-adb587d50b.chunk.js +1 -0
  49. package/dist/scripts/20-5dcf516232.chunk.js +1 -0
  50. package/dist/scripts/21-782b1e8947.chunk.js +1 -0
  51. package/dist/scripts/22-77a9f00273.chunk.js +1 -0
  52. package/dist/scripts/23-c380087827.chunk.js +1 -0
  53. package/dist/scripts/24-5ca282f342.chunk.js +1 -0
  54. package/dist/scripts/25-a595940248.chunk.js +1 -0
  55. package/dist/scripts/26-52d8ede81f.chunk.js +1 -0
  56. package/dist/scripts/27-00d6b5a4bd.chunk.js +1 -0
  57. package/dist/scripts/28-58cc01c876.chunk.js +1 -0
  58. package/dist/scripts/29-552493a7ad.chunk.js +1 -0
  59. package/dist/scripts/3-a32cc1fdf4.chunk.js +1 -0
  60. package/dist/scripts/30-3b0ed0fdaa.chunk.js +1 -0
  61. package/dist/scripts/31-d46eb161fa.chunk.js +1 -0
  62. package/dist/scripts/32-728cc1e053.chunk.js +1 -0
  63. package/dist/scripts/33-9f130fa663.chunk.js +1 -0
  64. package/dist/scripts/34-45ad8a1808.chunk.js +1 -0
  65. package/dist/scripts/35-38b73094a5.chunk.js +1 -0
  66. package/dist/scripts/36-6cc9b2e1f9.chunk.js +1 -0
  67. package/dist/scripts/37-18f74bd058.chunk.js +1 -0
  68. package/dist/scripts/38-ca9a95b14a.chunk.js +1 -0
  69. package/dist/scripts/39-21e6ce932e.chunk.js +1 -0
  70. package/dist/scripts/4-7f5573ad9d.chunk.js +1 -0
  71. package/dist/scripts/40-040a76d3cb.chunk.js +1 -0
  72. package/dist/scripts/41-ea0bd0118f.chunk.js +1 -0
  73. package/dist/scripts/42-ede0513e1c.chunk.js +1 -0
  74. package/dist/scripts/43-512f52a709.chunk.js +1 -0
  75. package/dist/scripts/44-2b494ad559.chunk.js +1 -0
  76. package/dist/scripts/45-74c1071058.chunk.js +1 -0
  77. package/dist/scripts/46-fa6537374c.chunk.js +1 -0
  78. package/dist/scripts/47-4fbd9bf958.chunk.js +1 -0
  79. package/dist/scripts/48-de58133c08.chunk.js +1 -0
  80. package/dist/scripts/49-4035147a3b.chunk.js +1 -0
  81. package/dist/scripts/5-08ffe0918e.chunk.js +1 -0
  82. package/dist/scripts/50-c2be46fa7e.chunk.js +1 -0
  83. package/dist/scripts/51-beb5c51318.chunk.js +1 -0
  84. package/dist/scripts/52-773e36d3f9.chunk.js +1 -0
  85. package/dist/scripts/{54-8df01312cc.chunk.js → 53-a5d949340b.chunk.js} +1 -1
  86. package/dist/scripts/54-4083e51a52.chunk.js +1 -0
  87. package/dist/scripts/55-622f7871d6.chunk.js +1 -0
  88. package/dist/scripts/56-b48e08b8ef.chunk.js +1 -0
  89. package/dist/scripts/57-1feff40a08.chunk.js +1 -0
  90. package/dist/scripts/{59-cc8e184cce.chunk.js → 58-46d9ab3567.chunk.js} +1 -1
  91. package/dist/scripts/59-4f532af025.chunk.js +1 -0
  92. package/dist/scripts/6-0aba54255e.chunk.js +1 -0
  93. package/dist/scripts/60-b977e9f98a.chunk.js +1 -0
  94. package/dist/scripts/61-a08050a033.chunk.js +1 -0
  95. package/dist/scripts/62-2d7c9575cd.chunk.js +1 -0
  96. package/dist/scripts/63-1b5541b59d.chunk.js +1 -0
  97. package/dist/scripts/64-5802c4c4a1.chunk.js +1 -0
  98. package/dist/scripts/65-a5583b77b5.chunk.js +1 -0
  99. package/dist/scripts/66-e6cbf6eff1.chunk.js +1 -0
  100. package/dist/scripts/67-147f6e38b8.chunk.js +1 -0
  101. package/dist/scripts/68-09d43f4bf6.chunk.js +1 -0
  102. package/dist/scripts/69-730a9f6e1b.chunk.js +1 -0
  103. package/dist/scripts/7-3a6b348c77.chunk.js +1 -0
  104. package/dist/scripts/70-99fa48a87e.chunk.js +1 -0
  105. package/dist/scripts/71-e6e4debb3b.chunk.js +1 -0
  106. package/dist/scripts/8-e6e81f44e1.chunk.js +1 -0
  107. package/dist/scripts/9-350230f5b4.chunk.js +1 -0
  108. package/dist/scripts/bundle-11b849726e.min.js +1 -0
  109. package/dist/scripts/bundle-185116e7ce.min.js +1 -0
  110. package/dist/scripts/bundles.json +1 -1
  111. package/package.json +4 -4
  112. package/dist/css/1.chunk.css.map +0 -1
  113. package/dist/css/10.chunk.css.map +0 -1
  114. package/dist/css/11.chunk.css +0 -137
  115. package/dist/css/11.chunk.css.map +0 -1
  116. package/dist/css/12.chunk.css.map +0 -1
  117. package/dist/css/13.chunk.css.map +0 -1
  118. package/dist/css/14.chunk.css.map +0 -1
  119. package/dist/css/16.chunk.css.map +0 -1
  120. package/dist/css/17.chunk.css.map +0 -1
  121. package/dist/css/18.chunk.css +0 -2
  122. package/dist/css/18.chunk.css.map +0 -1
  123. package/dist/css/2.chunk.css +0 -4
  124. package/dist/css/2.chunk.css.map +0 -1
  125. package/dist/css/21.chunk.css.map +0 -1
  126. package/dist/css/22.chunk.css.map +0 -1
  127. package/dist/css/23.chunk.css.map +0 -1
  128. package/dist/css/25.chunk.css.map +0 -1
  129. package/dist/css/26.chunk.css.map +0 -1
  130. package/dist/css/28.chunk.css.map +0 -1
  131. package/dist/css/29.chunk.css.map +0 -1
  132. package/dist/css/3.chunk.css.map +0 -1
  133. package/dist/css/30.chunk.css.map +0 -1
  134. package/dist/css/31.chunk.css.map +0 -1
  135. package/dist/css/32.chunk.css.map +0 -1
  136. package/dist/css/33.chunk.css +0 -16
  137. package/dist/css/33.chunk.css.map +0 -1
  138. package/dist/css/34.chunk.css +0 -21
  139. package/dist/css/34.chunk.css.map +0 -1
  140. package/dist/css/35.chunk.css +0 -20
  141. package/dist/css/35.chunk.css.map +0 -1
  142. package/dist/css/36.chunk.css.map +0 -1
  143. package/dist/css/37.chunk.css.map +0 -1
  144. package/dist/css/38.chunk.css.map +0 -1
  145. package/dist/css/4.chunk.css +0 -6
  146. package/dist/css/40.chunk.css.map +0 -1
  147. package/dist/css/41.chunk.css.map +0 -1
  148. package/dist/css/42.chunk.css.map +0 -1
  149. package/dist/css/43.chunk.css.map +0 -1
  150. package/dist/css/44.chunk.css.map +0 -1
  151. package/dist/css/45.chunk.css.map +0 -1
  152. package/dist/css/46.chunk.css.map +0 -1
  153. package/dist/css/47.chunk.css.map +0 -1
  154. package/dist/css/48.chunk.css +0 -2
  155. package/dist/css/48.chunk.css.map +0 -1
  156. package/dist/css/49.chunk.css.map +0 -1
  157. package/dist/css/50.chunk.css.map +0 -1
  158. package/dist/css/51.chunk.css +0 -2
  159. package/dist/css/51.chunk.css.map +0 -1
  160. package/dist/css/52.chunk.css +0 -66
  161. package/dist/css/52.chunk.css.map +0 -1
  162. package/dist/css/55.chunk.css.map +0 -1
  163. package/dist/css/56.chunk.css.map +0 -1
  164. package/dist/css/58.chunk.css.map +0 -1
  165. package/dist/css/59.chunk.css +0 -2
  166. package/dist/css/59.chunk.css.map +0 -1
  167. package/dist/css/6.chunk.css.map +0 -1
  168. package/dist/css/60.chunk.css.map +0 -1
  169. package/dist/css/62.chunk.css +0 -2
  170. package/dist/css/62.chunk.css.map +0 -1
  171. package/dist/css/63.chunk.css +0 -170
  172. package/dist/css/63.chunk.css.map +0 -1
  173. package/dist/css/67.chunk.css +0 -78
  174. package/dist/css/67.chunk.css.map +0 -1
  175. package/dist/css/68.chunk.css +0 -17
  176. package/dist/css/68.chunk.css.map +0 -1
  177. package/dist/css/69.chunk.css +0 -17
  178. package/dist/css/69.chunk.css.map +0 -1
  179. package/dist/css/7.chunk.css.map +0 -1
  180. package/dist/css/70.chunk.css +0 -23
  181. package/dist/css/70.chunk.css.map +0 -1
  182. package/dist/css/71.chunk.css +0 -40
  183. package/dist/css/71.chunk.css.map +0 -1
  184. package/dist/css/72.chunk.css +0 -16
  185. package/dist/css/72.chunk.css.map +0 -1
  186. package/dist/css/73.chunk.css +0 -37
  187. package/dist/css/73.chunk.css.map +0 -1
  188. package/dist/css/74.chunk.css +0 -29
  189. package/dist/css/74.chunk.css.map +0 -1
  190. package/dist/css/75.chunk.css +0 -6
  191. package/dist/css/75.chunk.css.map +0 -1
  192. package/dist/css/76.chunk.css +0 -6
  193. package/dist/css/76.chunk.css.map +0 -1
  194. package/dist/css/8.chunk.css.map +0 -1
  195. package/dist/css/library-editor-app.css.map +0 -1
  196. package/dist/scripts/0-8cdf48d69e.chunk.js +0 -1
  197. package/dist/scripts/0.chunk.js +0 -1034
  198. package/dist/scripts/0.chunk.js.map +0 -1
  199. package/dist/scripts/1-a197f0efeb.chunk.js +0 -1
  200. package/dist/scripts/1.chunk.js +0 -442
  201. package/dist/scripts/1.chunk.js.map +0 -1
  202. package/dist/scripts/10-48aa375ebe.chunk.js +0 -1
  203. package/dist/scripts/10.chunk.js +0 -820
  204. package/dist/scripts/10.chunk.js.map +0 -1
  205. package/dist/scripts/11.chunk.js +0 -4091
  206. package/dist/scripts/11.chunk.js.map +0 -1
  207. package/dist/scripts/12-57671136e8.chunk.js +0 -1
  208. package/dist/scripts/12.chunk.js +0 -555
  209. package/dist/scripts/12.chunk.js.map +0 -1
  210. package/dist/scripts/13-46bc40cc23.chunk.js +0 -1
  211. package/dist/scripts/13.chunk.js +0 -373
  212. package/dist/scripts/13.chunk.js.map +0 -1
  213. package/dist/scripts/14-556e982a73.chunk.js +0 -1
  214. package/dist/scripts/14.chunk.js +0 -2386
  215. package/dist/scripts/14.chunk.js.map +0 -1
  216. package/dist/scripts/15-2edbad42a0.chunk.js +0 -1
  217. package/dist/scripts/15.chunk.js +0 -314
  218. package/dist/scripts/15.chunk.js.map +0 -1
  219. package/dist/scripts/16-60b9a789b4.chunk.js +0 -1
  220. package/dist/scripts/16.chunk.js +0 -1290
  221. package/dist/scripts/16.chunk.js.map +0 -1
  222. package/dist/scripts/17-d6083dbd9b.chunk.js +0 -1
  223. package/dist/scripts/17.chunk.js +0 -381
  224. package/dist/scripts/17.chunk.js.map +0 -1
  225. package/dist/scripts/18-31ce9284d0.chunk.js +0 -1
  226. package/dist/scripts/18.chunk.js +0 -393
  227. package/dist/scripts/18.chunk.js.map +0 -1
  228. package/dist/scripts/19.chunk.js +0 -364
  229. package/dist/scripts/19.chunk.js.map +0 -1
  230. package/dist/scripts/2-33fcca96e3.chunk.js +0 -1
  231. package/dist/scripts/2.chunk.js +0 -519
  232. package/dist/scripts/2.chunk.js.map +0 -1
  233. package/dist/scripts/20-3c2f3fb166.chunk.js +0 -1
  234. package/dist/scripts/20.chunk.js +0 -317
  235. package/dist/scripts/20.chunk.js.map +0 -1
  236. package/dist/scripts/21-9497f03cd8.chunk.js +0 -1
  237. package/dist/scripts/21.chunk.js +0 -531
  238. package/dist/scripts/21.chunk.js.map +0 -1
  239. package/dist/scripts/22-22cd929ad4.chunk.js +0 -1
  240. package/dist/scripts/22.chunk.js +0 -354
  241. package/dist/scripts/22.chunk.js.map +0 -1
  242. package/dist/scripts/23-16b02d09f5.chunk.js +0 -1
  243. package/dist/scripts/23.chunk.js +0 -605
  244. package/dist/scripts/23.chunk.js.map +0 -1
  245. package/dist/scripts/24-24699f9007.chunk.js +0 -1
  246. package/dist/scripts/24.chunk.js +0 -318
  247. package/dist/scripts/24.chunk.js.map +0 -1
  248. package/dist/scripts/25-7a210f731b.chunk.js +0 -1
  249. package/dist/scripts/25.chunk.js +0 -365
  250. package/dist/scripts/25.chunk.js.map +0 -1
  251. package/dist/scripts/26-263cf0ebce.chunk.js +0 -1
  252. package/dist/scripts/26.chunk.js +0 -437
  253. package/dist/scripts/26.chunk.js.map +0 -1
  254. package/dist/scripts/27-707d8b29f0.chunk.js +0 -1
  255. package/dist/scripts/27.chunk.js +0 -3565
  256. package/dist/scripts/27.chunk.js.map +0 -1
  257. package/dist/scripts/28-d748f747fa.chunk.js +0 -1
  258. package/dist/scripts/28.chunk.js +0 -3129
  259. package/dist/scripts/28.chunk.js.map +0 -1
  260. package/dist/scripts/29-ef4aaa5fd8.chunk.js +0 -1
  261. package/dist/scripts/29.chunk.js +0 -3088
  262. package/dist/scripts/29.chunk.js.map +0 -1
  263. package/dist/scripts/3-9ac062f7ab.chunk.js +0 -1
  264. package/dist/scripts/3.chunk.js +0 -782
  265. package/dist/scripts/3.chunk.js.map +0 -1
  266. package/dist/scripts/30-1b84ae2ac7.chunk.js +0 -1
  267. package/dist/scripts/30.chunk.js +0 -1809
  268. package/dist/scripts/30.chunk.js.map +0 -1
  269. package/dist/scripts/31-b51d47f02b.chunk.js +0 -1
  270. package/dist/scripts/31.chunk.js +0 -958
  271. package/dist/scripts/31.chunk.js.map +0 -1
  272. package/dist/scripts/32-3f5cffb858.chunk.js +0 -1
  273. package/dist/scripts/32.chunk.js +0 -1235
  274. package/dist/scripts/32.chunk.js.map +0 -1
  275. package/dist/scripts/33-bd5b8ad402.chunk.js +0 -1
  276. package/dist/scripts/33.chunk.js +0 -792
  277. package/dist/scripts/33.chunk.js.map +0 -1
  278. package/dist/scripts/34-16c6ce9391.chunk.js +0 -1
  279. package/dist/scripts/34.chunk.js +0 -990
  280. package/dist/scripts/34.chunk.js.map +0 -1
  281. package/dist/scripts/35-f0ff6077b5.chunk.js +0 -1
  282. package/dist/scripts/35.chunk.js +0 -518
  283. package/dist/scripts/35.chunk.js.map +0 -1
  284. package/dist/scripts/36-6d5df4dbb0.chunk.js +0 -1
  285. package/dist/scripts/36.chunk.js +0 -335
  286. package/dist/scripts/36.chunk.js.map +0 -1
  287. package/dist/scripts/37-1aedf84774.chunk.js +0 -1
  288. package/dist/scripts/37.chunk.js +0 -236
  289. package/dist/scripts/37.chunk.js.map +0 -1
  290. package/dist/scripts/38-9411624870.chunk.js +0 -1
  291. package/dist/scripts/38.chunk.js +0 -315
  292. package/dist/scripts/38.chunk.js.map +0 -1
  293. package/dist/scripts/39-f46d2f69b1.chunk.js +0 -1
  294. package/dist/scripts/39.chunk.js +0 -116
  295. package/dist/scripts/39.chunk.js.map +0 -1
  296. package/dist/scripts/4-2bf2f1b864.chunk.js +0 -1
  297. package/dist/scripts/4.chunk.js +0 -335
  298. package/dist/scripts/4.chunk.js.map +0 -1
  299. package/dist/scripts/40-2134ac47ae.chunk.js +0 -1
  300. package/dist/scripts/40.chunk.js +0 -1782
  301. package/dist/scripts/40.chunk.js.map +0 -1
  302. package/dist/scripts/41-38841ce7ed.chunk.js +0 -1
  303. package/dist/scripts/41.chunk.js +0 -2347
  304. package/dist/scripts/41.chunk.js.map +0 -1
  305. package/dist/scripts/42-06cb96ddaf.chunk.js +0 -1
  306. package/dist/scripts/42.chunk.js +0 -2111
  307. package/dist/scripts/42.chunk.js.map +0 -1
  308. package/dist/scripts/43-164d1aaf84.chunk.js +0 -1
  309. package/dist/scripts/43.chunk.js +0 -2243
  310. package/dist/scripts/43.chunk.js.map +0 -1
  311. package/dist/scripts/44-234dd1aac7.chunk.js +0 -1
  312. package/dist/scripts/44.chunk.js +0 -1024
  313. package/dist/scripts/44.chunk.js.map +0 -1
  314. package/dist/scripts/45-26c33d7856.chunk.js +0 -1
  315. package/dist/scripts/45.chunk.js +0 -1065
  316. package/dist/scripts/45.chunk.js.map +0 -1
  317. package/dist/scripts/46-07c390591d.chunk.js +0 -1
  318. package/dist/scripts/46.chunk.js +0 -613
  319. package/dist/scripts/46.chunk.js.map +0 -1
  320. package/dist/scripts/47-6a9c70d236.chunk.js +0 -1
  321. package/dist/scripts/47.chunk.js +0 -735
  322. package/dist/scripts/47.chunk.js.map +0 -1
  323. package/dist/scripts/48-ee3bf3e841.chunk.js +0 -1
  324. package/dist/scripts/48.chunk.js +0 -994
  325. package/dist/scripts/48.chunk.js.map +0 -1
  326. package/dist/scripts/49-73ebbe96d0.chunk.js +0 -1
  327. package/dist/scripts/49.chunk.js +0 -759
  328. package/dist/scripts/49.chunk.js.map +0 -1
  329. package/dist/scripts/5-19ce45d023.chunk.js +0 -1
  330. package/dist/scripts/5.chunk.js +0 -40
  331. package/dist/scripts/5.chunk.js.map +0 -1
  332. package/dist/scripts/50-a1439e0fa7.chunk.js +0 -1
  333. package/dist/scripts/50.chunk.js +0 -528
  334. package/dist/scripts/50.chunk.js.map +0 -1
  335. package/dist/scripts/51-cad32e2046.chunk.js +0 -1
  336. package/dist/scripts/51.chunk.js +0 -932
  337. package/dist/scripts/51.chunk.js.map +0 -1
  338. package/dist/scripts/52-1d3e8eb21e.chunk.js +0 -1
  339. package/dist/scripts/52.chunk.js +0 -408
  340. package/dist/scripts/52.chunk.js.map +0 -1
  341. package/dist/scripts/53-5e80e33e98.chunk.js +0 -1
  342. package/dist/scripts/53.chunk.js +0 -754
  343. package/dist/scripts/53.chunk.js.map +0 -1
  344. package/dist/scripts/54.chunk.js +0 -681
  345. package/dist/scripts/54.chunk.js.map +0 -1
  346. package/dist/scripts/55-4c8d7b57f9.chunk.js +0 -1
  347. package/dist/scripts/55.chunk.js +0 -645
  348. package/dist/scripts/55.chunk.js.map +0 -1
  349. package/dist/scripts/56-1d96fdfcd3.chunk.js +0 -1
  350. package/dist/scripts/56.chunk.js +0 -346
  351. package/dist/scripts/56.chunk.js.map +0 -1
  352. package/dist/scripts/57-c17cdf728f.chunk.js +0 -1
  353. package/dist/scripts/57.chunk.js +0 -422
  354. package/dist/scripts/57.chunk.js.map +0 -1
  355. package/dist/scripts/58-ce34e558f4.chunk.js +0 -1
  356. package/dist/scripts/58.chunk.js +0 -437
  357. package/dist/scripts/58.chunk.js.map +0 -1
  358. package/dist/scripts/59.chunk.js +0 -342
  359. package/dist/scripts/59.chunk.js.map +0 -1
  360. package/dist/scripts/6-e9685801b5.chunk.js +0 -1
  361. package/dist/scripts/6.chunk.js +0 -484
  362. package/dist/scripts/6.chunk.js.map +0 -1
  363. package/dist/scripts/60-8d73b65e4e.chunk.js +0 -1
  364. package/dist/scripts/60.chunk.js +0 -254
  365. package/dist/scripts/60.chunk.js.map +0 -1
  366. package/dist/scripts/61-bd804db13e.chunk.js +0 -1
  367. package/dist/scripts/61.chunk.js +0 -318
  368. package/dist/scripts/61.chunk.js.map +0 -1
  369. package/dist/scripts/62-827229b727.chunk.js +0 -1
  370. package/dist/scripts/62.chunk.js +0 -142
  371. package/dist/scripts/62.chunk.js.map +0 -1
  372. package/dist/scripts/63-7251ac44d0.chunk.js +0 -1
  373. package/dist/scripts/63.chunk.js +0 -147
  374. package/dist/scripts/63.chunk.js.map +0 -1
  375. package/dist/scripts/64-33ca5259e4.chunk.js +0 -1
  376. package/dist/scripts/64.chunk.js +0 -439
  377. package/dist/scripts/64.chunk.js.map +0 -1
  378. package/dist/scripts/65-50d52bf3df.chunk.js +0 -1
  379. package/dist/scripts/65.chunk.js +0 -582
  380. package/dist/scripts/65.chunk.js.map +0 -1
  381. package/dist/scripts/66-fe41a3b54a.chunk.js +0 -1
  382. package/dist/scripts/66.chunk.js +0 -442
  383. package/dist/scripts/66.chunk.js.map +0 -1
  384. package/dist/scripts/67-1508455eb9.chunk.js +0 -1
  385. package/dist/scripts/67.chunk.js +0 -295
  386. package/dist/scripts/67.chunk.js.map +0 -1
  387. package/dist/scripts/68-21e8520126.chunk.js +0 -1
  388. package/dist/scripts/68.chunk.js +0 -165
  389. package/dist/scripts/68.chunk.js.map +0 -1
  390. package/dist/scripts/69-4d26485024.chunk.js +0 -1
  391. package/dist/scripts/69.chunk.js +0 -248
  392. package/dist/scripts/69.chunk.js.map +0 -1
  393. package/dist/scripts/7-d0085fdf2e.chunk.js +0 -1
  394. package/dist/scripts/7.chunk.js +0 -309
  395. package/dist/scripts/7.chunk.js.map +0 -1
  396. package/dist/scripts/70-8e1d03a7d8.chunk.js +0 -1
  397. package/dist/scripts/70.chunk.js +0 -207
  398. package/dist/scripts/70.chunk.js.map +0 -1
  399. package/dist/scripts/71-b835514c89.chunk.js +0 -1
  400. package/dist/scripts/71.chunk.js +0 -237
  401. package/dist/scripts/71.chunk.js.map +0 -1
  402. package/dist/scripts/72-23d6083900.chunk.js +0 -1
  403. package/dist/scripts/72.chunk.js +0 -331
  404. package/dist/scripts/72.chunk.js.map +0 -1
  405. package/dist/scripts/73.chunk.js +0 -404
  406. package/dist/scripts/73.chunk.js.map +0 -1
  407. package/dist/scripts/74.chunk.js +0 -301
  408. package/dist/scripts/74.chunk.js.map +0 -1
  409. package/dist/scripts/75.chunk.js +0 -231
  410. package/dist/scripts/75.chunk.js.map +0 -1
  411. package/dist/scripts/76.chunk.js +0 -157
  412. package/dist/scripts/76.chunk.js.map +0 -1
  413. package/dist/scripts/77.chunk.js +0 -307
  414. package/dist/scripts/77.chunk.js.map +0 -1
  415. package/dist/scripts/78.chunk.js +0 -249
  416. package/dist/scripts/78.chunk.js.map +0 -1
  417. package/dist/scripts/79.chunk.js +0 -282
  418. package/dist/scripts/79.chunk.js.map +0 -1
  419. package/dist/scripts/8-0ebd446b65.chunk.js +0 -1
  420. package/dist/scripts/8.chunk.js +0 -307
  421. package/dist/scripts/8.chunk.js.map +0 -1
  422. package/dist/scripts/80.chunk.js +0 -308
  423. package/dist/scripts/80.chunk.js.map +0 -1
  424. package/dist/scripts/81.chunk.js +0 -366
  425. package/dist/scripts/81.chunk.js.map +0 -1
  426. package/dist/scripts/82.chunk.js +0 -314
  427. package/dist/scripts/82.chunk.js.map +0 -1
  428. package/dist/scripts/83.chunk.js +0 -328
  429. package/dist/scripts/83.chunk.js.map +0 -1
  430. package/dist/scripts/84.chunk.js +0 -313
  431. package/dist/scripts/84.chunk.js.map +0 -1
  432. package/dist/scripts/85.chunk.js +0 -291
  433. package/dist/scripts/85.chunk.js.map +0 -1
  434. package/dist/scripts/86.chunk.js +0 -119
  435. package/dist/scripts/86.chunk.js.map +0 -1
  436. package/dist/scripts/87.chunk.js +0 -219
  437. package/dist/scripts/87.chunk.js.map +0 -1
  438. package/dist/scripts/88.chunk.js +0 -194
  439. package/dist/scripts/88.chunk.js.map +0 -1
  440. package/dist/scripts/89.chunk.js +0 -522
  441. package/dist/scripts/89.chunk.js.map +0 -1
  442. package/dist/scripts/9-0476e7c063.chunk.js +0 -1
  443. package/dist/scripts/9.chunk.js +0 -222
  444. package/dist/scripts/9.chunk.js.map +0 -1
  445. package/dist/scripts/90.chunk.js +0 -337
  446. package/dist/scripts/90.chunk.js.map +0 -1
  447. package/dist/scripts/91.chunk.js +0 -131
  448. package/dist/scripts/91.chunk.js.map +0 -1
  449. package/dist/scripts/92.chunk.js +0 -266
  450. package/dist/scripts/92.chunk.js.map +0 -1
  451. package/dist/scripts/bundle-1efd9147e1.min.js +0 -1
  452. package/dist/scripts/bundle-486bb6fa60.min.js +0 -1
  453. package/dist/scripts/bundle-511dc1956b.min.js +0 -1
  454. package/dist/scripts/bundle-8468900bf9.min.js +0 -1
  455. package/dist/scripts/bundle.js +0 -57527
  456. package/dist/scripts/bundle.js.map +0 -1
@@ -1,3565 +0,0 @@
1
- (window["webpackJsonp_clickview_library_editor"] = window["webpackJsonp_clickview_library_editor"] || []).push([[27],{
2
-
3
- /***/ "../../../node_modules/cropperjs/dist/cropper.js":
4
- /*!*******************************************************************************!*\
5
- !*** C:/ClickView Projects/@clickview/node_modules/cropperjs/dist/cropper.js ***!
6
- \*******************************************************************************/
7
- /*! no static exports found */
8
- /***/ (function(module, exports, __webpack_require__) {
9
-
10
- /*!
11
- * Cropper.js v1.5.3
12
- * https://fengyuanchen.github.io/cropperjs
13
- *
14
- * Copyright 2015-present Chen Fengyuan
15
- * Released under the MIT license
16
- *
17
- * Date: 2019-07-10T12:07:44.557Z
18
- */
19
-
20
- (function (global, factory) {
21
- true ? module.exports = factory() :
22
- undefined;
23
- }(this, function () { 'use strict';
24
-
25
- function _typeof(obj) {
26
- if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
27
- _typeof = function (obj) {
28
- return typeof obj;
29
- };
30
- } else {
31
- _typeof = function (obj) {
32
- return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
33
- };
34
- }
35
-
36
- return _typeof(obj);
37
- }
38
-
39
- function _classCallCheck(instance, Constructor) {
40
- if (!(instance instanceof Constructor)) {
41
- throw new TypeError("Cannot call a class as a function");
42
- }
43
- }
44
-
45
- function _defineProperties(target, props) {
46
- for (var i = 0; i < props.length; i++) {
47
- var descriptor = props[i];
48
- descriptor.enumerable = descriptor.enumerable || false;
49
- descriptor.configurable = true;
50
- if ("value" in descriptor) descriptor.writable = true;
51
- Object.defineProperty(target, descriptor.key, descriptor);
52
- }
53
- }
54
-
55
- function _createClass(Constructor, protoProps, staticProps) {
56
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
57
- if (staticProps) _defineProperties(Constructor, staticProps);
58
- return Constructor;
59
- }
60
-
61
- function _toConsumableArray(arr) {
62
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
63
- }
64
-
65
- function _arrayWithoutHoles(arr) {
66
- if (Array.isArray(arr)) {
67
- for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
68
-
69
- return arr2;
70
- }
71
- }
72
-
73
- function _iterableToArray(iter) {
74
- if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
75
- }
76
-
77
- function _nonIterableSpread() {
78
- throw new TypeError("Invalid attempt to spread non-iterable instance");
79
- }
80
-
81
- var IS_BROWSER = typeof window !== 'undefined';
82
- var WINDOW = IS_BROWSER ? window : {};
83
- var IS_TOUCH_DEVICE = IS_BROWSER ? 'ontouchstart' in WINDOW.document.documentElement : false;
84
- var HAS_POINTER_EVENT = IS_BROWSER ? 'PointerEvent' in WINDOW : false;
85
- var NAMESPACE = 'cropper'; // Actions
86
-
87
- var ACTION_ALL = 'all';
88
- var ACTION_CROP = 'crop';
89
- var ACTION_MOVE = 'move';
90
- var ACTION_ZOOM = 'zoom';
91
- var ACTION_EAST = 'e';
92
- var ACTION_WEST = 'w';
93
- var ACTION_SOUTH = 's';
94
- var ACTION_NORTH = 'n';
95
- var ACTION_NORTH_EAST = 'ne';
96
- var ACTION_NORTH_WEST = 'nw';
97
- var ACTION_SOUTH_EAST = 'se';
98
- var ACTION_SOUTH_WEST = 'sw'; // Classes
99
-
100
- var CLASS_CROP = "".concat(NAMESPACE, "-crop");
101
- var CLASS_DISABLED = "".concat(NAMESPACE, "-disabled");
102
- var CLASS_HIDDEN = "".concat(NAMESPACE, "-hidden");
103
- var CLASS_HIDE = "".concat(NAMESPACE, "-hide");
104
- var CLASS_INVISIBLE = "".concat(NAMESPACE, "-invisible");
105
- var CLASS_MODAL = "".concat(NAMESPACE, "-modal");
106
- var CLASS_MOVE = "".concat(NAMESPACE, "-move"); // Data keys
107
-
108
- var DATA_ACTION = "".concat(NAMESPACE, "Action");
109
- var DATA_PREVIEW = "".concat(NAMESPACE, "Preview"); // Drag modes
110
-
111
- var DRAG_MODE_CROP = 'crop';
112
- var DRAG_MODE_MOVE = 'move';
113
- var DRAG_MODE_NONE = 'none'; // Events
114
-
115
- var EVENT_CROP = 'crop';
116
- var EVENT_CROP_END = 'cropend';
117
- var EVENT_CROP_MOVE = 'cropmove';
118
- var EVENT_CROP_START = 'cropstart';
119
- var EVENT_DBLCLICK = 'dblclick';
120
- var EVENT_TOUCH_START = IS_TOUCH_DEVICE ? 'touchstart' : 'mousedown';
121
- var EVENT_TOUCH_MOVE = IS_TOUCH_DEVICE ? 'touchmove' : 'mousemove';
122
- var EVENT_TOUCH_END = IS_TOUCH_DEVICE ? 'touchend touchcancel' : 'mouseup';
123
- var EVENT_POINTER_DOWN = HAS_POINTER_EVENT ? 'pointerdown' : EVENT_TOUCH_START;
124
- var EVENT_POINTER_MOVE = HAS_POINTER_EVENT ? 'pointermove' : EVENT_TOUCH_MOVE;
125
- var EVENT_POINTER_UP = HAS_POINTER_EVENT ? 'pointerup pointercancel' : EVENT_TOUCH_END;
126
- var EVENT_READY = 'ready';
127
- var EVENT_RESIZE = 'resize';
128
- var EVENT_WHEEL = 'wheel';
129
- var EVENT_ZOOM = 'zoom'; // Mime types
130
-
131
- var MIME_TYPE_JPEG = 'image/jpeg'; // RegExps
132
-
133
- var REGEXP_ACTIONS = /^e|w|s|n|se|sw|ne|nw|all|crop|move|zoom$/;
134
- var REGEXP_DATA_URL_JPEG = /^data:image\/jpeg;base64,/;
135
- var REGEXP_TAG_NAME = /^img|canvas$/i; // Misc
136
- // Inspired by the default width and height of a canvas element.
137
-
138
- var MIN_CONTAINER_WIDTH = 200;
139
- var MIN_CONTAINER_HEIGHT = 100;
140
-
141
- var DEFAULTS = {
142
- // Define the view mode of the cropper
143
- viewMode: 0,
144
- // 0, 1, 2, 3
145
- // Define the dragging mode of the cropper
146
- dragMode: DRAG_MODE_CROP,
147
- // 'crop', 'move' or 'none'
148
- // Define the initial aspect ratio of the crop box
149
- initialAspectRatio: NaN,
150
- // Define the aspect ratio of the crop box
151
- aspectRatio: NaN,
152
- // An object with the previous cropping result data
153
- data: null,
154
- // A selector for adding extra containers to preview
155
- preview: '',
156
- // Re-render the cropper when resize the window
157
- responsive: true,
158
- // Restore the cropped area after resize the window
159
- restore: true,
160
- // Check if the current image is a cross-origin image
161
- checkCrossOrigin: true,
162
- // Check the current image's Exif Orientation information
163
- checkOrientation: true,
164
- // Show the black modal
165
- modal: true,
166
- // Show the dashed lines for guiding
167
- guides: true,
168
- // Show the center indicator for guiding
169
- center: true,
170
- // Show the white modal to highlight the crop box
171
- highlight: true,
172
- // Show the grid background
173
- background: true,
174
- // Enable to crop the image automatically when initialize
175
- autoCrop: true,
176
- // Define the percentage of automatic cropping area when initializes
177
- autoCropArea: 0.8,
178
- // Enable to move the image
179
- movable: true,
180
- // Enable to rotate the image
181
- rotatable: true,
182
- // Enable to scale the image
183
- scalable: true,
184
- // Enable to zoom the image
185
- zoomable: true,
186
- // Enable to zoom the image by dragging touch
187
- zoomOnTouch: true,
188
- // Enable to zoom the image by wheeling mouse
189
- zoomOnWheel: true,
190
- // Define zoom ratio when zoom the image by wheeling mouse
191
- wheelZoomRatio: 0.1,
192
- // Enable to move the crop box
193
- cropBoxMovable: true,
194
- // Enable to resize the crop box
195
- cropBoxResizable: true,
196
- // Toggle drag mode between "crop" and "move" when click twice on the cropper
197
- toggleDragModeOnDblclick: true,
198
- // Size limitation
199
- minCanvasWidth: 0,
200
- minCanvasHeight: 0,
201
- minCropBoxWidth: 0,
202
- minCropBoxHeight: 0,
203
- minContainerWidth: 200,
204
- minContainerHeight: 100,
205
- // Shortcuts of events
206
- ready: null,
207
- cropstart: null,
208
- cropmove: null,
209
- cropend: null,
210
- crop: null,
211
- zoom: null
212
- };
213
-
214
- var TEMPLATE = '<div class="cropper-container" touch-action="none">' + '<div class="cropper-wrap-box">' + '<div class="cropper-canvas"></div>' + '</div>' + '<div class="cropper-drag-box"></div>' + '<div class="cropper-crop-box">' + '<span class="cropper-view-box"></span>' + '<span class="cropper-dashed dashed-h"></span>' + '<span class="cropper-dashed dashed-v"></span>' + '<span class="cropper-center"></span>' + '<span class="cropper-face"></span>' + '<span class="cropper-line line-e" data-cropper-action="e"></span>' + '<span class="cropper-line line-n" data-cropper-action="n"></span>' + '<span class="cropper-line line-w" data-cropper-action="w"></span>' + '<span class="cropper-line line-s" data-cropper-action="s"></span>' + '<span class="cropper-point point-e" data-cropper-action="e"></span>' + '<span class="cropper-point point-n" data-cropper-action="n"></span>' + '<span class="cropper-point point-w" data-cropper-action="w"></span>' + '<span class="cropper-point point-s" data-cropper-action="s"></span>' + '<span class="cropper-point point-ne" data-cropper-action="ne"></span>' + '<span class="cropper-point point-nw" data-cropper-action="nw"></span>' + '<span class="cropper-point point-sw" data-cropper-action="sw"></span>' + '<span class="cropper-point point-se" data-cropper-action="se"></span>' + '</div>' + '</div>';
215
-
216
- /**
217
- * Check if the given value is not a number.
218
- */
219
-
220
- var isNaN = Number.isNaN || WINDOW.isNaN;
221
- /**
222
- * Check if the given value is a number.
223
- * @param {*} value - The value to check.
224
- * @returns {boolean} Returns `true` if the given value is a number, else `false`.
225
- */
226
-
227
- function isNumber(value) {
228
- return typeof value === 'number' && !isNaN(value);
229
- }
230
- /**
231
- * Check if the given value is a positive number.
232
- * @param {*} value - The value to check.
233
- * @returns {boolean} Returns `true` if the given value is a positive number, else `false`.
234
- */
235
-
236
- var isPositiveNumber = function isPositiveNumber(value) {
237
- return value > 0 && value < Infinity;
238
- };
239
- /**
240
- * Check if the given value is undefined.
241
- * @param {*} value - The value to check.
242
- * @returns {boolean} Returns `true` if the given value is undefined, else `false`.
243
- */
244
-
245
- function isUndefined(value) {
246
- return typeof value === 'undefined';
247
- }
248
- /**
249
- * Check if the given value is an object.
250
- * @param {*} value - The value to check.
251
- * @returns {boolean} Returns `true` if the given value is an object, else `false`.
252
- */
253
-
254
- function isObject(value) {
255
- return _typeof(value) === 'object' && value !== null;
256
- }
257
- var hasOwnProperty = Object.prototype.hasOwnProperty;
258
- /**
259
- * Check if the given value is a plain object.
260
- * @param {*} value - The value to check.
261
- * @returns {boolean} Returns `true` if the given value is a plain object, else `false`.
262
- */
263
-
264
- function isPlainObject(value) {
265
- if (!isObject(value)) {
266
- return false;
267
- }
268
-
269
- try {
270
- var _constructor = value.constructor;
271
- var prototype = _constructor.prototype;
272
- return _constructor && prototype && hasOwnProperty.call(prototype, 'isPrototypeOf');
273
- } catch (error) {
274
- return false;
275
- }
276
- }
277
- /**
278
- * Check if the given value is a function.
279
- * @param {*} value - The value to check.
280
- * @returns {boolean} Returns `true` if the given value is a function, else `false`.
281
- */
282
-
283
- function isFunction(value) {
284
- return typeof value === 'function';
285
- }
286
- var slice = Array.prototype.slice;
287
- /**
288
- * Convert array-like or iterable object to an array.
289
- * @param {*} value - The value to convert.
290
- * @returns {Array} Returns a new array.
291
- */
292
-
293
- function toArray(value) {
294
- return Array.from ? Array.from(value) : slice.call(value);
295
- }
296
- /**
297
- * Iterate the given data.
298
- * @param {*} data - The data to iterate.
299
- * @param {Function} callback - The process function for each element.
300
- * @returns {*} The original data.
301
- */
302
-
303
- function forEach(data, callback) {
304
- if (data && isFunction(callback)) {
305
- if (Array.isArray(data) || isNumber(data.length)
306
- /* array-like */
307
- ) {
308
- toArray(data).forEach(function (value, key) {
309
- callback.call(data, value, key, data);
310
- });
311
- } else if (isObject(data)) {
312
- Object.keys(data).forEach(function (key) {
313
- callback.call(data, data[key], key, data);
314
- });
315
- }
316
- }
317
-
318
- return data;
319
- }
320
- /**
321
- * Extend the given object.
322
- * @param {*} target - The target object to extend.
323
- * @param {*} args - The rest objects for merging to the target object.
324
- * @returns {Object} The extended object.
325
- */
326
-
327
- var assign = Object.assign || function assign(target) {
328
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
329
- args[_key - 1] = arguments[_key];
330
- }
331
-
332
- if (isObject(target) && args.length > 0) {
333
- args.forEach(function (arg) {
334
- if (isObject(arg)) {
335
- Object.keys(arg).forEach(function (key) {
336
- target[key] = arg[key];
337
- });
338
- }
339
- });
340
- }
341
-
342
- return target;
343
- };
344
- var REGEXP_DECIMALS = /\.\d*(?:0|9){12}\d*$/;
345
- /**
346
- * Normalize decimal number.
347
- * Check out {@link http://0.30000000000000004.com/}
348
- * @param {number} value - The value to normalize.
349
- * @param {number} [times=100000000000] - The times for normalizing.
350
- * @returns {number} Returns the normalized number.
351
- */
352
-
353
- function normalizeDecimalNumber(value) {
354
- var times = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 100000000000;
355
- return REGEXP_DECIMALS.test(value) ? Math.round(value * times) / times : value;
356
- }
357
- var REGEXP_SUFFIX = /^width|height|left|top|marginLeft|marginTop$/;
358
- /**
359
- * Apply styles to the given element.
360
- * @param {Element} element - The target element.
361
- * @param {Object} styles - The styles for applying.
362
- */
363
-
364
- function setStyle(element, styles) {
365
- var style = element.style;
366
- forEach(styles, function (value, property) {
367
- if (REGEXP_SUFFIX.test(property) && isNumber(value)) {
368
- value = "".concat(value, "px");
369
- }
370
-
371
- style[property] = value;
372
- });
373
- }
374
- /**
375
- * Check if the given element has a special class.
376
- * @param {Element} element - The element to check.
377
- * @param {string} value - The class to search.
378
- * @returns {boolean} Returns `true` if the special class was found.
379
- */
380
-
381
- function hasClass(element, value) {
382
- return element.classList ? element.classList.contains(value) : element.className.indexOf(value) > -1;
383
- }
384
- /**
385
- * Add classes to the given element.
386
- * @param {Element} element - The target element.
387
- * @param {string} value - The classes to be added.
388
- */
389
-
390
- function addClass(element, value) {
391
- if (!value) {
392
- return;
393
- }
394
-
395
- if (isNumber(element.length)) {
396
- forEach(element, function (elem) {
397
- addClass(elem, value);
398
- });
399
- return;
400
- }
401
-
402
- if (element.classList) {
403
- element.classList.add(value);
404
- return;
405
- }
406
-
407
- var className = element.className.trim();
408
-
409
- if (!className) {
410
- element.className = value;
411
- } else if (className.indexOf(value) < 0) {
412
- element.className = "".concat(className, " ").concat(value);
413
- }
414
- }
415
- /**
416
- * Remove classes from the given element.
417
- * @param {Element} element - The target element.
418
- * @param {string} value - The classes to be removed.
419
- */
420
-
421
- function removeClass(element, value) {
422
- if (!value) {
423
- return;
424
- }
425
-
426
- if (isNumber(element.length)) {
427
- forEach(element, function (elem) {
428
- removeClass(elem, value);
429
- });
430
- return;
431
- }
432
-
433
- if (element.classList) {
434
- element.classList.remove(value);
435
- return;
436
- }
437
-
438
- if (element.className.indexOf(value) >= 0) {
439
- element.className = element.className.replace(value, '');
440
- }
441
- }
442
- /**
443
- * Add or remove classes from the given element.
444
- * @param {Element} element - The target element.
445
- * @param {string} value - The classes to be toggled.
446
- * @param {boolean} added - Add only.
447
- */
448
-
449
- function toggleClass(element, value, added) {
450
- if (!value) {
451
- return;
452
- }
453
-
454
- if (isNumber(element.length)) {
455
- forEach(element, function (elem) {
456
- toggleClass(elem, value, added);
457
- });
458
- return;
459
- } // IE10-11 doesn't support the second parameter of `classList.toggle`
460
-
461
-
462
- if (added) {
463
- addClass(element, value);
464
- } else {
465
- removeClass(element, value);
466
- }
467
- }
468
- var REGEXP_CAMEL_CASE = /([a-z\d])([A-Z])/g;
469
- /**
470
- * Transform the given string from camelCase to kebab-case
471
- * @param {string} value - The value to transform.
472
- * @returns {string} The transformed value.
473
- */
474
-
475
- function toParamCase(value) {
476
- return value.replace(REGEXP_CAMEL_CASE, '$1-$2').toLowerCase();
477
- }
478
- /**
479
- * Get data from the given element.
480
- * @param {Element} element - The target element.
481
- * @param {string} name - The data key to get.
482
- * @returns {string} The data value.
483
- */
484
-
485
- function getData(element, name) {
486
- if (isObject(element[name])) {
487
- return element[name];
488
- }
489
-
490
- if (element.dataset) {
491
- return element.dataset[name];
492
- }
493
-
494
- return element.getAttribute("data-".concat(toParamCase(name)));
495
- }
496
- /**
497
- * Set data to the given element.
498
- * @param {Element} element - The target element.
499
- * @param {string} name - The data key to set.
500
- * @param {string} data - The data value.
501
- */
502
-
503
- function setData(element, name, data) {
504
- if (isObject(data)) {
505
- element[name] = data;
506
- } else if (element.dataset) {
507
- element.dataset[name] = data;
508
- } else {
509
- element.setAttribute("data-".concat(toParamCase(name)), data);
510
- }
511
- }
512
- /**
513
- * Remove data from the given element.
514
- * @param {Element} element - The target element.
515
- * @param {string} name - The data key to remove.
516
- */
517
-
518
- function removeData(element, name) {
519
- if (isObject(element[name])) {
520
- try {
521
- delete element[name];
522
- } catch (error) {
523
- element[name] = undefined;
524
- }
525
- } else if (element.dataset) {
526
- // #128 Safari not allows to delete dataset property
527
- try {
528
- delete element.dataset[name];
529
- } catch (error) {
530
- element.dataset[name] = undefined;
531
- }
532
- } else {
533
- element.removeAttribute("data-".concat(toParamCase(name)));
534
- }
535
- }
536
- var REGEXP_SPACES = /\s\s*/;
537
-
538
- var onceSupported = function () {
539
- var supported = false;
540
-
541
- if (IS_BROWSER) {
542
- var once = false;
543
-
544
- var listener = function listener() {};
545
-
546
- var options = Object.defineProperty({}, 'once', {
547
- get: function get() {
548
- supported = true;
549
- return once;
550
- },
551
-
552
- /**
553
- * This setter can fix a `TypeError` in strict mode
554
- * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Getter_only}
555
- * @param {boolean} value - The value to set
556
- */
557
- set: function set(value) {
558
- once = value;
559
- }
560
- });
561
- WINDOW.addEventListener('test', listener, options);
562
- WINDOW.removeEventListener('test', listener, options);
563
- }
564
-
565
- return supported;
566
- }();
567
- /**
568
- * Remove event listener from the target element.
569
- * @param {Element} element - The event target.
570
- * @param {string} type - The event type(s).
571
- * @param {Function} listener - The event listener.
572
- * @param {Object} options - The event options.
573
- */
574
-
575
-
576
- function removeListener(element, type, listener) {
577
- var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
578
- var handler = listener;
579
- type.trim().split(REGEXP_SPACES).forEach(function (event) {
580
- if (!onceSupported) {
581
- var listeners = element.listeners;
582
-
583
- if (listeners && listeners[event] && listeners[event][listener]) {
584
- handler = listeners[event][listener];
585
- delete listeners[event][listener];
586
-
587
- if (Object.keys(listeners[event]).length === 0) {
588
- delete listeners[event];
589
- }
590
-
591
- if (Object.keys(listeners).length === 0) {
592
- delete element.listeners;
593
- }
594
- }
595
- }
596
-
597
- element.removeEventListener(event, handler, options);
598
- });
599
- }
600
- /**
601
- * Add event listener to the target element.
602
- * @param {Element} element - The event target.
603
- * @param {string} type - The event type(s).
604
- * @param {Function} listener - The event listener.
605
- * @param {Object} options - The event options.
606
- */
607
-
608
- function addListener(element, type, listener) {
609
- var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
610
- var _handler = listener;
611
- type.trim().split(REGEXP_SPACES).forEach(function (event) {
612
- if (options.once && !onceSupported) {
613
- var _element$listeners = element.listeners,
614
- listeners = _element$listeners === void 0 ? {} : _element$listeners;
615
-
616
- _handler = function handler() {
617
- delete listeners[event][listener];
618
- element.removeEventListener(event, _handler, options);
619
-
620
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
621
- args[_key2] = arguments[_key2];
622
- }
623
-
624
- listener.apply(element, args);
625
- };
626
-
627
- if (!listeners[event]) {
628
- listeners[event] = {};
629
- }
630
-
631
- if (listeners[event][listener]) {
632
- element.removeEventListener(event, listeners[event][listener], options);
633
- }
634
-
635
- listeners[event][listener] = _handler;
636
- element.listeners = listeners;
637
- }
638
-
639
- element.addEventListener(event, _handler, options);
640
- });
641
- }
642
- /**
643
- * Dispatch event on the target element.
644
- * @param {Element} element - The event target.
645
- * @param {string} type - The event type(s).
646
- * @param {Object} data - The additional event data.
647
- * @returns {boolean} Indicate if the event is default prevented or not.
648
- */
649
-
650
- function dispatchEvent(element, type, data) {
651
- var event; // Event and CustomEvent on IE9-11 are global objects, not constructors
652
-
653
- if (isFunction(Event) && isFunction(CustomEvent)) {
654
- event = new CustomEvent(type, {
655
- detail: data,
656
- bubbles: true,
657
- cancelable: true
658
- });
659
- } else {
660
- event = document.createEvent('CustomEvent');
661
- event.initCustomEvent(type, true, true, data);
662
- }
663
-
664
- return element.dispatchEvent(event);
665
- }
666
- /**
667
- * Get the offset base on the document.
668
- * @param {Element} element - The target element.
669
- * @returns {Object} The offset data.
670
- */
671
-
672
- function getOffset(element) {
673
- var box = element.getBoundingClientRect();
674
- return {
675
- left: box.left + (window.pageXOffset - document.documentElement.clientLeft),
676
- top: box.top + (window.pageYOffset - document.documentElement.clientTop)
677
- };
678
- }
679
- var location = WINDOW.location;
680
- var REGEXP_ORIGINS = /^(\w+:)\/\/([^:/?#]*):?(\d*)/i;
681
- /**
682
- * Check if the given URL is a cross origin URL.
683
- * @param {string} url - The target URL.
684
- * @returns {boolean} Returns `true` if the given URL is a cross origin URL, else `false`.
685
- */
686
-
687
- function isCrossOriginURL(url) {
688
- var parts = url.match(REGEXP_ORIGINS);
689
- return parts !== null && (parts[1] !== location.protocol || parts[2] !== location.hostname || parts[3] !== location.port);
690
- }
691
- /**
692
- * Add timestamp to the given URL.
693
- * @param {string} url - The target URL.
694
- * @returns {string} The result URL.
695
- */
696
-
697
- function addTimestamp(url) {
698
- var timestamp = "timestamp=".concat(new Date().getTime());
699
- return url + (url.indexOf('?') === -1 ? '?' : '&') + timestamp;
700
- }
701
- /**
702
- * Get transforms base on the given object.
703
- * @param {Object} obj - The target object.
704
- * @returns {string} A string contains transform values.
705
- */
706
-
707
- function getTransforms(_ref) {
708
- var rotate = _ref.rotate,
709
- scaleX = _ref.scaleX,
710
- scaleY = _ref.scaleY,
711
- translateX = _ref.translateX,
712
- translateY = _ref.translateY;
713
- var values = [];
714
-
715
- if (isNumber(translateX) && translateX !== 0) {
716
- values.push("translateX(".concat(translateX, "px)"));
717
- }
718
-
719
- if (isNumber(translateY) && translateY !== 0) {
720
- values.push("translateY(".concat(translateY, "px)"));
721
- } // Rotate should come first before scale to match orientation transform
722
-
723
-
724
- if (isNumber(rotate) && rotate !== 0) {
725
- values.push("rotate(".concat(rotate, "deg)"));
726
- }
727
-
728
- if (isNumber(scaleX) && scaleX !== 1) {
729
- values.push("scaleX(".concat(scaleX, ")"));
730
- }
731
-
732
- if (isNumber(scaleY) && scaleY !== 1) {
733
- values.push("scaleY(".concat(scaleY, ")"));
734
- }
735
-
736
- var transform = values.length ? values.join(' ') : 'none';
737
- return {
738
- WebkitTransform: transform,
739
- msTransform: transform,
740
- transform: transform
741
- };
742
- }
743
- /**
744
- * Get the max ratio of a group of pointers.
745
- * @param {string} pointers - The target pointers.
746
- * @returns {number} The result ratio.
747
- */
748
-
749
- function getMaxZoomRatio(pointers) {
750
- var pointers2 = assign({}, pointers);
751
- var ratios = [];
752
- forEach(pointers, function (pointer, pointerId) {
753
- delete pointers2[pointerId];
754
- forEach(pointers2, function (pointer2) {
755
- var x1 = Math.abs(pointer.startX - pointer2.startX);
756
- var y1 = Math.abs(pointer.startY - pointer2.startY);
757
- var x2 = Math.abs(pointer.endX - pointer2.endX);
758
- var y2 = Math.abs(pointer.endY - pointer2.endY);
759
- var z1 = Math.sqrt(x1 * x1 + y1 * y1);
760
- var z2 = Math.sqrt(x2 * x2 + y2 * y2);
761
- var ratio = (z2 - z1) / z1;
762
- ratios.push(ratio);
763
- });
764
- });
765
- ratios.sort(function (a, b) {
766
- return Math.abs(a) < Math.abs(b);
767
- });
768
- return ratios[0];
769
- }
770
- /**
771
- * Get a pointer from an event object.
772
- * @param {Object} event - The target event object.
773
- * @param {boolean} endOnly - Indicates if only returns the end point coordinate or not.
774
- * @returns {Object} The result pointer contains start and/or end point coordinates.
775
- */
776
-
777
- function getPointer(_ref2, endOnly) {
778
- var pageX = _ref2.pageX,
779
- pageY = _ref2.pageY;
780
- var end = {
781
- endX: pageX,
782
- endY: pageY
783
- };
784
- return endOnly ? end : assign({
785
- startX: pageX,
786
- startY: pageY
787
- }, end);
788
- }
789
- /**
790
- * Get the center point coordinate of a group of pointers.
791
- * @param {Object} pointers - The target pointers.
792
- * @returns {Object} The center point coordinate.
793
- */
794
-
795
- function getPointersCenter(pointers) {
796
- var pageX = 0;
797
- var pageY = 0;
798
- var count = 0;
799
- forEach(pointers, function (_ref3) {
800
- var startX = _ref3.startX,
801
- startY = _ref3.startY;
802
- pageX += startX;
803
- pageY += startY;
804
- count += 1;
805
- });
806
- pageX /= count;
807
- pageY /= count;
808
- return {
809
- pageX: pageX,
810
- pageY: pageY
811
- };
812
- }
813
- /**
814
- * Get the max sizes in a rectangle under the given aspect ratio.
815
- * @param {Object} data - The original sizes.
816
- * @param {string} [type='contain'] - The adjust type.
817
- * @returns {Object} The result sizes.
818
- */
819
-
820
- function getAdjustedSizes(_ref4) // or 'cover'
821
- {
822
- var aspectRatio = _ref4.aspectRatio,
823
- height = _ref4.height,
824
- width = _ref4.width;
825
- var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'contain';
826
- var isValidWidth = isPositiveNumber(width);
827
- var isValidHeight = isPositiveNumber(height);
828
-
829
- if (isValidWidth && isValidHeight) {
830
- var adjustedWidth = height * aspectRatio;
831
-
832
- if (type === 'contain' && adjustedWidth > width || type === 'cover' && adjustedWidth < width) {
833
- height = width / aspectRatio;
834
- } else {
835
- width = height * aspectRatio;
836
- }
837
- } else if (isValidWidth) {
838
- height = width / aspectRatio;
839
- } else if (isValidHeight) {
840
- width = height * aspectRatio;
841
- }
842
-
843
- return {
844
- width: width,
845
- height: height
846
- };
847
- }
848
- /**
849
- * Get the new sizes of a rectangle after rotated.
850
- * @param {Object} data - The original sizes.
851
- * @returns {Object} The result sizes.
852
- */
853
-
854
- function getRotatedSizes(_ref5) {
855
- var width = _ref5.width,
856
- height = _ref5.height,
857
- degree = _ref5.degree;
858
- degree = Math.abs(degree) % 180;
859
-
860
- if (degree === 90) {
861
- return {
862
- width: height,
863
- height: width
864
- };
865
- }
866
-
867
- var arc = degree % 90 * Math.PI / 180;
868
- var sinArc = Math.sin(arc);
869
- var cosArc = Math.cos(arc);
870
- var newWidth = width * cosArc + height * sinArc;
871
- var newHeight = width * sinArc + height * cosArc;
872
- return degree > 90 ? {
873
- width: newHeight,
874
- height: newWidth
875
- } : {
876
- width: newWidth,
877
- height: newHeight
878
- };
879
- }
880
- /**
881
- * Get a canvas which drew the given image.
882
- * @param {HTMLImageElement} image - The image for drawing.
883
- * @param {Object} imageData - The image data.
884
- * @param {Object} canvasData - The canvas data.
885
- * @param {Object} options - The options.
886
- * @returns {HTMLCanvasElement} The result canvas.
887
- */
888
-
889
- function getSourceCanvas(image, _ref6, _ref7, _ref8) {
890
- var imageAspectRatio = _ref6.aspectRatio,
891
- imageNaturalWidth = _ref6.naturalWidth,
892
- imageNaturalHeight = _ref6.naturalHeight,
893
- _ref6$rotate = _ref6.rotate,
894
- rotate = _ref6$rotate === void 0 ? 0 : _ref6$rotate,
895
- _ref6$scaleX = _ref6.scaleX,
896
- scaleX = _ref6$scaleX === void 0 ? 1 : _ref6$scaleX,
897
- _ref6$scaleY = _ref6.scaleY,
898
- scaleY = _ref6$scaleY === void 0 ? 1 : _ref6$scaleY;
899
- var aspectRatio = _ref7.aspectRatio,
900
- naturalWidth = _ref7.naturalWidth,
901
- naturalHeight = _ref7.naturalHeight;
902
- var _ref8$fillColor = _ref8.fillColor,
903
- fillColor = _ref8$fillColor === void 0 ? 'transparent' : _ref8$fillColor,
904
- _ref8$imageSmoothingE = _ref8.imageSmoothingEnabled,
905
- imageSmoothingEnabled = _ref8$imageSmoothingE === void 0 ? true : _ref8$imageSmoothingE,
906
- _ref8$imageSmoothingQ = _ref8.imageSmoothingQuality,
907
- imageSmoothingQuality = _ref8$imageSmoothingQ === void 0 ? 'low' : _ref8$imageSmoothingQ,
908
- _ref8$maxWidth = _ref8.maxWidth,
909
- maxWidth = _ref8$maxWidth === void 0 ? Infinity : _ref8$maxWidth,
910
- _ref8$maxHeight = _ref8.maxHeight,
911
- maxHeight = _ref8$maxHeight === void 0 ? Infinity : _ref8$maxHeight,
912
- _ref8$minWidth = _ref8.minWidth,
913
- minWidth = _ref8$minWidth === void 0 ? 0 : _ref8$minWidth,
914
- _ref8$minHeight = _ref8.minHeight,
915
- minHeight = _ref8$minHeight === void 0 ? 0 : _ref8$minHeight;
916
- var canvas = document.createElement('canvas');
917
- var context = canvas.getContext('2d');
918
- var maxSizes = getAdjustedSizes({
919
- aspectRatio: aspectRatio,
920
- width: maxWidth,
921
- height: maxHeight
922
- });
923
- var minSizes = getAdjustedSizes({
924
- aspectRatio: aspectRatio,
925
- width: minWidth,
926
- height: minHeight
927
- }, 'cover');
928
- var width = Math.min(maxSizes.width, Math.max(minSizes.width, naturalWidth));
929
- var height = Math.min(maxSizes.height, Math.max(minSizes.height, naturalHeight)); // Note: should always use image's natural sizes for drawing as
930
- // imageData.naturalWidth === canvasData.naturalHeight when rotate % 180 === 90
931
-
932
- var destMaxSizes = getAdjustedSizes({
933
- aspectRatio: imageAspectRatio,
934
- width: maxWidth,
935
- height: maxHeight
936
- });
937
- var destMinSizes = getAdjustedSizes({
938
- aspectRatio: imageAspectRatio,
939
- width: minWidth,
940
- height: minHeight
941
- }, 'cover');
942
- var destWidth = Math.min(destMaxSizes.width, Math.max(destMinSizes.width, imageNaturalWidth));
943
- var destHeight = Math.min(destMaxSizes.height, Math.max(destMinSizes.height, imageNaturalHeight));
944
- var params = [-destWidth / 2, -destHeight / 2, destWidth, destHeight];
945
- canvas.width = normalizeDecimalNumber(width);
946
- canvas.height = normalizeDecimalNumber(height);
947
- context.fillStyle = fillColor;
948
- context.fillRect(0, 0, width, height);
949
- context.save();
950
- context.translate(width / 2, height / 2);
951
- context.rotate(rotate * Math.PI / 180);
952
- context.scale(scaleX, scaleY);
953
- context.imageSmoothingEnabled = imageSmoothingEnabled;
954
- context.imageSmoothingQuality = imageSmoothingQuality;
955
- context.drawImage.apply(context, [image].concat(_toConsumableArray(params.map(function (param) {
956
- return Math.floor(normalizeDecimalNumber(param));
957
- }))));
958
- context.restore();
959
- return canvas;
960
- }
961
- var fromCharCode = String.fromCharCode;
962
- /**
963
- * Get string from char code in data view.
964
- * @param {DataView} dataView - The data view for read.
965
- * @param {number} start - The start index.
966
- * @param {number} length - The read length.
967
- * @returns {string} The read result.
968
- */
969
-
970
- function getStringFromCharCode(dataView, start, length) {
971
- var str = '';
972
- length += start;
973
-
974
- for (var i = start; i < length; i += 1) {
975
- str += fromCharCode(dataView.getUint8(i));
976
- }
977
-
978
- return str;
979
- }
980
- var REGEXP_DATA_URL_HEAD = /^data:.*,/;
981
- /**
982
- * Transform Data URL to array buffer.
983
- * @param {string} dataURL - The Data URL to transform.
984
- * @returns {ArrayBuffer} The result array buffer.
985
- */
986
-
987
- function dataURLToArrayBuffer(dataURL) {
988
- var base64 = dataURL.replace(REGEXP_DATA_URL_HEAD, '');
989
- var binary = atob(base64);
990
- var arrayBuffer = new ArrayBuffer(binary.length);
991
- var uint8 = new Uint8Array(arrayBuffer);
992
- forEach(uint8, function (value, i) {
993
- uint8[i] = binary.charCodeAt(i);
994
- });
995
- return arrayBuffer;
996
- }
997
- /**
998
- * Transform array buffer to Data URL.
999
- * @param {ArrayBuffer} arrayBuffer - The array buffer to transform.
1000
- * @param {string} mimeType - The mime type of the Data URL.
1001
- * @returns {string} The result Data URL.
1002
- */
1003
-
1004
- function arrayBufferToDataURL(arrayBuffer, mimeType) {
1005
- var chunks = []; // Chunk Typed Array for better performance (#435)
1006
-
1007
- var chunkSize = 8192;
1008
- var uint8 = new Uint8Array(arrayBuffer);
1009
-
1010
- while (uint8.length > 0) {
1011
- // XXX: Babel's `toConsumableArray` helper will throw error in IE or Safari 9
1012
- // eslint-disable-next-line prefer-spread
1013
- chunks.push(fromCharCode.apply(null, toArray(uint8.subarray(0, chunkSize))));
1014
- uint8 = uint8.subarray(chunkSize);
1015
- }
1016
-
1017
- return "data:".concat(mimeType, ";base64,").concat(btoa(chunks.join('')));
1018
- }
1019
- /**
1020
- * Get orientation value from given array buffer.
1021
- * @param {ArrayBuffer} arrayBuffer - The array buffer to read.
1022
- * @returns {number} The read orientation value.
1023
- */
1024
-
1025
- function resetAndGetOrientation(arrayBuffer) {
1026
- var dataView = new DataView(arrayBuffer);
1027
- var orientation; // Ignores range error when the image does not have correct Exif information
1028
-
1029
- try {
1030
- var littleEndian;
1031
- var app1Start;
1032
- var ifdStart; // Only handle JPEG image (start by 0xFFD8)
1033
-
1034
- if (dataView.getUint8(0) === 0xFF && dataView.getUint8(1) === 0xD8) {
1035
- var length = dataView.byteLength;
1036
- var offset = 2;
1037
-
1038
- while (offset + 1 < length) {
1039
- if (dataView.getUint8(offset) === 0xFF && dataView.getUint8(offset + 1) === 0xE1) {
1040
- app1Start = offset;
1041
- break;
1042
- }
1043
-
1044
- offset += 1;
1045
- }
1046
- }
1047
-
1048
- if (app1Start) {
1049
- var exifIDCode = app1Start + 4;
1050
- var tiffOffset = app1Start + 10;
1051
-
1052
- if (getStringFromCharCode(dataView, exifIDCode, 4) === 'Exif') {
1053
- var endianness = dataView.getUint16(tiffOffset);
1054
- littleEndian = endianness === 0x4949;
1055
-
1056
- if (littleEndian || endianness === 0x4D4D
1057
- /* bigEndian */
1058
- ) {
1059
- if (dataView.getUint16(tiffOffset + 2, littleEndian) === 0x002A) {
1060
- var firstIFDOffset = dataView.getUint32(tiffOffset + 4, littleEndian);
1061
-
1062
- if (firstIFDOffset >= 0x00000008) {
1063
- ifdStart = tiffOffset + firstIFDOffset;
1064
- }
1065
- }
1066
- }
1067
- }
1068
- }
1069
-
1070
- if (ifdStart) {
1071
- var _length = dataView.getUint16(ifdStart, littleEndian);
1072
-
1073
- var _offset;
1074
-
1075
- var i;
1076
-
1077
- for (i = 0; i < _length; i += 1) {
1078
- _offset = ifdStart + i * 12 + 2;
1079
-
1080
- if (dataView.getUint16(_offset, littleEndian) === 0x0112
1081
- /* Orientation */
1082
- ) {
1083
- // 8 is the offset of the current tag's value
1084
- _offset += 8; // Get the original orientation value
1085
-
1086
- orientation = dataView.getUint16(_offset, littleEndian); // Override the orientation with its default value
1087
-
1088
- dataView.setUint16(_offset, 1, littleEndian);
1089
- break;
1090
- }
1091
- }
1092
- }
1093
- } catch (error) {
1094
- orientation = 1;
1095
- }
1096
-
1097
- return orientation;
1098
- }
1099
- /**
1100
- * Parse Exif Orientation value.
1101
- * @param {number} orientation - The orientation to parse.
1102
- * @returns {Object} The parsed result.
1103
- */
1104
-
1105
- function parseOrientation(orientation) {
1106
- var rotate = 0;
1107
- var scaleX = 1;
1108
- var scaleY = 1;
1109
-
1110
- switch (orientation) {
1111
- // Flip horizontal
1112
- case 2:
1113
- scaleX = -1;
1114
- break;
1115
- // Rotate left 180°
1116
-
1117
- case 3:
1118
- rotate = -180;
1119
- break;
1120
- // Flip vertical
1121
-
1122
- case 4:
1123
- scaleY = -1;
1124
- break;
1125
- // Flip vertical and rotate right 90°
1126
-
1127
- case 5:
1128
- rotate = 90;
1129
- scaleY = -1;
1130
- break;
1131
- // Rotate right 90°
1132
-
1133
- case 6:
1134
- rotate = 90;
1135
- break;
1136
- // Flip horizontal and rotate right 90°
1137
-
1138
- case 7:
1139
- rotate = 90;
1140
- scaleX = -1;
1141
- break;
1142
- // Rotate left 90°
1143
-
1144
- case 8:
1145
- rotate = -90;
1146
- break;
1147
-
1148
- default:
1149
- }
1150
-
1151
- return {
1152
- rotate: rotate,
1153
- scaleX: scaleX,
1154
- scaleY: scaleY
1155
- };
1156
- }
1157
-
1158
- var render = {
1159
- render: function render() {
1160
- this.initContainer();
1161
- this.initCanvas();
1162
- this.initCropBox();
1163
- this.renderCanvas();
1164
-
1165
- if (this.cropped) {
1166
- this.renderCropBox();
1167
- }
1168
- },
1169
- initContainer: function initContainer() {
1170
- var element = this.element,
1171
- options = this.options,
1172
- container = this.container,
1173
- cropper = this.cropper;
1174
- addClass(cropper, CLASS_HIDDEN);
1175
- removeClass(element, CLASS_HIDDEN);
1176
- var containerData = {
1177
- width: Math.max(container.offsetWidth, Number(options.minContainerWidth) || 200),
1178
- height: Math.max(container.offsetHeight, Number(options.minContainerHeight) || 100)
1179
- };
1180
- this.containerData = containerData;
1181
- setStyle(cropper, {
1182
- width: containerData.width,
1183
- height: containerData.height
1184
- });
1185
- addClass(element, CLASS_HIDDEN);
1186
- removeClass(cropper, CLASS_HIDDEN);
1187
- },
1188
- // Canvas (image wrapper)
1189
- initCanvas: function initCanvas() {
1190
- var containerData = this.containerData,
1191
- imageData = this.imageData;
1192
- var viewMode = this.options.viewMode;
1193
- var rotated = Math.abs(imageData.rotate) % 180 === 90;
1194
- var naturalWidth = rotated ? imageData.naturalHeight : imageData.naturalWidth;
1195
- var naturalHeight = rotated ? imageData.naturalWidth : imageData.naturalHeight;
1196
- var aspectRatio = naturalWidth / naturalHeight;
1197
- var canvasWidth = containerData.width;
1198
- var canvasHeight = containerData.height;
1199
-
1200
- if (containerData.height * aspectRatio > containerData.width) {
1201
- if (viewMode === 3) {
1202
- canvasWidth = containerData.height * aspectRatio;
1203
- } else {
1204
- canvasHeight = containerData.width / aspectRatio;
1205
- }
1206
- } else if (viewMode === 3) {
1207
- canvasHeight = containerData.width / aspectRatio;
1208
- } else {
1209
- canvasWidth = containerData.height * aspectRatio;
1210
- }
1211
-
1212
- var canvasData = {
1213
- aspectRatio: aspectRatio,
1214
- naturalWidth: naturalWidth,
1215
- naturalHeight: naturalHeight,
1216
- width: canvasWidth,
1217
- height: canvasHeight
1218
- };
1219
- canvasData.left = (containerData.width - canvasWidth) / 2;
1220
- canvasData.top = (containerData.height - canvasHeight) / 2;
1221
- canvasData.oldLeft = canvasData.left;
1222
- canvasData.oldTop = canvasData.top;
1223
- this.canvasData = canvasData;
1224
- this.limited = viewMode === 1 || viewMode === 2;
1225
- this.limitCanvas(true, true);
1226
- this.initialImageData = assign({}, imageData);
1227
- this.initialCanvasData = assign({}, canvasData);
1228
- },
1229
- limitCanvas: function limitCanvas(sizeLimited, positionLimited) {
1230
- var options = this.options,
1231
- containerData = this.containerData,
1232
- canvasData = this.canvasData,
1233
- cropBoxData = this.cropBoxData;
1234
- var viewMode = options.viewMode;
1235
- var aspectRatio = canvasData.aspectRatio;
1236
- var cropped = this.cropped && cropBoxData;
1237
-
1238
- if (sizeLimited) {
1239
- var minCanvasWidth = Number(options.minCanvasWidth) || 0;
1240
- var minCanvasHeight = Number(options.minCanvasHeight) || 0;
1241
-
1242
- if (viewMode > 1) {
1243
- minCanvasWidth = Math.max(minCanvasWidth, containerData.width);
1244
- minCanvasHeight = Math.max(minCanvasHeight, containerData.height);
1245
-
1246
- if (viewMode === 3) {
1247
- if (minCanvasHeight * aspectRatio > minCanvasWidth) {
1248
- minCanvasWidth = minCanvasHeight * aspectRatio;
1249
- } else {
1250
- minCanvasHeight = minCanvasWidth / aspectRatio;
1251
- }
1252
- }
1253
- } else if (viewMode > 0) {
1254
- if (minCanvasWidth) {
1255
- minCanvasWidth = Math.max(minCanvasWidth, cropped ? cropBoxData.width : 0);
1256
- } else if (minCanvasHeight) {
1257
- minCanvasHeight = Math.max(minCanvasHeight, cropped ? cropBoxData.height : 0);
1258
- } else if (cropped) {
1259
- minCanvasWidth = cropBoxData.width;
1260
- minCanvasHeight = cropBoxData.height;
1261
-
1262
- if (minCanvasHeight * aspectRatio > minCanvasWidth) {
1263
- minCanvasWidth = minCanvasHeight * aspectRatio;
1264
- } else {
1265
- minCanvasHeight = minCanvasWidth / aspectRatio;
1266
- }
1267
- }
1268
- }
1269
-
1270
- var _getAdjustedSizes = getAdjustedSizes({
1271
- aspectRatio: aspectRatio,
1272
- width: minCanvasWidth,
1273
- height: minCanvasHeight
1274
- });
1275
-
1276
- minCanvasWidth = _getAdjustedSizes.width;
1277
- minCanvasHeight = _getAdjustedSizes.height;
1278
- canvasData.minWidth = minCanvasWidth;
1279
- canvasData.minHeight = minCanvasHeight;
1280
- canvasData.maxWidth = Infinity;
1281
- canvasData.maxHeight = Infinity;
1282
- }
1283
-
1284
- if (positionLimited) {
1285
- if (viewMode > (cropped ? 0 : 1)) {
1286
- var newCanvasLeft = containerData.width - canvasData.width;
1287
- var newCanvasTop = containerData.height - canvasData.height;
1288
- canvasData.minLeft = Math.min(0, newCanvasLeft);
1289
- canvasData.minTop = Math.min(0, newCanvasTop);
1290
- canvasData.maxLeft = Math.max(0, newCanvasLeft);
1291
- canvasData.maxTop = Math.max(0, newCanvasTop);
1292
-
1293
- if (cropped && this.limited) {
1294
- canvasData.minLeft = Math.min(cropBoxData.left, cropBoxData.left + (cropBoxData.width - canvasData.width));
1295
- canvasData.minTop = Math.min(cropBoxData.top, cropBoxData.top + (cropBoxData.height - canvasData.height));
1296
- canvasData.maxLeft = cropBoxData.left;
1297
- canvasData.maxTop = cropBoxData.top;
1298
-
1299
- if (viewMode === 2) {
1300
- if (canvasData.width >= containerData.width) {
1301
- canvasData.minLeft = Math.min(0, newCanvasLeft);
1302
- canvasData.maxLeft = Math.max(0, newCanvasLeft);
1303
- }
1304
-
1305
- if (canvasData.height >= containerData.height) {
1306
- canvasData.minTop = Math.min(0, newCanvasTop);
1307
- canvasData.maxTop = Math.max(0, newCanvasTop);
1308
- }
1309
- }
1310
- }
1311
- } else {
1312
- canvasData.minLeft = -canvasData.width;
1313
- canvasData.minTop = -canvasData.height;
1314
- canvasData.maxLeft = containerData.width;
1315
- canvasData.maxTop = containerData.height;
1316
- }
1317
- }
1318
- },
1319
- renderCanvas: function renderCanvas(changed, transformed) {
1320
- var canvasData = this.canvasData,
1321
- imageData = this.imageData;
1322
-
1323
- if (transformed) {
1324
- var _getRotatedSizes = getRotatedSizes({
1325
- width: imageData.naturalWidth * Math.abs(imageData.scaleX || 1),
1326
- height: imageData.naturalHeight * Math.abs(imageData.scaleY || 1),
1327
- degree: imageData.rotate || 0
1328
- }),
1329
- naturalWidth = _getRotatedSizes.width,
1330
- naturalHeight = _getRotatedSizes.height;
1331
-
1332
- var width = canvasData.width * (naturalWidth / canvasData.naturalWidth);
1333
- var height = canvasData.height * (naturalHeight / canvasData.naturalHeight);
1334
- canvasData.left -= (width - canvasData.width) / 2;
1335
- canvasData.top -= (height - canvasData.height) / 2;
1336
- canvasData.width = width;
1337
- canvasData.height = height;
1338
- canvasData.aspectRatio = naturalWidth / naturalHeight;
1339
- canvasData.naturalWidth = naturalWidth;
1340
- canvasData.naturalHeight = naturalHeight;
1341
- this.limitCanvas(true, false);
1342
- }
1343
-
1344
- if (canvasData.width > canvasData.maxWidth || canvasData.width < canvasData.minWidth) {
1345
- canvasData.left = canvasData.oldLeft;
1346
- }
1347
-
1348
- if (canvasData.height > canvasData.maxHeight || canvasData.height < canvasData.minHeight) {
1349
- canvasData.top = canvasData.oldTop;
1350
- }
1351
-
1352
- canvasData.width = Math.min(Math.max(canvasData.width, canvasData.minWidth), canvasData.maxWidth);
1353
- canvasData.height = Math.min(Math.max(canvasData.height, canvasData.minHeight), canvasData.maxHeight);
1354
- this.limitCanvas(false, true);
1355
- canvasData.left = Math.min(Math.max(canvasData.left, canvasData.minLeft), canvasData.maxLeft);
1356
- canvasData.top = Math.min(Math.max(canvasData.top, canvasData.minTop), canvasData.maxTop);
1357
- canvasData.oldLeft = canvasData.left;
1358
- canvasData.oldTop = canvasData.top;
1359
- setStyle(this.canvas, assign({
1360
- width: canvasData.width,
1361
- height: canvasData.height
1362
- }, getTransforms({
1363
- translateX: canvasData.left,
1364
- translateY: canvasData.top
1365
- })));
1366
- this.renderImage(changed);
1367
-
1368
- if (this.cropped && this.limited) {
1369
- this.limitCropBox(true, true);
1370
- }
1371
- },
1372
- renderImage: function renderImage(changed) {
1373
- var canvasData = this.canvasData,
1374
- imageData = this.imageData;
1375
- var width = imageData.naturalWidth * (canvasData.width / canvasData.naturalWidth);
1376
- var height = imageData.naturalHeight * (canvasData.height / canvasData.naturalHeight);
1377
- assign(imageData, {
1378
- width: width,
1379
- height: height,
1380
- left: (canvasData.width - width) / 2,
1381
- top: (canvasData.height - height) / 2
1382
- });
1383
- setStyle(this.image, assign({
1384
- width: imageData.width,
1385
- height: imageData.height
1386
- }, getTransforms(assign({
1387
- translateX: imageData.left,
1388
- translateY: imageData.top
1389
- }, imageData))));
1390
-
1391
- if (changed) {
1392
- this.output();
1393
- }
1394
- },
1395
- initCropBox: function initCropBox() {
1396
- var options = this.options,
1397
- canvasData = this.canvasData;
1398
- var aspectRatio = options.aspectRatio || options.initialAspectRatio;
1399
- var autoCropArea = Number(options.autoCropArea) || 0.8;
1400
- var cropBoxData = {
1401
- width: canvasData.width,
1402
- height: canvasData.height
1403
- };
1404
-
1405
- if (aspectRatio) {
1406
- if (canvasData.height * aspectRatio > canvasData.width) {
1407
- cropBoxData.height = cropBoxData.width / aspectRatio;
1408
- } else {
1409
- cropBoxData.width = cropBoxData.height * aspectRatio;
1410
- }
1411
- }
1412
-
1413
- this.cropBoxData = cropBoxData;
1414
- this.limitCropBox(true, true); // Initialize auto crop area
1415
-
1416
- cropBoxData.width = Math.min(Math.max(cropBoxData.width, cropBoxData.minWidth), cropBoxData.maxWidth);
1417
- cropBoxData.height = Math.min(Math.max(cropBoxData.height, cropBoxData.minHeight), cropBoxData.maxHeight); // The width/height of auto crop area must large than "minWidth/Height"
1418
-
1419
- cropBoxData.width = Math.max(cropBoxData.minWidth, cropBoxData.width * autoCropArea);
1420
- cropBoxData.height = Math.max(cropBoxData.minHeight, cropBoxData.height * autoCropArea);
1421
- cropBoxData.left = canvasData.left + (canvasData.width - cropBoxData.width) / 2;
1422
- cropBoxData.top = canvasData.top + (canvasData.height - cropBoxData.height) / 2;
1423
- cropBoxData.oldLeft = cropBoxData.left;
1424
- cropBoxData.oldTop = cropBoxData.top;
1425
- this.initialCropBoxData = assign({}, cropBoxData);
1426
- },
1427
- limitCropBox: function limitCropBox(sizeLimited, positionLimited) {
1428
- var options = this.options,
1429
- containerData = this.containerData,
1430
- canvasData = this.canvasData,
1431
- cropBoxData = this.cropBoxData,
1432
- limited = this.limited;
1433
- var aspectRatio = options.aspectRatio;
1434
-
1435
- if (sizeLimited) {
1436
- var minCropBoxWidth = Number(options.minCropBoxWidth) || 0;
1437
- var minCropBoxHeight = Number(options.minCropBoxHeight) || 0;
1438
- var maxCropBoxWidth = limited ? Math.min(containerData.width, canvasData.width, canvasData.width + canvasData.left, containerData.width - canvasData.left) : containerData.width;
1439
- var maxCropBoxHeight = limited ? Math.min(containerData.height, canvasData.height, canvasData.height + canvasData.top, containerData.height - canvasData.top) : containerData.height; // The min/maxCropBoxWidth/Height must be less than container's width/height
1440
-
1441
- minCropBoxWidth = Math.min(minCropBoxWidth, containerData.width);
1442
- minCropBoxHeight = Math.min(minCropBoxHeight, containerData.height);
1443
-
1444
- if (aspectRatio) {
1445
- if (minCropBoxWidth && minCropBoxHeight) {
1446
- if (minCropBoxHeight * aspectRatio > minCropBoxWidth) {
1447
- minCropBoxHeight = minCropBoxWidth / aspectRatio;
1448
- } else {
1449
- minCropBoxWidth = minCropBoxHeight * aspectRatio;
1450
- }
1451
- } else if (minCropBoxWidth) {
1452
- minCropBoxHeight = minCropBoxWidth / aspectRatio;
1453
- } else if (minCropBoxHeight) {
1454
- minCropBoxWidth = minCropBoxHeight * aspectRatio;
1455
- }
1456
-
1457
- if (maxCropBoxHeight * aspectRatio > maxCropBoxWidth) {
1458
- maxCropBoxHeight = maxCropBoxWidth / aspectRatio;
1459
- } else {
1460
- maxCropBoxWidth = maxCropBoxHeight * aspectRatio;
1461
- }
1462
- } // The minWidth/Height must be less than maxWidth/Height
1463
-
1464
-
1465
- cropBoxData.minWidth = Math.min(minCropBoxWidth, maxCropBoxWidth);
1466
- cropBoxData.minHeight = Math.min(minCropBoxHeight, maxCropBoxHeight);
1467
- cropBoxData.maxWidth = maxCropBoxWidth;
1468
- cropBoxData.maxHeight = maxCropBoxHeight;
1469
- }
1470
-
1471
- if (positionLimited) {
1472
- if (limited) {
1473
- cropBoxData.minLeft = Math.max(0, canvasData.left);
1474
- cropBoxData.minTop = Math.max(0, canvasData.top);
1475
- cropBoxData.maxLeft = Math.min(containerData.width, canvasData.left + canvasData.width) - cropBoxData.width;
1476
- cropBoxData.maxTop = Math.min(containerData.height, canvasData.top + canvasData.height) - cropBoxData.height;
1477
- } else {
1478
- cropBoxData.minLeft = 0;
1479
- cropBoxData.minTop = 0;
1480
- cropBoxData.maxLeft = containerData.width - cropBoxData.width;
1481
- cropBoxData.maxTop = containerData.height - cropBoxData.height;
1482
- }
1483
- }
1484
- },
1485
- renderCropBox: function renderCropBox() {
1486
- var options = this.options,
1487
- containerData = this.containerData,
1488
- cropBoxData = this.cropBoxData;
1489
-
1490
- if (cropBoxData.width > cropBoxData.maxWidth || cropBoxData.width < cropBoxData.minWidth) {
1491
- cropBoxData.left = cropBoxData.oldLeft;
1492
- }
1493
-
1494
- if (cropBoxData.height > cropBoxData.maxHeight || cropBoxData.height < cropBoxData.minHeight) {
1495
- cropBoxData.top = cropBoxData.oldTop;
1496
- }
1497
-
1498
- cropBoxData.width = Math.min(Math.max(cropBoxData.width, cropBoxData.minWidth), cropBoxData.maxWidth);
1499
- cropBoxData.height = Math.min(Math.max(cropBoxData.height, cropBoxData.minHeight), cropBoxData.maxHeight);
1500
- this.limitCropBox(false, true);
1501
- cropBoxData.left = Math.min(Math.max(cropBoxData.left, cropBoxData.minLeft), cropBoxData.maxLeft);
1502
- cropBoxData.top = Math.min(Math.max(cropBoxData.top, cropBoxData.minTop), cropBoxData.maxTop);
1503
- cropBoxData.oldLeft = cropBoxData.left;
1504
- cropBoxData.oldTop = cropBoxData.top;
1505
-
1506
- if (options.movable && options.cropBoxMovable) {
1507
- // Turn to move the canvas when the crop box is equal to the container
1508
- setData(this.face, DATA_ACTION, cropBoxData.width >= containerData.width && cropBoxData.height >= containerData.height ? ACTION_MOVE : ACTION_ALL);
1509
- }
1510
-
1511
- setStyle(this.cropBox, assign({
1512
- width: cropBoxData.width,
1513
- height: cropBoxData.height
1514
- }, getTransforms({
1515
- translateX: cropBoxData.left,
1516
- translateY: cropBoxData.top
1517
- })));
1518
-
1519
- if (this.cropped && this.limited) {
1520
- this.limitCanvas(true, true);
1521
- }
1522
-
1523
- if (!this.disabled) {
1524
- this.output();
1525
- }
1526
- },
1527
- output: function output() {
1528
- this.preview();
1529
- dispatchEvent(this.element, EVENT_CROP, this.getData());
1530
- }
1531
- };
1532
-
1533
- var preview = {
1534
- initPreview: function initPreview() {
1535
- var crossOrigin = this.crossOrigin;
1536
- var preview = this.options.preview;
1537
- var url = crossOrigin ? this.crossOriginUrl : this.url;
1538
- var image = document.createElement('img');
1539
-
1540
- if (crossOrigin) {
1541
- image.crossOrigin = crossOrigin;
1542
- }
1543
-
1544
- image.src = url;
1545
- this.viewBox.appendChild(image);
1546
- this.viewBoxImage = image;
1547
-
1548
- if (!preview) {
1549
- return;
1550
- }
1551
-
1552
- var previews = preview;
1553
-
1554
- if (typeof preview === 'string') {
1555
- previews = this.element.ownerDocument.querySelectorAll(preview);
1556
- } else if (preview.querySelector) {
1557
- previews = [preview];
1558
- }
1559
-
1560
- this.previews = previews;
1561
- forEach(previews, function (el) {
1562
- var img = document.createElement('img'); // Save the original size for recover
1563
-
1564
- setData(el, DATA_PREVIEW, {
1565
- width: el.offsetWidth,
1566
- height: el.offsetHeight,
1567
- html: el.innerHTML
1568
- });
1569
-
1570
- if (crossOrigin) {
1571
- img.crossOrigin = crossOrigin;
1572
- }
1573
-
1574
- img.src = url;
1575
- /**
1576
- * Override img element styles
1577
- * Add `display:block` to avoid margin top issue
1578
- * Add `height:auto` to override `height` attribute on IE8
1579
- * (Occur only when margin-top <= -height)
1580
- */
1581
-
1582
- img.style.cssText = 'display:block;' + 'width:100%;' + 'height:auto;' + 'min-width:0!important;' + 'min-height:0!important;' + 'max-width:none!important;' + 'max-height:none!important;' + 'image-orientation:0deg!important;"';
1583
- el.innerHTML = '';
1584
- el.appendChild(img);
1585
- });
1586
- },
1587
- resetPreview: function resetPreview() {
1588
- forEach(this.previews, function (element) {
1589
- var data = getData(element, DATA_PREVIEW);
1590
- setStyle(element, {
1591
- width: data.width,
1592
- height: data.height
1593
- });
1594
- element.innerHTML = data.html;
1595
- removeData(element, DATA_PREVIEW);
1596
- });
1597
- },
1598
- preview: function preview() {
1599
- var imageData = this.imageData,
1600
- canvasData = this.canvasData,
1601
- cropBoxData = this.cropBoxData;
1602
- var cropBoxWidth = cropBoxData.width,
1603
- cropBoxHeight = cropBoxData.height;
1604
- var width = imageData.width,
1605
- height = imageData.height;
1606
- var left = cropBoxData.left - canvasData.left - imageData.left;
1607
- var top = cropBoxData.top - canvasData.top - imageData.top;
1608
-
1609
- if (!this.cropped || this.disabled) {
1610
- return;
1611
- }
1612
-
1613
- setStyle(this.viewBoxImage, assign({
1614
- width: width,
1615
- height: height
1616
- }, getTransforms(assign({
1617
- translateX: -left,
1618
- translateY: -top
1619
- }, imageData))));
1620
- forEach(this.previews, function (element) {
1621
- var data = getData(element, DATA_PREVIEW);
1622
- var originalWidth = data.width;
1623
- var originalHeight = data.height;
1624
- var newWidth = originalWidth;
1625
- var newHeight = originalHeight;
1626
- var ratio = 1;
1627
-
1628
- if (cropBoxWidth) {
1629
- ratio = originalWidth / cropBoxWidth;
1630
- newHeight = cropBoxHeight * ratio;
1631
- }
1632
-
1633
- if (cropBoxHeight && newHeight > originalHeight) {
1634
- ratio = originalHeight / cropBoxHeight;
1635
- newWidth = cropBoxWidth * ratio;
1636
- newHeight = originalHeight;
1637
- }
1638
-
1639
- setStyle(element, {
1640
- width: newWidth,
1641
- height: newHeight
1642
- });
1643
- setStyle(element.getElementsByTagName('img')[0], assign({
1644
- width: width * ratio,
1645
- height: height * ratio
1646
- }, getTransforms(assign({
1647
- translateX: -left * ratio,
1648
- translateY: -top * ratio
1649
- }, imageData))));
1650
- });
1651
- }
1652
- };
1653
-
1654
- var events = {
1655
- bind: function bind() {
1656
- var element = this.element,
1657
- options = this.options,
1658
- cropper = this.cropper;
1659
-
1660
- if (isFunction(options.cropstart)) {
1661
- addListener(element, EVENT_CROP_START, options.cropstart);
1662
- }
1663
-
1664
- if (isFunction(options.cropmove)) {
1665
- addListener(element, EVENT_CROP_MOVE, options.cropmove);
1666
- }
1667
-
1668
- if (isFunction(options.cropend)) {
1669
- addListener(element, EVENT_CROP_END, options.cropend);
1670
- }
1671
-
1672
- if (isFunction(options.crop)) {
1673
- addListener(element, EVENT_CROP, options.crop);
1674
- }
1675
-
1676
- if (isFunction(options.zoom)) {
1677
- addListener(element, EVENT_ZOOM, options.zoom);
1678
- }
1679
-
1680
- addListener(cropper, EVENT_POINTER_DOWN, this.onCropStart = this.cropStart.bind(this));
1681
-
1682
- if (options.zoomable && options.zoomOnWheel) {
1683
- addListener(cropper, EVENT_WHEEL, this.onWheel = this.wheel.bind(this), {
1684
- passive: false,
1685
- capture: true
1686
- });
1687
- }
1688
-
1689
- if (options.toggleDragModeOnDblclick) {
1690
- addListener(cropper, EVENT_DBLCLICK, this.onDblclick = this.dblclick.bind(this));
1691
- }
1692
-
1693
- addListener(element.ownerDocument, EVENT_POINTER_MOVE, this.onCropMove = this.cropMove.bind(this));
1694
- addListener(element.ownerDocument, EVENT_POINTER_UP, this.onCropEnd = this.cropEnd.bind(this));
1695
-
1696
- if (options.responsive) {
1697
- addListener(window, EVENT_RESIZE, this.onResize = this.resize.bind(this));
1698
- }
1699
- },
1700
- unbind: function unbind() {
1701
- var element = this.element,
1702
- options = this.options,
1703
- cropper = this.cropper;
1704
-
1705
- if (isFunction(options.cropstart)) {
1706
- removeListener(element, EVENT_CROP_START, options.cropstart);
1707
- }
1708
-
1709
- if (isFunction(options.cropmove)) {
1710
- removeListener(element, EVENT_CROP_MOVE, options.cropmove);
1711
- }
1712
-
1713
- if (isFunction(options.cropend)) {
1714
- removeListener(element, EVENT_CROP_END, options.cropend);
1715
- }
1716
-
1717
- if (isFunction(options.crop)) {
1718
- removeListener(element, EVENT_CROP, options.crop);
1719
- }
1720
-
1721
- if (isFunction(options.zoom)) {
1722
- removeListener(element, EVENT_ZOOM, options.zoom);
1723
- }
1724
-
1725
- removeListener(cropper, EVENT_POINTER_DOWN, this.onCropStart);
1726
-
1727
- if (options.zoomable && options.zoomOnWheel) {
1728
- removeListener(cropper, EVENT_WHEEL, this.onWheel, {
1729
- passive: false,
1730
- capture: true
1731
- });
1732
- }
1733
-
1734
- if (options.toggleDragModeOnDblclick) {
1735
- removeListener(cropper, EVENT_DBLCLICK, this.onDblclick);
1736
- }
1737
-
1738
- removeListener(element.ownerDocument, EVENT_POINTER_MOVE, this.onCropMove);
1739
- removeListener(element.ownerDocument, EVENT_POINTER_UP, this.onCropEnd);
1740
-
1741
- if (options.responsive) {
1742
- removeListener(window, EVENT_RESIZE, this.onResize);
1743
- }
1744
- }
1745
- };
1746
-
1747
- var handlers = {
1748
- resize: function resize() {
1749
- var options = this.options,
1750
- container = this.container,
1751
- containerData = this.containerData;
1752
- var minContainerWidth = Number(options.minContainerWidth) || MIN_CONTAINER_WIDTH;
1753
- var minContainerHeight = Number(options.minContainerHeight) || MIN_CONTAINER_HEIGHT;
1754
-
1755
- if (this.disabled || containerData.width <= minContainerWidth || containerData.height <= minContainerHeight) {
1756
- return;
1757
- }
1758
-
1759
- var ratio = container.offsetWidth / containerData.width; // Resize when width changed or height changed
1760
-
1761
- if (ratio !== 1 || container.offsetHeight !== containerData.height) {
1762
- var canvasData;
1763
- var cropBoxData;
1764
-
1765
- if (options.restore) {
1766
- canvasData = this.getCanvasData();
1767
- cropBoxData = this.getCropBoxData();
1768
- }
1769
-
1770
- this.render();
1771
-
1772
- if (options.restore) {
1773
- this.setCanvasData(forEach(canvasData, function (n, i) {
1774
- canvasData[i] = n * ratio;
1775
- }));
1776
- this.setCropBoxData(forEach(cropBoxData, function (n, i) {
1777
- cropBoxData[i] = n * ratio;
1778
- }));
1779
- }
1780
- }
1781
- },
1782
- dblclick: function dblclick() {
1783
- if (this.disabled || this.options.dragMode === DRAG_MODE_NONE) {
1784
- return;
1785
- }
1786
-
1787
- this.setDragMode(hasClass(this.dragBox, CLASS_CROP) ? DRAG_MODE_MOVE : DRAG_MODE_CROP);
1788
- },
1789
- wheel: function wheel(event) {
1790
- var _this = this;
1791
-
1792
- var ratio = Number(this.options.wheelZoomRatio) || 0.1;
1793
- var delta = 1;
1794
-
1795
- if (this.disabled) {
1796
- return;
1797
- }
1798
-
1799
- event.preventDefault(); // Limit wheel speed to prevent zoom too fast (#21)
1800
-
1801
- if (this.wheeling) {
1802
- return;
1803
- }
1804
-
1805
- this.wheeling = true;
1806
- setTimeout(function () {
1807
- _this.wheeling = false;
1808
- }, 50);
1809
-
1810
- if (event.deltaY) {
1811
- delta = event.deltaY > 0 ? 1 : -1;
1812
- } else if (event.wheelDelta) {
1813
- delta = -event.wheelDelta / 120;
1814
- } else if (event.detail) {
1815
- delta = event.detail > 0 ? 1 : -1;
1816
- }
1817
-
1818
- this.zoom(-delta * ratio, event);
1819
- },
1820
- cropStart: function cropStart(event) {
1821
- var buttons = event.buttons,
1822
- button = event.button;
1823
-
1824
- if (this.disabled // No primary button (Usually the left button)
1825
- // Note that touch events have no `buttons` or `button` property
1826
- || isNumber(buttons) && buttons !== 1 || isNumber(button) && button !== 0 // Open context menu
1827
- || event.ctrlKey) {
1828
- return;
1829
- }
1830
-
1831
- var options = this.options,
1832
- pointers = this.pointers;
1833
- var action;
1834
-
1835
- if (event.changedTouches) {
1836
- // Handle touch event
1837
- forEach(event.changedTouches, function (touch) {
1838
- pointers[touch.identifier] = getPointer(touch);
1839
- });
1840
- } else {
1841
- // Handle mouse event and pointer event
1842
- pointers[event.pointerId || 0] = getPointer(event);
1843
- }
1844
-
1845
- if (Object.keys(pointers).length > 1 && options.zoomable && options.zoomOnTouch) {
1846
- action = ACTION_ZOOM;
1847
- } else {
1848
- action = getData(event.target, DATA_ACTION);
1849
- }
1850
-
1851
- if (!REGEXP_ACTIONS.test(action)) {
1852
- return;
1853
- }
1854
-
1855
- if (dispatchEvent(this.element, EVENT_CROP_START, {
1856
- originalEvent: event,
1857
- action: action
1858
- }) === false) {
1859
- return;
1860
- } // This line is required for preventing page zooming in iOS browsers
1861
-
1862
-
1863
- event.preventDefault();
1864
- this.action = action;
1865
- this.cropping = false;
1866
-
1867
- if (action === ACTION_CROP) {
1868
- this.cropping = true;
1869
- addClass(this.dragBox, CLASS_MODAL);
1870
- }
1871
- },
1872
- cropMove: function cropMove(event) {
1873
- var action = this.action;
1874
-
1875
- if (this.disabled || !action) {
1876
- return;
1877
- }
1878
-
1879
- var pointers = this.pointers;
1880
- event.preventDefault();
1881
-
1882
- if (dispatchEvent(this.element, EVENT_CROP_MOVE, {
1883
- originalEvent: event,
1884
- action: action
1885
- }) === false) {
1886
- return;
1887
- }
1888
-
1889
- if (event.changedTouches) {
1890
- forEach(event.changedTouches, function (touch) {
1891
- // The first parameter should not be undefined (#432)
1892
- assign(pointers[touch.identifier] || {}, getPointer(touch, true));
1893
- });
1894
- } else {
1895
- assign(pointers[event.pointerId || 0] || {}, getPointer(event, true));
1896
- }
1897
-
1898
- this.change(event);
1899
- },
1900
- cropEnd: function cropEnd(event) {
1901
- if (this.disabled) {
1902
- return;
1903
- }
1904
-
1905
- var action = this.action,
1906
- pointers = this.pointers;
1907
-
1908
- if (event.changedTouches) {
1909
- forEach(event.changedTouches, function (touch) {
1910
- delete pointers[touch.identifier];
1911
- });
1912
- } else {
1913
- delete pointers[event.pointerId || 0];
1914
- }
1915
-
1916
- if (!action) {
1917
- return;
1918
- }
1919
-
1920
- event.preventDefault();
1921
-
1922
- if (!Object.keys(pointers).length) {
1923
- this.action = '';
1924
- }
1925
-
1926
- if (this.cropping) {
1927
- this.cropping = false;
1928
- toggleClass(this.dragBox, CLASS_MODAL, this.cropped && this.options.modal);
1929
- }
1930
-
1931
- dispatchEvent(this.element, EVENT_CROP_END, {
1932
- originalEvent: event,
1933
- action: action
1934
- });
1935
- }
1936
- };
1937
-
1938
- var change = {
1939
- change: function change(event) {
1940
- var options = this.options,
1941
- canvasData = this.canvasData,
1942
- containerData = this.containerData,
1943
- cropBoxData = this.cropBoxData,
1944
- pointers = this.pointers;
1945
- var action = this.action;
1946
- var aspectRatio = options.aspectRatio;
1947
- var left = cropBoxData.left,
1948
- top = cropBoxData.top,
1949
- width = cropBoxData.width,
1950
- height = cropBoxData.height;
1951
- var right = left + width;
1952
- var bottom = top + height;
1953
- var minLeft = 0;
1954
- var minTop = 0;
1955
- var maxWidth = containerData.width;
1956
- var maxHeight = containerData.height;
1957
- var renderable = true;
1958
- var offset; // Locking aspect ratio in "free mode" by holding shift key
1959
-
1960
- if (!aspectRatio && event.shiftKey) {
1961
- aspectRatio = width && height ? width / height : 1;
1962
- }
1963
-
1964
- if (this.limited) {
1965
- minLeft = cropBoxData.minLeft;
1966
- minTop = cropBoxData.minTop;
1967
- maxWidth = minLeft + Math.min(containerData.width, canvasData.width, canvasData.left + canvasData.width);
1968
- maxHeight = minTop + Math.min(containerData.height, canvasData.height, canvasData.top + canvasData.height);
1969
- }
1970
-
1971
- var pointer = pointers[Object.keys(pointers)[0]];
1972
- var range = {
1973
- x: pointer.endX - pointer.startX,
1974
- y: pointer.endY - pointer.startY
1975
- };
1976
-
1977
- var check = function check(side) {
1978
- switch (side) {
1979
- case ACTION_EAST:
1980
- if (right + range.x > maxWidth) {
1981
- range.x = maxWidth - right;
1982
- }
1983
-
1984
- break;
1985
-
1986
- case ACTION_WEST:
1987
- if (left + range.x < minLeft) {
1988
- range.x = minLeft - left;
1989
- }
1990
-
1991
- break;
1992
-
1993
- case ACTION_NORTH:
1994
- if (top + range.y < minTop) {
1995
- range.y = minTop - top;
1996
- }
1997
-
1998
- break;
1999
-
2000
- case ACTION_SOUTH:
2001
- if (bottom + range.y > maxHeight) {
2002
- range.y = maxHeight - bottom;
2003
- }
2004
-
2005
- break;
2006
-
2007
- default:
2008
- }
2009
- };
2010
-
2011
- switch (action) {
2012
- // Move crop box
2013
- case ACTION_ALL:
2014
- left += range.x;
2015
- top += range.y;
2016
- break;
2017
- // Resize crop box
2018
-
2019
- case ACTION_EAST:
2020
- if (range.x >= 0 && (right >= maxWidth || aspectRatio && (top <= minTop || bottom >= maxHeight))) {
2021
- renderable = false;
2022
- break;
2023
- }
2024
-
2025
- check(ACTION_EAST);
2026
- width += range.x;
2027
-
2028
- if (width < 0) {
2029
- action = ACTION_WEST;
2030
- width = -width;
2031
- left -= width;
2032
- }
2033
-
2034
- if (aspectRatio) {
2035
- height = width / aspectRatio;
2036
- top += (cropBoxData.height - height) / 2;
2037
- }
2038
-
2039
- break;
2040
-
2041
- case ACTION_NORTH:
2042
- if (range.y <= 0 && (top <= minTop || aspectRatio && (left <= minLeft || right >= maxWidth))) {
2043
- renderable = false;
2044
- break;
2045
- }
2046
-
2047
- check(ACTION_NORTH);
2048
- height -= range.y;
2049
- top += range.y;
2050
-
2051
- if (height < 0) {
2052
- action = ACTION_SOUTH;
2053
- height = -height;
2054
- top -= height;
2055
- }
2056
-
2057
- if (aspectRatio) {
2058
- width = height * aspectRatio;
2059
- left += (cropBoxData.width - width) / 2;
2060
- }
2061
-
2062
- break;
2063
-
2064
- case ACTION_WEST:
2065
- if (range.x <= 0 && (left <= minLeft || aspectRatio && (top <= minTop || bottom >= maxHeight))) {
2066
- renderable = false;
2067
- break;
2068
- }
2069
-
2070
- check(ACTION_WEST);
2071
- width -= range.x;
2072
- left += range.x;
2073
-
2074
- if (width < 0) {
2075
- action = ACTION_EAST;
2076
- width = -width;
2077
- left -= width;
2078
- }
2079
-
2080
- if (aspectRatio) {
2081
- height = width / aspectRatio;
2082
- top += (cropBoxData.height - height) / 2;
2083
- }
2084
-
2085
- break;
2086
-
2087
- case ACTION_SOUTH:
2088
- if (range.y >= 0 && (bottom >= maxHeight || aspectRatio && (left <= minLeft || right >= maxWidth))) {
2089
- renderable = false;
2090
- break;
2091
- }
2092
-
2093
- check(ACTION_SOUTH);
2094
- height += range.y;
2095
-
2096
- if (height < 0) {
2097
- action = ACTION_NORTH;
2098
- height = -height;
2099
- top -= height;
2100
- }
2101
-
2102
- if (aspectRatio) {
2103
- width = height * aspectRatio;
2104
- left += (cropBoxData.width - width) / 2;
2105
- }
2106
-
2107
- break;
2108
-
2109
- case ACTION_NORTH_EAST:
2110
- if (aspectRatio) {
2111
- if (range.y <= 0 && (top <= minTop || right >= maxWidth)) {
2112
- renderable = false;
2113
- break;
2114
- }
2115
-
2116
- check(ACTION_NORTH);
2117
- height -= range.y;
2118
- top += range.y;
2119
- width = height * aspectRatio;
2120
- } else {
2121
- check(ACTION_NORTH);
2122
- check(ACTION_EAST);
2123
-
2124
- if (range.x >= 0) {
2125
- if (right < maxWidth) {
2126
- width += range.x;
2127
- } else if (range.y <= 0 && top <= minTop) {
2128
- renderable = false;
2129
- }
2130
- } else {
2131
- width += range.x;
2132
- }
2133
-
2134
- if (range.y <= 0) {
2135
- if (top > minTop) {
2136
- height -= range.y;
2137
- top += range.y;
2138
- }
2139
- } else {
2140
- height -= range.y;
2141
- top += range.y;
2142
- }
2143
- }
2144
-
2145
- if (width < 0 && height < 0) {
2146
- action = ACTION_SOUTH_WEST;
2147
- height = -height;
2148
- width = -width;
2149
- top -= height;
2150
- left -= width;
2151
- } else if (width < 0) {
2152
- action = ACTION_NORTH_WEST;
2153
- width = -width;
2154
- left -= width;
2155
- } else if (height < 0) {
2156
- action = ACTION_SOUTH_EAST;
2157
- height = -height;
2158
- top -= height;
2159
- }
2160
-
2161
- break;
2162
-
2163
- case ACTION_NORTH_WEST:
2164
- if (aspectRatio) {
2165
- if (range.y <= 0 && (top <= minTop || left <= minLeft)) {
2166
- renderable = false;
2167
- break;
2168
- }
2169
-
2170
- check(ACTION_NORTH);
2171
- height -= range.y;
2172
- top += range.y;
2173
- width = height * aspectRatio;
2174
- left += cropBoxData.width - width;
2175
- } else {
2176
- check(ACTION_NORTH);
2177
- check(ACTION_WEST);
2178
-
2179
- if (range.x <= 0) {
2180
- if (left > minLeft) {
2181
- width -= range.x;
2182
- left += range.x;
2183
- } else if (range.y <= 0 && top <= minTop) {
2184
- renderable = false;
2185
- }
2186
- } else {
2187
- width -= range.x;
2188
- left += range.x;
2189
- }
2190
-
2191
- if (range.y <= 0) {
2192
- if (top > minTop) {
2193
- height -= range.y;
2194
- top += range.y;
2195
- }
2196
- } else {
2197
- height -= range.y;
2198
- top += range.y;
2199
- }
2200
- }
2201
-
2202
- if (width < 0 && height < 0) {
2203
- action = ACTION_SOUTH_EAST;
2204
- height = -height;
2205
- width = -width;
2206
- top -= height;
2207
- left -= width;
2208
- } else if (width < 0) {
2209
- action = ACTION_NORTH_EAST;
2210
- width = -width;
2211
- left -= width;
2212
- } else if (height < 0) {
2213
- action = ACTION_SOUTH_WEST;
2214
- height = -height;
2215
- top -= height;
2216
- }
2217
-
2218
- break;
2219
-
2220
- case ACTION_SOUTH_WEST:
2221
- if (aspectRatio) {
2222
- if (range.x <= 0 && (left <= minLeft || bottom >= maxHeight)) {
2223
- renderable = false;
2224
- break;
2225
- }
2226
-
2227
- check(ACTION_WEST);
2228
- width -= range.x;
2229
- left += range.x;
2230
- height = width / aspectRatio;
2231
- } else {
2232
- check(ACTION_SOUTH);
2233
- check(ACTION_WEST);
2234
-
2235
- if (range.x <= 0) {
2236
- if (left > minLeft) {
2237
- width -= range.x;
2238
- left += range.x;
2239
- } else if (range.y >= 0 && bottom >= maxHeight) {
2240
- renderable = false;
2241
- }
2242
- } else {
2243
- width -= range.x;
2244
- left += range.x;
2245
- }
2246
-
2247
- if (range.y >= 0) {
2248
- if (bottom < maxHeight) {
2249
- height += range.y;
2250
- }
2251
- } else {
2252
- height += range.y;
2253
- }
2254
- }
2255
-
2256
- if (width < 0 && height < 0) {
2257
- action = ACTION_NORTH_EAST;
2258
- height = -height;
2259
- width = -width;
2260
- top -= height;
2261
- left -= width;
2262
- } else if (width < 0) {
2263
- action = ACTION_SOUTH_EAST;
2264
- width = -width;
2265
- left -= width;
2266
- } else if (height < 0) {
2267
- action = ACTION_NORTH_WEST;
2268
- height = -height;
2269
- top -= height;
2270
- }
2271
-
2272
- break;
2273
-
2274
- case ACTION_SOUTH_EAST:
2275
- if (aspectRatio) {
2276
- if (range.x >= 0 && (right >= maxWidth || bottom >= maxHeight)) {
2277
- renderable = false;
2278
- break;
2279
- }
2280
-
2281
- check(ACTION_EAST);
2282
- width += range.x;
2283
- height = width / aspectRatio;
2284
- } else {
2285
- check(ACTION_SOUTH);
2286
- check(ACTION_EAST);
2287
-
2288
- if (range.x >= 0) {
2289
- if (right < maxWidth) {
2290
- width += range.x;
2291
- } else if (range.y >= 0 && bottom >= maxHeight) {
2292
- renderable = false;
2293
- }
2294
- } else {
2295
- width += range.x;
2296
- }
2297
-
2298
- if (range.y >= 0) {
2299
- if (bottom < maxHeight) {
2300
- height += range.y;
2301
- }
2302
- } else {
2303
- height += range.y;
2304
- }
2305
- }
2306
-
2307
- if (width < 0 && height < 0) {
2308
- action = ACTION_NORTH_WEST;
2309
- height = -height;
2310
- width = -width;
2311
- top -= height;
2312
- left -= width;
2313
- } else if (width < 0) {
2314
- action = ACTION_SOUTH_WEST;
2315
- width = -width;
2316
- left -= width;
2317
- } else if (height < 0) {
2318
- action = ACTION_NORTH_EAST;
2319
- height = -height;
2320
- top -= height;
2321
- }
2322
-
2323
- break;
2324
- // Move canvas
2325
-
2326
- case ACTION_MOVE:
2327
- this.move(range.x, range.y);
2328
- renderable = false;
2329
- break;
2330
- // Zoom canvas
2331
-
2332
- case ACTION_ZOOM:
2333
- this.zoom(getMaxZoomRatio(pointers), event);
2334
- renderable = false;
2335
- break;
2336
- // Create crop box
2337
-
2338
- case ACTION_CROP:
2339
- if (!range.x || !range.y) {
2340
- renderable = false;
2341
- break;
2342
- }
2343
-
2344
- offset = getOffset(this.cropper);
2345
- left = pointer.startX - offset.left;
2346
- top = pointer.startY - offset.top;
2347
- width = cropBoxData.minWidth;
2348
- height = cropBoxData.minHeight;
2349
-
2350
- if (range.x > 0) {
2351
- action = range.y > 0 ? ACTION_SOUTH_EAST : ACTION_NORTH_EAST;
2352
- } else if (range.x < 0) {
2353
- left -= width;
2354
- action = range.y > 0 ? ACTION_SOUTH_WEST : ACTION_NORTH_WEST;
2355
- }
2356
-
2357
- if (range.y < 0) {
2358
- top -= height;
2359
- } // Show the crop box if is hidden
2360
-
2361
-
2362
- if (!this.cropped) {
2363
- removeClass(this.cropBox, CLASS_HIDDEN);
2364
- this.cropped = true;
2365
-
2366
- if (this.limited) {
2367
- this.limitCropBox(true, true);
2368
- }
2369
- }
2370
-
2371
- break;
2372
-
2373
- default:
2374
- }
2375
-
2376
- if (renderable) {
2377
- cropBoxData.width = width;
2378
- cropBoxData.height = height;
2379
- cropBoxData.left = left;
2380
- cropBoxData.top = top;
2381
- this.action = action;
2382
- this.renderCropBox();
2383
- } // Override
2384
-
2385
-
2386
- forEach(pointers, function (p) {
2387
- p.startX = p.endX;
2388
- p.startY = p.endY;
2389
- });
2390
- }
2391
- };
2392
-
2393
- var methods = {
2394
- // Show the crop box manually
2395
- crop: function crop() {
2396
- if (this.ready && !this.cropped && !this.disabled) {
2397
- this.cropped = true;
2398
- this.limitCropBox(true, true);
2399
-
2400
- if (this.options.modal) {
2401
- addClass(this.dragBox, CLASS_MODAL);
2402
- }
2403
-
2404
- removeClass(this.cropBox, CLASS_HIDDEN);
2405
- this.setCropBoxData(this.initialCropBoxData);
2406
- }
2407
-
2408
- return this;
2409
- },
2410
- // Reset the image and crop box to their initial states
2411
- reset: function reset() {
2412
- if (this.ready && !this.disabled) {
2413
- this.imageData = assign({}, this.initialImageData);
2414
- this.canvasData = assign({}, this.initialCanvasData);
2415
- this.cropBoxData = assign({}, this.initialCropBoxData);
2416
- this.renderCanvas();
2417
-
2418
- if (this.cropped) {
2419
- this.renderCropBox();
2420
- }
2421
- }
2422
-
2423
- return this;
2424
- },
2425
- // Clear the crop box
2426
- clear: function clear() {
2427
- if (this.cropped && !this.disabled) {
2428
- assign(this.cropBoxData, {
2429
- left: 0,
2430
- top: 0,
2431
- width: 0,
2432
- height: 0
2433
- });
2434
- this.cropped = false;
2435
- this.renderCropBox();
2436
- this.limitCanvas(true, true); // Render canvas after crop box rendered
2437
-
2438
- this.renderCanvas();
2439
- removeClass(this.dragBox, CLASS_MODAL);
2440
- addClass(this.cropBox, CLASS_HIDDEN);
2441
- }
2442
-
2443
- return this;
2444
- },
2445
-
2446
- /**
2447
- * Replace the image's src and rebuild the cropper
2448
- * @param {string} url - The new URL.
2449
- * @param {boolean} [hasSameSize] - Indicate if the new image has the same size as the old one.
2450
- * @returns {Cropper} this
2451
- */
2452
- replace: function replace(url) {
2453
- var hasSameSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
2454
-
2455
- if (!this.disabled && url) {
2456
- if (this.isImg) {
2457
- this.element.src = url;
2458
- }
2459
-
2460
- if (hasSameSize) {
2461
- this.url = url;
2462
- this.image.src = url;
2463
-
2464
- if (this.ready) {
2465
- this.viewBoxImage.src = url;
2466
- forEach(this.previews, function (element) {
2467
- element.getElementsByTagName('img')[0].src = url;
2468
- });
2469
- }
2470
- } else {
2471
- if (this.isImg) {
2472
- this.replaced = true;
2473
- }
2474
-
2475
- this.options.data = null;
2476
- this.uncreate();
2477
- this.load(url);
2478
- }
2479
- }
2480
-
2481
- return this;
2482
- },
2483
- // Enable (unfreeze) the cropper
2484
- enable: function enable() {
2485
- if (this.ready && this.disabled) {
2486
- this.disabled = false;
2487
- removeClass(this.cropper, CLASS_DISABLED);
2488
- }
2489
-
2490
- return this;
2491
- },
2492
- // Disable (freeze) the cropper
2493
- disable: function disable() {
2494
- if (this.ready && !this.disabled) {
2495
- this.disabled = true;
2496
- addClass(this.cropper, CLASS_DISABLED);
2497
- }
2498
-
2499
- return this;
2500
- },
2501
-
2502
- /**
2503
- * Destroy the cropper and remove the instance from the image
2504
- * @returns {Cropper} this
2505
- */
2506
- destroy: function destroy() {
2507
- var element = this.element;
2508
-
2509
- if (!element[NAMESPACE]) {
2510
- return this;
2511
- }
2512
-
2513
- element[NAMESPACE] = undefined;
2514
-
2515
- if (this.isImg && this.replaced) {
2516
- element.src = this.originalUrl;
2517
- }
2518
-
2519
- this.uncreate();
2520
- return this;
2521
- },
2522
-
2523
- /**
2524
- * Move the canvas with relative offsets
2525
- * @param {number} offsetX - The relative offset distance on the x-axis.
2526
- * @param {number} [offsetY=offsetX] - The relative offset distance on the y-axis.
2527
- * @returns {Cropper} this
2528
- */
2529
- move: function move(offsetX) {
2530
- var offsetY = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : offsetX;
2531
- var _this$canvasData = this.canvasData,
2532
- left = _this$canvasData.left,
2533
- top = _this$canvasData.top;
2534
- return this.moveTo(isUndefined(offsetX) ? offsetX : left + Number(offsetX), isUndefined(offsetY) ? offsetY : top + Number(offsetY));
2535
- },
2536
-
2537
- /**
2538
- * Move the canvas to an absolute point
2539
- * @param {number} x - The x-axis coordinate.
2540
- * @param {number} [y=x] - The y-axis coordinate.
2541
- * @returns {Cropper} this
2542
- */
2543
- moveTo: function moveTo(x) {
2544
- var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : x;
2545
- var canvasData = this.canvasData;
2546
- var changed = false;
2547
- x = Number(x);
2548
- y = Number(y);
2549
-
2550
- if (this.ready && !this.disabled && this.options.movable) {
2551
- if (isNumber(x)) {
2552
- canvasData.left = x;
2553
- changed = true;
2554
- }
2555
-
2556
- if (isNumber(y)) {
2557
- canvasData.top = y;
2558
- changed = true;
2559
- }
2560
-
2561
- if (changed) {
2562
- this.renderCanvas(true);
2563
- }
2564
- }
2565
-
2566
- return this;
2567
- },
2568
-
2569
- /**
2570
- * Zoom the canvas with a relative ratio
2571
- * @param {number} ratio - The target ratio.
2572
- * @param {Event} _originalEvent - The original event if any.
2573
- * @returns {Cropper} this
2574
- */
2575
- zoom: function zoom(ratio, _originalEvent) {
2576
- var canvasData = this.canvasData;
2577
- ratio = Number(ratio);
2578
-
2579
- if (ratio < 0) {
2580
- ratio = 1 / (1 - ratio);
2581
- } else {
2582
- ratio = 1 + ratio;
2583
- }
2584
-
2585
- return this.zoomTo(canvasData.width * ratio / canvasData.naturalWidth, null, _originalEvent);
2586
- },
2587
-
2588
- /**
2589
- * Zoom the canvas to an absolute ratio
2590
- * @param {number} ratio - The target ratio.
2591
- * @param {Object} pivot - The zoom pivot point coordinate.
2592
- * @param {Event} _originalEvent - The original event if any.
2593
- * @returns {Cropper} this
2594
- */
2595
- zoomTo: function zoomTo(ratio, pivot, _originalEvent) {
2596
- var options = this.options,
2597
- canvasData = this.canvasData;
2598
- var width = canvasData.width,
2599
- height = canvasData.height,
2600
- naturalWidth = canvasData.naturalWidth,
2601
- naturalHeight = canvasData.naturalHeight;
2602
- ratio = Number(ratio);
2603
-
2604
- if (ratio >= 0 && this.ready && !this.disabled && options.zoomable) {
2605
- var newWidth = naturalWidth * ratio;
2606
- var newHeight = naturalHeight * ratio;
2607
-
2608
- if (dispatchEvent(this.element, EVENT_ZOOM, {
2609
- ratio: ratio,
2610
- oldRatio: width / naturalWidth,
2611
- originalEvent: _originalEvent
2612
- }) === false) {
2613
- return this;
2614
- }
2615
-
2616
- if (_originalEvent) {
2617
- var pointers = this.pointers;
2618
- var offset = getOffset(this.cropper);
2619
- var center = pointers && Object.keys(pointers).length ? getPointersCenter(pointers) : {
2620
- pageX: _originalEvent.pageX,
2621
- pageY: _originalEvent.pageY
2622
- }; // Zoom from the triggering point of the event
2623
-
2624
- canvasData.left -= (newWidth - width) * ((center.pageX - offset.left - canvasData.left) / width);
2625
- canvasData.top -= (newHeight - height) * ((center.pageY - offset.top - canvasData.top) / height);
2626
- } else if (isPlainObject(pivot) && isNumber(pivot.x) && isNumber(pivot.y)) {
2627
- canvasData.left -= (newWidth - width) * ((pivot.x - canvasData.left) / width);
2628
- canvasData.top -= (newHeight - height) * ((pivot.y - canvasData.top) / height);
2629
- } else {
2630
- // Zoom from the center of the canvas
2631
- canvasData.left -= (newWidth - width) / 2;
2632
- canvasData.top -= (newHeight - height) / 2;
2633
- }
2634
-
2635
- canvasData.width = newWidth;
2636
- canvasData.height = newHeight;
2637
- this.renderCanvas(true);
2638
- }
2639
-
2640
- return this;
2641
- },
2642
-
2643
- /**
2644
- * Rotate the canvas with a relative degree
2645
- * @param {number} degree - The rotate degree.
2646
- * @returns {Cropper} this
2647
- */
2648
- rotate: function rotate(degree) {
2649
- return this.rotateTo((this.imageData.rotate || 0) + Number(degree));
2650
- },
2651
-
2652
- /**
2653
- * Rotate the canvas to an absolute degree
2654
- * @param {number} degree - The rotate degree.
2655
- * @returns {Cropper} this
2656
- */
2657
- rotateTo: function rotateTo(degree) {
2658
- degree = Number(degree);
2659
-
2660
- if (isNumber(degree) && this.ready && !this.disabled && this.options.rotatable) {
2661
- this.imageData.rotate = degree % 360;
2662
- this.renderCanvas(true, true);
2663
- }
2664
-
2665
- return this;
2666
- },
2667
-
2668
- /**
2669
- * Scale the image on the x-axis.
2670
- * @param {number} scaleX - The scale ratio on the x-axis.
2671
- * @returns {Cropper} this
2672
- */
2673
- scaleX: function scaleX(_scaleX) {
2674
- var scaleY = this.imageData.scaleY;
2675
- return this.scale(_scaleX, isNumber(scaleY) ? scaleY : 1);
2676
- },
2677
-
2678
- /**
2679
- * Scale the image on the y-axis.
2680
- * @param {number} scaleY - The scale ratio on the y-axis.
2681
- * @returns {Cropper} this
2682
- */
2683
- scaleY: function scaleY(_scaleY) {
2684
- var scaleX = this.imageData.scaleX;
2685
- return this.scale(isNumber(scaleX) ? scaleX : 1, _scaleY);
2686
- },
2687
-
2688
- /**
2689
- * Scale the image
2690
- * @param {number} scaleX - The scale ratio on the x-axis.
2691
- * @param {number} [scaleY=scaleX] - The scale ratio on the y-axis.
2692
- * @returns {Cropper} this
2693
- */
2694
- scale: function scale(scaleX) {
2695
- var scaleY = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : scaleX;
2696
- var imageData = this.imageData;
2697
- var transformed = false;
2698
- scaleX = Number(scaleX);
2699
- scaleY = Number(scaleY);
2700
-
2701
- if (this.ready && !this.disabled && this.options.scalable) {
2702
- if (isNumber(scaleX)) {
2703
- imageData.scaleX = scaleX;
2704
- transformed = true;
2705
- }
2706
-
2707
- if (isNumber(scaleY)) {
2708
- imageData.scaleY = scaleY;
2709
- transformed = true;
2710
- }
2711
-
2712
- if (transformed) {
2713
- this.renderCanvas(true, true);
2714
- }
2715
- }
2716
-
2717
- return this;
2718
- },
2719
-
2720
- /**
2721
- * Get the cropped area position and size data (base on the original image)
2722
- * @param {boolean} [rounded=false] - Indicate if round the data values or not.
2723
- * @returns {Object} The result cropped data.
2724
- */
2725
- getData: function getData() {
2726
- var rounded = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
2727
- var options = this.options,
2728
- imageData = this.imageData,
2729
- canvasData = this.canvasData,
2730
- cropBoxData = this.cropBoxData;
2731
- var data;
2732
-
2733
- if (this.ready && this.cropped) {
2734
- data = {
2735
- x: cropBoxData.left - canvasData.left,
2736
- y: cropBoxData.top - canvasData.top,
2737
- width: cropBoxData.width,
2738
- height: cropBoxData.height
2739
- };
2740
- var ratio = imageData.width / imageData.naturalWidth;
2741
- forEach(data, function (n, i) {
2742
- data[i] = n / ratio;
2743
- });
2744
-
2745
- if (rounded) {
2746
- // In case rounding off leads to extra 1px in right or bottom border
2747
- // we should round the top-left corner and the dimension (#343).
2748
- var bottom = Math.round(data.y + data.height);
2749
- var right = Math.round(data.x + data.width);
2750
- data.x = Math.round(data.x);
2751
- data.y = Math.round(data.y);
2752
- data.width = right - data.x;
2753
- data.height = bottom - data.y;
2754
- }
2755
- } else {
2756
- data = {
2757
- x: 0,
2758
- y: 0,
2759
- width: 0,
2760
- height: 0
2761
- };
2762
- }
2763
-
2764
- if (options.rotatable) {
2765
- data.rotate = imageData.rotate || 0;
2766
- }
2767
-
2768
- if (options.scalable) {
2769
- data.scaleX = imageData.scaleX || 1;
2770
- data.scaleY = imageData.scaleY || 1;
2771
- }
2772
-
2773
- return data;
2774
- },
2775
-
2776
- /**
2777
- * Set the cropped area position and size with new data
2778
- * @param {Object} data - The new data.
2779
- * @returns {Cropper} this
2780
- */
2781
- setData: function setData(data) {
2782
- var options = this.options,
2783
- imageData = this.imageData,
2784
- canvasData = this.canvasData;
2785
- var cropBoxData = {};
2786
-
2787
- if (this.ready && !this.disabled && isPlainObject(data)) {
2788
- var transformed = false;
2789
-
2790
- if (options.rotatable) {
2791
- if (isNumber(data.rotate) && data.rotate !== imageData.rotate) {
2792
- imageData.rotate = data.rotate;
2793
- transformed = true;
2794
- }
2795
- }
2796
-
2797
- if (options.scalable) {
2798
- if (isNumber(data.scaleX) && data.scaleX !== imageData.scaleX) {
2799
- imageData.scaleX = data.scaleX;
2800
- transformed = true;
2801
- }
2802
-
2803
- if (isNumber(data.scaleY) && data.scaleY !== imageData.scaleY) {
2804
- imageData.scaleY = data.scaleY;
2805
- transformed = true;
2806
- }
2807
- }
2808
-
2809
- if (transformed) {
2810
- this.renderCanvas(true, true);
2811
- }
2812
-
2813
- var ratio = imageData.width / imageData.naturalWidth;
2814
-
2815
- if (isNumber(data.x)) {
2816
- cropBoxData.left = data.x * ratio + canvasData.left;
2817
- }
2818
-
2819
- if (isNumber(data.y)) {
2820
- cropBoxData.top = data.y * ratio + canvasData.top;
2821
- }
2822
-
2823
- if (isNumber(data.width)) {
2824
- cropBoxData.width = data.width * ratio;
2825
- }
2826
-
2827
- if (isNumber(data.height)) {
2828
- cropBoxData.height = data.height * ratio;
2829
- }
2830
-
2831
- this.setCropBoxData(cropBoxData);
2832
- }
2833
-
2834
- return this;
2835
- },
2836
-
2837
- /**
2838
- * Get the container size data.
2839
- * @returns {Object} The result container data.
2840
- */
2841
- getContainerData: function getContainerData() {
2842
- return this.ready ? assign({}, this.containerData) : {};
2843
- },
2844
-
2845
- /**
2846
- * Get the image position and size data.
2847
- * @returns {Object} The result image data.
2848
- */
2849
- getImageData: function getImageData() {
2850
- return this.sized ? assign({}, this.imageData) : {};
2851
- },
2852
-
2853
- /**
2854
- * Get the canvas position and size data.
2855
- * @returns {Object} The result canvas data.
2856
- */
2857
- getCanvasData: function getCanvasData() {
2858
- var canvasData = this.canvasData;
2859
- var data = {};
2860
-
2861
- if (this.ready) {
2862
- forEach(['left', 'top', 'width', 'height', 'naturalWidth', 'naturalHeight'], function (n) {
2863
- data[n] = canvasData[n];
2864
- });
2865
- }
2866
-
2867
- return data;
2868
- },
2869
-
2870
- /**
2871
- * Set the canvas position and size with new data.
2872
- * @param {Object} data - The new canvas data.
2873
- * @returns {Cropper} this
2874
- */
2875
- setCanvasData: function setCanvasData(data) {
2876
- var canvasData = this.canvasData;
2877
- var aspectRatio = canvasData.aspectRatio;
2878
-
2879
- if (this.ready && !this.disabled && isPlainObject(data)) {
2880
- if (isNumber(data.left)) {
2881
- canvasData.left = data.left;
2882
- }
2883
-
2884
- if (isNumber(data.top)) {
2885
- canvasData.top = data.top;
2886
- }
2887
-
2888
- if (isNumber(data.width)) {
2889
- canvasData.width = data.width;
2890
- canvasData.height = data.width / aspectRatio;
2891
- } else if (isNumber(data.height)) {
2892
- canvasData.height = data.height;
2893
- canvasData.width = data.height * aspectRatio;
2894
- }
2895
-
2896
- this.renderCanvas(true);
2897
- }
2898
-
2899
- return this;
2900
- },
2901
-
2902
- /**
2903
- * Get the crop box position and size data.
2904
- * @returns {Object} The result crop box data.
2905
- */
2906
- getCropBoxData: function getCropBoxData() {
2907
- var cropBoxData = this.cropBoxData;
2908
- var data;
2909
-
2910
- if (this.ready && this.cropped) {
2911
- data = {
2912
- left: cropBoxData.left,
2913
- top: cropBoxData.top,
2914
- width: cropBoxData.width,
2915
- height: cropBoxData.height
2916
- };
2917
- }
2918
-
2919
- return data || {};
2920
- },
2921
-
2922
- /**
2923
- * Set the crop box position and size with new data.
2924
- * @param {Object} data - The new crop box data.
2925
- * @returns {Cropper} this
2926
- */
2927
- setCropBoxData: function setCropBoxData(data) {
2928
- var cropBoxData = this.cropBoxData;
2929
- var aspectRatio = this.options.aspectRatio;
2930
- var widthChanged;
2931
- var heightChanged;
2932
-
2933
- if (this.ready && this.cropped && !this.disabled && isPlainObject(data)) {
2934
- if (isNumber(data.left)) {
2935
- cropBoxData.left = data.left;
2936
- }
2937
-
2938
- if (isNumber(data.top)) {
2939
- cropBoxData.top = data.top;
2940
- }
2941
-
2942
- if (isNumber(data.width) && data.width !== cropBoxData.width) {
2943
- widthChanged = true;
2944
- cropBoxData.width = data.width;
2945
- }
2946
-
2947
- if (isNumber(data.height) && data.height !== cropBoxData.height) {
2948
- heightChanged = true;
2949
- cropBoxData.height = data.height;
2950
- }
2951
-
2952
- if (aspectRatio) {
2953
- if (widthChanged) {
2954
- cropBoxData.height = cropBoxData.width / aspectRatio;
2955
- } else if (heightChanged) {
2956
- cropBoxData.width = cropBoxData.height * aspectRatio;
2957
- }
2958
- }
2959
-
2960
- this.renderCropBox();
2961
- }
2962
-
2963
- return this;
2964
- },
2965
-
2966
- /**
2967
- * Get a canvas drawn the cropped image.
2968
- * @param {Object} [options={}] - The config options.
2969
- * @returns {HTMLCanvasElement} - The result canvas.
2970
- */
2971
- getCroppedCanvas: function getCroppedCanvas() {
2972
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2973
-
2974
- if (!this.ready || !window.HTMLCanvasElement) {
2975
- return null;
2976
- }
2977
-
2978
- var canvasData = this.canvasData;
2979
- var source = getSourceCanvas(this.image, this.imageData, canvasData, options); // Returns the source canvas if it is not cropped.
2980
-
2981
- if (!this.cropped) {
2982
- return source;
2983
- }
2984
-
2985
- var _this$getData = this.getData(),
2986
- initialX = _this$getData.x,
2987
- initialY = _this$getData.y,
2988
- initialWidth = _this$getData.width,
2989
- initialHeight = _this$getData.height;
2990
-
2991
- var ratio = source.width / Math.floor(canvasData.naturalWidth);
2992
-
2993
- if (ratio !== 1) {
2994
- initialX *= ratio;
2995
- initialY *= ratio;
2996
- initialWidth *= ratio;
2997
- initialHeight *= ratio;
2998
- }
2999
-
3000
- var aspectRatio = initialWidth / initialHeight;
3001
- var maxSizes = getAdjustedSizes({
3002
- aspectRatio: aspectRatio,
3003
- width: options.maxWidth || Infinity,
3004
- height: options.maxHeight || Infinity
3005
- });
3006
- var minSizes = getAdjustedSizes({
3007
- aspectRatio: aspectRatio,
3008
- width: options.minWidth || 0,
3009
- height: options.minHeight || 0
3010
- }, 'cover');
3011
-
3012
- var _getAdjustedSizes = getAdjustedSizes({
3013
- aspectRatio: aspectRatio,
3014
- width: options.width || (ratio !== 1 ? source.width : initialWidth),
3015
- height: options.height || (ratio !== 1 ? source.height : initialHeight)
3016
- }),
3017
- width = _getAdjustedSizes.width,
3018
- height = _getAdjustedSizes.height;
3019
-
3020
- width = Math.min(maxSizes.width, Math.max(minSizes.width, width));
3021
- height = Math.min(maxSizes.height, Math.max(minSizes.height, height));
3022
- var canvas = document.createElement('canvas');
3023
- var context = canvas.getContext('2d');
3024
- canvas.width = normalizeDecimalNumber(width);
3025
- canvas.height = normalizeDecimalNumber(height);
3026
- context.fillStyle = options.fillColor || 'transparent';
3027
- context.fillRect(0, 0, width, height);
3028
- var _options$imageSmoothi = options.imageSmoothingEnabled,
3029
- imageSmoothingEnabled = _options$imageSmoothi === void 0 ? true : _options$imageSmoothi,
3030
- imageSmoothingQuality = options.imageSmoothingQuality;
3031
- context.imageSmoothingEnabled = imageSmoothingEnabled;
3032
-
3033
- if (imageSmoothingQuality) {
3034
- context.imageSmoothingQuality = imageSmoothingQuality;
3035
- } // https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D.drawImage
3036
-
3037
-
3038
- var sourceWidth = source.width;
3039
- var sourceHeight = source.height; // Source canvas parameters
3040
-
3041
- var srcX = initialX;
3042
- var srcY = initialY;
3043
- var srcWidth;
3044
- var srcHeight; // Destination canvas parameters
3045
-
3046
- var dstX;
3047
- var dstY;
3048
- var dstWidth;
3049
- var dstHeight;
3050
-
3051
- if (srcX <= -initialWidth || srcX > sourceWidth) {
3052
- srcX = 0;
3053
- srcWidth = 0;
3054
- dstX = 0;
3055
- dstWidth = 0;
3056
- } else if (srcX <= 0) {
3057
- dstX = -srcX;
3058
- srcX = 0;
3059
- srcWidth = Math.min(sourceWidth, initialWidth + srcX);
3060
- dstWidth = srcWidth;
3061
- } else if (srcX <= sourceWidth) {
3062
- dstX = 0;
3063
- srcWidth = Math.min(initialWidth, sourceWidth - srcX);
3064
- dstWidth = srcWidth;
3065
- }
3066
-
3067
- if (srcWidth <= 0 || srcY <= -initialHeight || srcY > sourceHeight) {
3068
- srcY = 0;
3069
- srcHeight = 0;
3070
- dstY = 0;
3071
- dstHeight = 0;
3072
- } else if (srcY <= 0) {
3073
- dstY = -srcY;
3074
- srcY = 0;
3075
- srcHeight = Math.min(sourceHeight, initialHeight + srcY);
3076
- dstHeight = srcHeight;
3077
- } else if (srcY <= sourceHeight) {
3078
- dstY = 0;
3079
- srcHeight = Math.min(initialHeight, sourceHeight - srcY);
3080
- dstHeight = srcHeight;
3081
- }
3082
-
3083
- var params = [srcX, srcY, srcWidth, srcHeight]; // Avoid "IndexSizeError"
3084
-
3085
- if (dstWidth > 0 && dstHeight > 0) {
3086
- var scale = width / initialWidth;
3087
- params.push(dstX * scale, dstY * scale, dstWidth * scale, dstHeight * scale);
3088
- } // All the numerical parameters should be integer for `drawImage`
3089
- // https://github.com/fengyuanchen/cropper/issues/476
3090
-
3091
-
3092
- context.drawImage.apply(context, [source].concat(_toConsumableArray(params.map(function (param) {
3093
- return Math.floor(normalizeDecimalNumber(param));
3094
- }))));
3095
- return canvas;
3096
- },
3097
-
3098
- /**
3099
- * Change the aspect ratio of the crop box.
3100
- * @param {number} aspectRatio - The new aspect ratio.
3101
- * @returns {Cropper} this
3102
- */
3103
- setAspectRatio: function setAspectRatio(aspectRatio) {
3104
- var options = this.options;
3105
-
3106
- if (!this.disabled && !isUndefined(aspectRatio)) {
3107
- // 0 -> NaN
3108
- options.aspectRatio = Math.max(0, aspectRatio) || NaN;
3109
-
3110
- if (this.ready) {
3111
- this.initCropBox();
3112
-
3113
- if (this.cropped) {
3114
- this.renderCropBox();
3115
- }
3116
- }
3117
- }
3118
-
3119
- return this;
3120
- },
3121
-
3122
- /**
3123
- * Change the drag mode.
3124
- * @param {string} mode - The new drag mode.
3125
- * @returns {Cropper} this
3126
- */
3127
- setDragMode: function setDragMode(mode) {
3128
- var options = this.options,
3129
- dragBox = this.dragBox,
3130
- face = this.face;
3131
-
3132
- if (this.ready && !this.disabled) {
3133
- var croppable = mode === DRAG_MODE_CROP;
3134
- var movable = options.movable && mode === DRAG_MODE_MOVE;
3135
- mode = croppable || movable ? mode : DRAG_MODE_NONE;
3136
- options.dragMode = mode;
3137
- setData(dragBox, DATA_ACTION, mode);
3138
- toggleClass(dragBox, CLASS_CROP, croppable);
3139
- toggleClass(dragBox, CLASS_MOVE, movable);
3140
-
3141
- if (!options.cropBoxMovable) {
3142
- // Sync drag mode to crop box when it is not movable
3143
- setData(face, DATA_ACTION, mode);
3144
- toggleClass(face, CLASS_CROP, croppable);
3145
- toggleClass(face, CLASS_MOVE, movable);
3146
- }
3147
- }
3148
-
3149
- return this;
3150
- }
3151
- };
3152
-
3153
- var AnotherCropper = WINDOW.Cropper;
3154
-
3155
- var Cropper =
3156
- /*#__PURE__*/
3157
- function () {
3158
- /**
3159
- * Create a new Cropper.
3160
- * @param {Element} element - The target element for cropping.
3161
- * @param {Object} [options={}] - The configuration options.
3162
- */
3163
- function Cropper(element) {
3164
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3165
-
3166
- _classCallCheck(this, Cropper);
3167
-
3168
- if (!element || !REGEXP_TAG_NAME.test(element.tagName)) {
3169
- throw new Error('The first argument is required and must be an <img> or <canvas> element.');
3170
- }
3171
-
3172
- this.element = element;
3173
- this.options = assign({}, DEFAULTS, isPlainObject(options) && options);
3174
- this.cropped = false;
3175
- this.disabled = false;
3176
- this.pointers = {};
3177
- this.ready = false;
3178
- this.reloading = false;
3179
- this.replaced = false;
3180
- this.sized = false;
3181
- this.sizing = false;
3182
- this.init();
3183
- }
3184
-
3185
- _createClass(Cropper, [{
3186
- key: "init",
3187
- value: function init() {
3188
- var element = this.element;
3189
- var tagName = element.tagName.toLowerCase();
3190
- var url;
3191
-
3192
- if (element[NAMESPACE]) {
3193
- return;
3194
- }
3195
-
3196
- element[NAMESPACE] = this;
3197
-
3198
- if (tagName === 'img') {
3199
- this.isImg = true; // e.g.: "img/picture.jpg"
3200
-
3201
- url = element.getAttribute('src') || '';
3202
- this.originalUrl = url; // Stop when it's a blank image
3203
-
3204
- if (!url) {
3205
- return;
3206
- } // e.g.: "http://example.com/img/picture.jpg"
3207
-
3208
-
3209
- url = element.src;
3210
- } else if (tagName === 'canvas' && window.HTMLCanvasElement) {
3211
- url = element.toDataURL();
3212
- }
3213
-
3214
- this.load(url);
3215
- }
3216
- }, {
3217
- key: "load",
3218
- value: function load(url) {
3219
- var _this = this;
3220
-
3221
- if (!url) {
3222
- return;
3223
- }
3224
-
3225
- this.url = url;
3226
- this.imageData = {};
3227
- var element = this.element,
3228
- options = this.options;
3229
-
3230
- if (!options.rotatable && !options.scalable) {
3231
- options.checkOrientation = false;
3232
- } // Only IE10+ supports Typed Arrays
3233
-
3234
-
3235
- if (!options.checkOrientation || !window.ArrayBuffer) {
3236
- this.clone();
3237
- return;
3238
- } // Read ArrayBuffer from Data URL of JPEG images directly for better performance.
3239
-
3240
-
3241
- if (REGEXP_DATA_URL_JPEG.test(url)) {
3242
- this.read(dataURLToArrayBuffer(url));
3243
- return;
3244
- }
3245
-
3246
- var xhr = new XMLHttpRequest();
3247
- var clone = this.clone.bind(this);
3248
- this.reloading = true;
3249
- this.xhr = xhr; // 1. Cross origin requests are only supported for protocol schemes:
3250
- // http, https, data, chrome, chrome-extension.
3251
- // 2. Access to XMLHttpRequest from a Data URL will be blocked by CORS policy
3252
- // in some browsers as IE11 and Safari.
3253
-
3254
- xhr.onabort = clone;
3255
- xhr.onerror = clone;
3256
- xhr.ontimeout = clone;
3257
-
3258
- xhr.onprogress = function () {
3259
- if (xhr.getResponseHeader('content-type') !== MIME_TYPE_JPEG) {
3260
- xhr.abort();
3261
- }
3262
- };
3263
-
3264
- xhr.onload = function () {
3265
- _this.read(xhr.response);
3266
- };
3267
-
3268
- xhr.onloadend = function () {
3269
- _this.reloading = false;
3270
- _this.xhr = null;
3271
- }; // Bust cache when there is a "crossOrigin" property to avoid browser cache error
3272
-
3273
-
3274
- if (options.checkCrossOrigin && isCrossOriginURL(url) && element.crossOrigin) {
3275
- url = addTimestamp(url);
3276
- }
3277
-
3278
- xhr.open('GET', url);
3279
- xhr.responseType = 'arraybuffer';
3280
- xhr.withCredentials = element.crossOrigin === 'use-credentials';
3281
- xhr.send();
3282
- }
3283
- }, {
3284
- key: "read",
3285
- value: function read(arrayBuffer) {
3286
- var options = this.options,
3287
- imageData = this.imageData; // Reset the orientation value to its default value 1
3288
- // as some iOS browsers will render image with its orientation
3289
-
3290
- var orientation = resetAndGetOrientation(arrayBuffer);
3291
- var rotate = 0;
3292
- var scaleX = 1;
3293
- var scaleY = 1;
3294
-
3295
- if (orientation > 1) {
3296
- // Generate a new URL which has the default orientation value
3297
- this.url = arrayBufferToDataURL(arrayBuffer, MIME_TYPE_JPEG);
3298
-
3299
- var _parseOrientation = parseOrientation(orientation);
3300
-
3301
- rotate = _parseOrientation.rotate;
3302
- scaleX = _parseOrientation.scaleX;
3303
- scaleY = _parseOrientation.scaleY;
3304
- }
3305
-
3306
- if (options.rotatable) {
3307
- imageData.rotate = rotate;
3308
- }
3309
-
3310
- if (options.scalable) {
3311
- imageData.scaleX = scaleX;
3312
- imageData.scaleY = scaleY;
3313
- }
3314
-
3315
- this.clone();
3316
- }
3317
- }, {
3318
- key: "clone",
3319
- value: function clone() {
3320
- var element = this.element,
3321
- url = this.url;
3322
- var crossOrigin;
3323
- var crossOriginUrl;
3324
-
3325
- if (this.options.checkCrossOrigin && isCrossOriginURL(url)) {
3326
- crossOrigin = element.crossOrigin;
3327
-
3328
- if (!crossOrigin) {
3329
- crossOrigin = 'anonymous';
3330
- } // Bust cache when there is not a "crossOrigin" property (#519)
3331
-
3332
-
3333
- crossOriginUrl = addTimestamp(url);
3334
- }
3335
-
3336
- this.crossOrigin = crossOrigin;
3337
- this.crossOriginUrl = crossOriginUrl;
3338
- var image = document.createElement('img');
3339
-
3340
- if (crossOrigin) {
3341
- image.crossOrigin = crossOrigin;
3342
- }
3343
-
3344
- image.src = crossOriginUrl || url;
3345
- this.image = image;
3346
- image.onload = this.start.bind(this);
3347
- image.onerror = this.stop.bind(this);
3348
- addClass(image, CLASS_HIDE);
3349
- element.parentNode.insertBefore(image, element.nextSibling);
3350
- }
3351
- }, {
3352
- key: "start",
3353
- value: function start() {
3354
- var _this2 = this;
3355
-
3356
- var image = this.isImg ? this.element : this.image;
3357
- image.onload = null;
3358
- image.onerror = null;
3359
- this.sizing = true; // Match all browsers that use WebKit as the layout engine in iOS devices,
3360
- // such as Safari for iOS, Chrome for iOS, and in-app browsers.
3361
-
3362
- var isIOSWebKit = WINDOW.navigator && /(?:iPad|iPhone|iPod).*?AppleWebKit/i.test(WINDOW.navigator.userAgent);
3363
-
3364
- var done = function done(naturalWidth, naturalHeight) {
3365
- assign(_this2.imageData, {
3366
- naturalWidth: naturalWidth,
3367
- naturalHeight: naturalHeight,
3368
- aspectRatio: naturalWidth / naturalHeight
3369
- });
3370
- _this2.sizing = false;
3371
- _this2.sized = true;
3372
-
3373
- _this2.build();
3374
- }; // Most modern browsers (excepts iOS WebKit)
3375
-
3376
-
3377
- if (image.naturalWidth && !isIOSWebKit) {
3378
- done(image.naturalWidth, image.naturalHeight);
3379
- return;
3380
- }
3381
-
3382
- var sizingImage = document.createElement('img');
3383
- var body = document.body || document.documentElement;
3384
- this.sizingImage = sizingImage;
3385
-
3386
- sizingImage.onload = function () {
3387
- done(sizingImage.width, sizingImage.height);
3388
-
3389
- if (!isIOSWebKit) {
3390
- body.removeChild(sizingImage);
3391
- }
3392
- };
3393
-
3394
- sizingImage.src = image.src; // iOS WebKit will convert the image automatically
3395
- // with its orientation once append it into DOM (#279)
3396
-
3397
- if (!isIOSWebKit) {
3398
- sizingImage.style.cssText = 'left:0;' + 'max-height:none!important;' + 'max-width:none!important;' + 'min-height:0!important;' + 'min-width:0!important;' + 'opacity:0;' + 'position:absolute;' + 'top:0;' + 'z-index:-1;';
3399
- body.appendChild(sizingImage);
3400
- }
3401
- }
3402
- }, {
3403
- key: "stop",
3404
- value: function stop() {
3405
- var image = this.image;
3406
- image.onload = null;
3407
- image.onerror = null;
3408
- image.parentNode.removeChild(image);
3409
- this.image = null;
3410
- }
3411
- }, {
3412
- key: "build",
3413
- value: function build() {
3414
- if (!this.sized || this.ready) {
3415
- return;
3416
- }
3417
-
3418
- var element = this.element,
3419
- options = this.options,
3420
- image = this.image; // Create cropper elements
3421
-
3422
- var container = element.parentNode;
3423
- var template = document.createElement('div');
3424
- template.innerHTML = TEMPLATE;
3425
- var cropper = template.querySelector(".".concat(NAMESPACE, "-container"));
3426
- var canvas = cropper.querySelector(".".concat(NAMESPACE, "-canvas"));
3427
- var dragBox = cropper.querySelector(".".concat(NAMESPACE, "-drag-box"));
3428
- var cropBox = cropper.querySelector(".".concat(NAMESPACE, "-crop-box"));
3429
- var face = cropBox.querySelector(".".concat(NAMESPACE, "-face"));
3430
- this.container = container;
3431
- this.cropper = cropper;
3432
- this.canvas = canvas;
3433
- this.dragBox = dragBox;
3434
- this.cropBox = cropBox;
3435
- this.viewBox = cropper.querySelector(".".concat(NAMESPACE, "-view-box"));
3436
- this.face = face;
3437
- canvas.appendChild(image); // Hide the original image
3438
-
3439
- addClass(element, CLASS_HIDDEN); // Inserts the cropper after to the current image
3440
-
3441
- container.insertBefore(cropper, element.nextSibling); // Show the image if is hidden
3442
-
3443
- if (!this.isImg) {
3444
- removeClass(image, CLASS_HIDE);
3445
- }
3446
-
3447
- this.initPreview();
3448
- this.bind();
3449
- options.initialAspectRatio = Math.max(0, options.initialAspectRatio) || NaN;
3450
- options.aspectRatio = Math.max(0, options.aspectRatio) || NaN;
3451
- options.viewMode = Math.max(0, Math.min(3, Math.round(options.viewMode))) || 0;
3452
- addClass(cropBox, CLASS_HIDDEN);
3453
-
3454
- if (!options.guides) {
3455
- addClass(cropBox.getElementsByClassName("".concat(NAMESPACE, "-dashed")), CLASS_HIDDEN);
3456
- }
3457
-
3458
- if (!options.center) {
3459
- addClass(cropBox.getElementsByClassName("".concat(NAMESPACE, "-center")), CLASS_HIDDEN);
3460
- }
3461
-
3462
- if (options.background) {
3463
- addClass(cropper, "".concat(NAMESPACE, "-bg"));
3464
- }
3465
-
3466
- if (!options.highlight) {
3467
- addClass(face, CLASS_INVISIBLE);
3468
- }
3469
-
3470
- if (options.cropBoxMovable) {
3471
- addClass(face, CLASS_MOVE);
3472
- setData(face, DATA_ACTION, ACTION_ALL);
3473
- }
3474
-
3475
- if (!options.cropBoxResizable) {
3476
- addClass(cropBox.getElementsByClassName("".concat(NAMESPACE, "-line")), CLASS_HIDDEN);
3477
- addClass(cropBox.getElementsByClassName("".concat(NAMESPACE, "-point")), CLASS_HIDDEN);
3478
- }
3479
-
3480
- this.render();
3481
- this.ready = true;
3482
- this.setDragMode(options.dragMode);
3483
-
3484
- if (options.autoCrop) {
3485
- this.crop();
3486
- }
3487
-
3488
- this.setData(options.data);
3489
-
3490
- if (isFunction(options.ready)) {
3491
- addListener(element, EVENT_READY, options.ready, {
3492
- once: true
3493
- });
3494
- }
3495
-
3496
- dispatchEvent(element, EVENT_READY);
3497
- }
3498
- }, {
3499
- key: "unbuild",
3500
- value: function unbuild() {
3501
- if (!this.ready) {
3502
- return;
3503
- }
3504
-
3505
- this.ready = false;
3506
- this.unbind();
3507
- this.resetPreview();
3508
- this.cropper.parentNode.removeChild(this.cropper);
3509
- removeClass(this.element, CLASS_HIDDEN);
3510
- }
3511
- }, {
3512
- key: "uncreate",
3513
- value: function uncreate() {
3514
- if (this.ready) {
3515
- this.unbuild();
3516
- this.ready = false;
3517
- this.cropped = false;
3518
- } else if (this.sizing) {
3519
- this.sizingImage.onload = null;
3520
- this.sizing = false;
3521
- this.sized = false;
3522
- } else if (this.reloading) {
3523
- this.xhr.onabort = null;
3524
- this.xhr.abort();
3525
- } else if (this.image) {
3526
- this.stop();
3527
- }
3528
- }
3529
- /**
3530
- * Get the no conflict cropper class.
3531
- * @returns {Cropper} The cropper class.
3532
- */
3533
-
3534
- }], [{
3535
- key: "noConflict",
3536
- value: function noConflict() {
3537
- window.Cropper = AnotherCropper;
3538
- return Cropper;
3539
- }
3540
- /**
3541
- * Change the default options.
3542
- * @param {Object} options - The new default options.
3543
- */
3544
-
3545
- }, {
3546
- key: "setDefaults",
3547
- value: function setDefaults(options) {
3548
- assign(DEFAULTS, isPlainObject(options) && options);
3549
- }
3550
- }]);
3551
-
3552
- return Cropper;
3553
- }();
3554
-
3555
- assign(Cropper.prototype, render, preview, events, handlers, change, methods);
3556
-
3557
- return Cropper;
3558
-
3559
- }));
3560
-
3561
-
3562
- /***/ })
3563
-
3564
- }]);
3565
- //# sourceMappingURL=27.chunk.js.map