ding-image-editor 3.15.3

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 (374) hide show
  1. package/README.md +193 -0
  2. package/dist/svg/icon-a.svg +376 -0
  3. package/dist/svg/icon-b.svg +369 -0
  4. package/dist/svg/icon-c.svg +369 -0
  5. package/dist/svg/icon-d.svg +369 -0
  6. package/dist/tui-image-editor.css +6 -0
  7. package/dist/tui-image-editor.js +62329 -0
  8. package/dist/tui-image-editor.min.css +5 -0
  9. package/dist/tui-image-editor.min.js +15 -0
  10. package/index.d.ts +334 -0
  11. package/package.json +52 -0
  12. package/src/css/buttons.styl +102 -0
  13. package/src/css/checkbox.styl +86 -0
  14. package/src/css/colorpicker.styl +98 -0
  15. package/src/css/gridtable.styl +45 -0
  16. package/src/css/icon.styl +44 -0
  17. package/src/css/index.styl +17 -0
  18. package/src/css/main.styl +163 -0
  19. package/src/css/position.styl +309 -0
  20. package/src/css/range.styl +91 -0
  21. package/src/css/submenu.styl +168 -0
  22. package/src/index.js +29 -0
  23. package/src/js/action.js +686 -0
  24. package/src/js/command/addIcon.js +42 -0
  25. package/src/js/command/addImageObject.js +34 -0
  26. package/src/js/command/addObject.js +43 -0
  27. package/src/js/command/addShape.js +51 -0
  28. package/src/js/command/addText.js +73 -0
  29. package/src/js/command/applyFilter.js +95 -0
  30. package/src/js/command/changeIconColor.js +48 -0
  31. package/src/js/command/changeSelection.js +31 -0
  32. package/src/js/command/changeShape.js +84 -0
  33. package/src/js/command/changeText.js +44 -0
  34. package/src/js/command/changeTextStyle.js +80 -0
  35. package/src/js/command/clearObjects.js +33 -0
  36. package/src/js/command/flip.js +36 -0
  37. package/src/js/command/loadImage.js +58 -0
  38. package/src/js/command/removeFilter.js +38 -0
  39. package/src/js/command/removeObject.js +37 -0
  40. package/src/js/command/resize.js +41 -0
  41. package/src/js/command/resizeCanvasDimension.js +40 -0
  42. package/src/js/command/rotate.js +64 -0
  43. package/src/js/command/setObjectPosition.js +50 -0
  44. package/src/js/command/setObjectProperties.js +55 -0
  45. package/src/js/component/cropper.js +407 -0
  46. package/src/js/component/filter.js +229 -0
  47. package/src/js/component/flip.js +146 -0
  48. package/src/js/component/freeDrawing.js +144 -0
  49. package/src/js/component/icon.js +246 -0
  50. package/src/js/component/imageLoader.js +84 -0
  51. package/src/js/component/line.js +205 -0
  52. package/src/js/component/resize.js +103 -0
  53. package/src/js/component/rotation.js +91 -0
  54. package/src/js/component/shape.js +601 -0
  55. package/src/js/component/text.js +572 -0
  56. package/src/js/component/zoom.js +708 -0
  57. package/src/js/consts.js +404 -0
  58. package/src/js/drawingMode/cropper.js +35 -0
  59. package/src/js/drawingMode/freeDrawing.js +36 -0
  60. package/src/js/drawingMode/icon.js +35 -0
  61. package/src/js/drawingMode/lineDrawing.js +36 -0
  62. package/src/js/drawingMode/resize.js +35 -0
  63. package/src/js/drawingMode/shape.js +35 -0
  64. package/src/js/drawingMode/text.js +35 -0
  65. package/src/js/drawingMode/zoom.js +37 -0
  66. package/src/js/extension/arrowLine.js +172 -0
  67. package/src/js/extension/blur.js +29 -0
  68. package/src/js/extension/colorFilter.js +104 -0
  69. package/src/js/extension/cropzone.js +568 -0
  70. package/src/js/extension/emboss.js +29 -0
  71. package/src/js/extension/mask.js +90 -0
  72. package/src/js/extension/sharpen.js +29 -0
  73. package/src/js/factory/command.js +36 -0
  74. package/src/js/factory/errorMessage.js +27 -0
  75. package/src/js/graphics.js +1539 -0
  76. package/src/js/helper/imagetracer.js +1396 -0
  77. package/src/js/helper/selectionModifyHelper.js +86 -0
  78. package/src/js/helper/shapeFilterFillHelper.js +564 -0
  79. package/src/js/helper/shapeResizeHelper.js +237 -0
  80. package/src/js/imageEditor.js +1795 -0
  81. package/src/js/interface/command.js +131 -0
  82. package/src/js/interface/component.js +127 -0
  83. package/src/js/interface/drawingMode.js +47 -0
  84. package/src/js/invoker.js +292 -0
  85. package/src/js/polyfill.js +498 -0
  86. package/src/js/ui/crop.js +139 -0
  87. package/src/js/ui/draw.js +187 -0
  88. package/src/js/ui/filter.js +510 -0
  89. package/src/js/ui/flip.js +87 -0
  90. package/src/js/ui/history.js +171 -0
  91. package/src/js/ui/icon.js +191 -0
  92. package/src/js/ui/locale/locale.js +19 -0
  93. package/src/js/ui/mask.js +96 -0
  94. package/src/js/ui/panelMenu.js +130 -0
  95. package/src/js/ui/resize.js +241 -0
  96. package/src/js/ui/rotate.js +123 -0
  97. package/src/js/ui/shape.js +265 -0
  98. package/src/js/ui/submenuBase.js +122 -0
  99. package/src/js/ui/template/controls.js +21 -0
  100. package/src/js/ui/template/mainContainer.js +38 -0
  101. package/src/js/ui/template/style.js +146 -0
  102. package/src/js/ui/template/submenu/crop.js +73 -0
  103. package/src/js/ui/template/submenu/draw.js +42 -0
  104. package/src/js/ui/template/submenu/filter.js +157 -0
  105. package/src/js/ui/template/submenu/flip.js +41 -0
  106. package/src/js/ui/template/submenu/history.js +22 -0
  107. package/src/js/ui/template/submenu/icon.js +108 -0
  108. package/src/js/ui/template/submenu/mask.js +30 -0
  109. package/src/js/ui/template/submenu/resize.js +54 -0
  110. package/src/js/ui/template/submenu/rotate.js +32 -0
  111. package/src/js/ui/template/submenu/shape.js +45 -0
  112. package/src/js/ui/template/submenu/text.js +67 -0
  113. package/src/js/ui/template/submenu/zoom.js +41 -0
  114. package/src/js/ui/text.js +279 -0
  115. package/src/js/ui/theme/standard.js +220 -0
  116. package/src/js/ui/theme/theme.js +249 -0
  117. package/src/js/ui/tools/colorpicker.js +250 -0
  118. package/src/js/ui/tools/range.js +390 -0
  119. package/src/js/ui.js +858 -0
  120. package/src/js/util.js +551 -0
  121. package/src/svg/default.svg +335 -0
  122. package/src/svg/icon-a/ic-apply.svg +6 -0
  123. package/src/svg/icon-a/ic-cancel.svg +6 -0
  124. package/src/svg/icon-a/ic-color-transparent-w.svg +12 -0
  125. package/src/svg/icon-a/ic-crop.svg +7 -0
  126. package/src/svg/icon-a/ic-delete-all.svg +6 -0
  127. package/src/svg/icon-a/ic-delete.svg +6 -0
  128. package/src/svg/icon-a/ic-draw-free.svg +5 -0
  129. package/src/svg/icon-a/ic-draw-line.svg +5 -0
  130. package/src/svg/icon-a/ic-draw.svg +6 -0
  131. package/src/svg/icon-a/ic-filter.svg +7 -0
  132. package/src/svg/icon-a/ic-flip-reset.svg +7 -0
  133. package/src/svg/icon-a/ic-flip-x.svg +6 -0
  134. package/src/svg/icon-a/ic-flip-y.svg +6 -0
  135. package/src/svg/icon-a/ic-flip.svg +6 -0
  136. package/src/svg/icon-a/ic-history-check.svg +5 -0
  137. package/src/svg/icon-a/ic-history-crop.svg +7 -0
  138. package/src/svg/icon-a/ic-history-delete.svg +9 -0
  139. package/src/svg/icon-a/ic-history-draw.svg +7 -0
  140. package/src/svg/icon-a/ic-history-filter.svg +8 -0
  141. package/src/svg/icon-a/ic-history-flip.svg +6 -0
  142. package/src/svg/icon-a/ic-history-group.svg +9 -0
  143. package/src/svg/icon-a/ic-history-icon.svg +6 -0
  144. package/src/svg/icon-a/ic-history-load.svg +7 -0
  145. package/src/svg/icon-a/ic-history-mask.svg +9 -0
  146. package/src/svg/icon-a/ic-history-resize.svg +12 -0
  147. package/src/svg/icon-a/ic-history-rotate.svg +16 -0
  148. package/src/svg/icon-a/ic-history-shape.svg +7 -0
  149. package/src/svg/icon-a/ic-history-text.svg +8 -0
  150. package/src/svg/icon-a/ic-history.svg +6 -0
  151. package/src/svg/icon-a/ic-icon-arrow-2.svg +5 -0
  152. package/src/svg/icon-a/ic-icon-arrow-3.svg +5 -0
  153. package/src/svg/icon-a/ic-icon-arrow.svg +5 -0
  154. package/src/svg/icon-a/ic-icon-bubble.svg +5 -0
  155. package/src/svg/icon-a/ic-icon-heart.svg +5 -0
  156. package/src/svg/icon-a/ic-icon-load.svg +8 -0
  157. package/src/svg/icon-a/ic-icon-location.svg +8 -0
  158. package/src/svg/icon-a/ic-icon-polygon.svg +5 -0
  159. package/src/svg/icon-a/ic-icon-star-2.svg +5 -0
  160. package/src/svg/icon-a/ic-icon-star.svg +5 -0
  161. package/src/svg/icon-a/ic-icon.svg +5 -0
  162. package/src/svg/icon-a/ic-mask-load.svg +8 -0
  163. package/src/svg/icon-a/ic-mask.svg +6 -0
  164. package/src/svg/icon-a/ic-redo.svg +7 -0
  165. package/src/svg/icon-a/ic-reset.svg +7 -0
  166. package/src/svg/icon-a/ic-resize.svg +13 -0
  167. package/src/svg/icon-a/ic-rotate-clockwise.svg +7 -0
  168. package/src/svg/icon-a/ic-rotate-counterclockwise.svg +7 -0
  169. package/src/svg/icon-a/ic-rotate.svg +7 -0
  170. package/src/svg/icon-a/ic-shape-circle.svg +5 -0
  171. package/src/svg/icon-a/ic-shape-rectangle.svg +5 -0
  172. package/src/svg/icon-a/ic-shape-triangle.svg +5 -0
  173. package/src/svg/icon-a/ic-shape.svg +6 -0
  174. package/src/svg/icon-a/ic-text-align-center.svg +6 -0
  175. package/src/svg/icon-a/ic-text-align-left.svg +6 -0
  176. package/src/svg/icon-a/ic-text-align-right.svg +6 -0
  177. package/src/svg/icon-a/ic-text-bold.svg +7 -0
  178. package/src/svg/icon-a/ic-text-italic.svg +6 -0
  179. package/src/svg/icon-a/ic-text-underline.svg +7 -0
  180. package/src/svg/icon-a/ic-text.svg +7 -0
  181. package/src/svg/icon-a/ic-undo.svg +7 -0
  182. package/src/svg/icon-a/ic-zoom-hand.svg +8 -0
  183. package/src/svg/icon-a/ic-zoom-zoom-in.svg +10 -0
  184. package/src/svg/icon-a/ic-zoom-zoom-out.svg +9 -0
  185. package/src/svg/icon-a/img-bi.svg +5 -0
  186. package/src/svg/icon-b/ic-apply.svg +6 -0
  187. package/src/svg/icon-b/ic-cancel.svg +6 -0
  188. package/src/svg/icon-b/ic-crop.svg +7 -0
  189. package/src/svg/icon-b/ic-delete-all.svg +6 -0
  190. package/src/svg/icon-b/ic-delete.svg +6 -0
  191. package/src/svg/icon-b/ic-draw-free.svg +5 -0
  192. package/src/svg/icon-b/ic-draw-line.svg +5 -0
  193. package/src/svg/icon-b/ic-draw.svg +6 -0
  194. package/src/svg/icon-b/ic-filter.svg +7 -0
  195. package/src/svg/icon-b/ic-flip-reset.svg +7 -0
  196. package/src/svg/icon-b/ic-flip-x.svg +6 -0
  197. package/src/svg/icon-b/ic-flip-y.svg +6 -0
  198. package/src/svg/icon-b/ic-flip.svg +6 -0
  199. package/src/svg/icon-b/ic-history-check.svg +5 -0
  200. package/src/svg/icon-b/ic-history-crop.svg +7 -0
  201. package/src/svg/icon-b/ic-history-delete.svg +9 -0
  202. package/src/svg/icon-b/ic-history-draw.svg +7 -0
  203. package/src/svg/icon-b/ic-history-filter.svg +8 -0
  204. package/src/svg/icon-b/ic-history-flip.svg +6 -0
  205. package/src/svg/icon-b/ic-history-group.svg +9 -0
  206. package/src/svg/icon-b/ic-history-icon.svg +6 -0
  207. package/src/svg/icon-b/ic-history-load.svg +7 -0
  208. package/src/svg/icon-b/ic-history-mask.svg +9 -0
  209. package/src/svg/icon-b/ic-history-resize.svg +12 -0
  210. package/src/svg/icon-b/ic-history-rotate.svg +16 -0
  211. package/src/svg/icon-b/ic-history-shape.svg +7 -0
  212. package/src/svg/icon-b/ic-history-text.svg +8 -0
  213. package/src/svg/icon-b/ic-history.svg +6 -0
  214. package/src/svg/icon-b/ic-icon-arrow-2.svg +5 -0
  215. package/src/svg/icon-b/ic-icon-arrow-3.svg +5 -0
  216. package/src/svg/icon-b/ic-icon-arrow.svg +5 -0
  217. package/src/svg/icon-b/ic-icon-bubble.svg +5 -0
  218. package/src/svg/icon-b/ic-icon-heart.svg +5 -0
  219. package/src/svg/icon-b/ic-icon-load.svg +8 -0
  220. package/src/svg/icon-b/ic-icon-location.svg +8 -0
  221. package/src/svg/icon-b/ic-icon-polygon.svg +5 -0
  222. package/src/svg/icon-b/ic-icon-star-2.svg +5 -0
  223. package/src/svg/icon-b/ic-icon-star.svg +5 -0
  224. package/src/svg/icon-b/ic-icon.svg +5 -0
  225. package/src/svg/icon-b/ic-mask-load.svg +8 -0
  226. package/src/svg/icon-b/ic-mask.svg +6 -0
  227. package/src/svg/icon-b/ic-redo.svg +7 -0
  228. package/src/svg/icon-b/ic-reset.svg +7 -0
  229. package/src/svg/icon-b/ic-resize.svg +13 -0
  230. package/src/svg/icon-b/ic-rotate-clockwise.svg +7 -0
  231. package/src/svg/icon-b/ic-rotate-counterclockwise.svg +7 -0
  232. package/src/svg/icon-b/ic-rotate.svg +7 -0
  233. package/src/svg/icon-b/ic-shape-circle.svg +5 -0
  234. package/src/svg/icon-b/ic-shape-rectangle.svg +5 -0
  235. package/src/svg/icon-b/ic-shape-triangle.svg +5 -0
  236. package/src/svg/icon-b/ic-shape.svg +6 -0
  237. package/src/svg/icon-b/ic-text-align-center.svg +6 -0
  238. package/src/svg/icon-b/ic-text-align-left.svg +6 -0
  239. package/src/svg/icon-b/ic-text-align-right.svg +6 -0
  240. package/src/svg/icon-b/ic-text-bold.svg +7 -0
  241. package/src/svg/icon-b/ic-text-italic.svg +6 -0
  242. package/src/svg/icon-b/ic-text-underline.svg +7 -0
  243. package/src/svg/icon-b/ic-text.svg +7 -0
  244. package/src/svg/icon-b/ic-undo.svg +7 -0
  245. package/src/svg/icon-b/ic-zoom-hand.svg +8 -0
  246. package/src/svg/icon-b/ic-zoom-zoom-in.svg +12 -0
  247. package/src/svg/icon-b/ic-zoom-zoom-out.svg +11 -0
  248. package/src/svg/icon-b/img-bi.svg +5 -0
  249. package/src/svg/icon-c/ic-apply.svg +6 -0
  250. package/src/svg/icon-c/ic-cancel.svg +6 -0
  251. package/src/svg/icon-c/ic-crop.svg +7 -0
  252. package/src/svg/icon-c/ic-delete-all.svg +6 -0
  253. package/src/svg/icon-c/ic-delete.svg +6 -0
  254. package/src/svg/icon-c/ic-draw-free.svg +5 -0
  255. package/src/svg/icon-c/ic-draw-line.svg +5 -0
  256. package/src/svg/icon-c/ic-draw.svg +6 -0
  257. package/src/svg/icon-c/ic-filter.svg +7 -0
  258. package/src/svg/icon-c/ic-flip-reset.svg +7 -0
  259. package/src/svg/icon-c/ic-flip-x.svg +6 -0
  260. package/src/svg/icon-c/ic-flip-y.svg +6 -0
  261. package/src/svg/icon-c/ic-flip.svg +6 -0
  262. package/src/svg/icon-c/ic-history-check.svg +5 -0
  263. package/src/svg/icon-c/ic-history-crop.svg +7 -0
  264. package/src/svg/icon-c/ic-history-delete.svg +9 -0
  265. package/src/svg/icon-c/ic-history-draw.svg +7 -0
  266. package/src/svg/icon-c/ic-history-filter.svg +8 -0
  267. package/src/svg/icon-c/ic-history-flip.svg +6 -0
  268. package/src/svg/icon-c/ic-history-group.svg +9 -0
  269. package/src/svg/icon-c/ic-history-icon.svg +6 -0
  270. package/src/svg/icon-c/ic-history-load.svg +7 -0
  271. package/src/svg/icon-c/ic-history-mask.svg +9 -0
  272. package/src/svg/icon-c/ic-history-resize.svg +12 -0
  273. package/src/svg/icon-c/ic-history-rotate.svg +16 -0
  274. package/src/svg/icon-c/ic-history-shape.svg +7 -0
  275. package/src/svg/icon-c/ic-history-text.svg +8 -0
  276. package/src/svg/icon-c/ic-history.svg +6 -0
  277. package/src/svg/icon-c/ic-icon-arrow-2.svg +5 -0
  278. package/src/svg/icon-c/ic-icon-arrow-3.svg +5 -0
  279. package/src/svg/icon-c/ic-icon-arrow.svg +5 -0
  280. package/src/svg/icon-c/ic-icon-bubble.svg +5 -0
  281. package/src/svg/icon-c/ic-icon-heart.svg +5 -0
  282. package/src/svg/icon-c/ic-icon-load.svg +8 -0
  283. package/src/svg/icon-c/ic-icon-location.svg +8 -0
  284. package/src/svg/icon-c/ic-icon-polygon.svg +5 -0
  285. package/src/svg/icon-c/ic-icon-star-2.svg +5 -0
  286. package/src/svg/icon-c/ic-icon-star.svg +5 -0
  287. package/src/svg/icon-c/ic-icon.svg +5 -0
  288. package/src/svg/icon-c/ic-mask-load.svg +8 -0
  289. package/src/svg/icon-c/ic-mask.svg +6 -0
  290. package/src/svg/icon-c/ic-redo.svg +7 -0
  291. package/src/svg/icon-c/ic-reset.svg +7 -0
  292. package/src/svg/icon-c/ic-resize.svg +13 -0
  293. package/src/svg/icon-c/ic-rotate-clockwise.svg +7 -0
  294. package/src/svg/icon-c/ic-rotate-counterclockwise.svg +7 -0
  295. package/src/svg/icon-c/ic-rotate.svg +7 -0
  296. package/src/svg/icon-c/ic-shape-circle.svg +5 -0
  297. package/src/svg/icon-c/ic-shape-rectangle.svg +5 -0
  298. package/src/svg/icon-c/ic-shape-triangle.svg +5 -0
  299. package/src/svg/icon-c/ic-shape.svg +6 -0
  300. package/src/svg/icon-c/ic-text-align-center.svg +6 -0
  301. package/src/svg/icon-c/ic-text-align-left.svg +6 -0
  302. package/src/svg/icon-c/ic-text-align-right.svg +6 -0
  303. package/src/svg/icon-c/ic-text-bold.svg +7 -0
  304. package/src/svg/icon-c/ic-text-italic.svg +6 -0
  305. package/src/svg/icon-c/ic-text-underline.svg +7 -0
  306. package/src/svg/icon-c/ic-text.svg +7 -0
  307. package/src/svg/icon-c/ic-undo.svg +7 -0
  308. package/src/svg/icon-c/ic-zoom-hand.svg +8 -0
  309. package/src/svg/icon-c/ic-zoom-zoom-in.svg +12 -0
  310. package/src/svg/icon-c/ic-zoom-zoom-out.svg +11 -0
  311. package/src/svg/icon-c/img-bi.svg +5 -0
  312. package/src/svg/icon-d/ic-apply.svg +6 -0
  313. package/src/svg/icon-d/ic-cancel.svg +6 -0
  314. package/src/svg/icon-d/ic-crop.svg +7 -0
  315. package/src/svg/icon-d/ic-delete-all.svg +6 -0
  316. package/src/svg/icon-d/ic-delete.svg +6 -0
  317. package/src/svg/icon-d/ic-draw-free.svg +5 -0
  318. package/src/svg/icon-d/ic-draw-line.svg +5 -0
  319. package/src/svg/icon-d/ic-draw.svg +6 -0
  320. package/src/svg/icon-d/ic-filter.svg +7 -0
  321. package/src/svg/icon-d/ic-flip-reset.svg +7 -0
  322. package/src/svg/icon-d/ic-flip-x.svg +6 -0
  323. package/src/svg/icon-d/ic-flip-y.svg +6 -0
  324. package/src/svg/icon-d/ic-flip.svg +6 -0
  325. package/src/svg/icon-d/ic-history-check.svg +5 -0
  326. package/src/svg/icon-d/ic-history-crop.svg +7 -0
  327. package/src/svg/icon-d/ic-history-delete.svg +9 -0
  328. package/src/svg/icon-d/ic-history-draw.svg +7 -0
  329. package/src/svg/icon-d/ic-history-filter.svg +8 -0
  330. package/src/svg/icon-d/ic-history-flip.svg +6 -0
  331. package/src/svg/icon-d/ic-history-group.svg +9 -0
  332. package/src/svg/icon-d/ic-history-icon.svg +6 -0
  333. package/src/svg/icon-d/ic-history-load.svg +7 -0
  334. package/src/svg/icon-d/ic-history-mask.svg +9 -0
  335. package/src/svg/icon-d/ic-history-resize.svg +12 -0
  336. package/src/svg/icon-d/ic-history-rotate.svg +16 -0
  337. package/src/svg/icon-d/ic-history-shape.svg +7 -0
  338. package/src/svg/icon-d/ic-history-text.svg +8 -0
  339. package/src/svg/icon-d/ic-history.svg +6 -0
  340. package/src/svg/icon-d/ic-icon-arrow-2.svg +5 -0
  341. package/src/svg/icon-d/ic-icon-arrow-3.svg +5 -0
  342. package/src/svg/icon-d/ic-icon-arrow.svg +5 -0
  343. package/src/svg/icon-d/ic-icon-bubble.svg +5 -0
  344. package/src/svg/icon-d/ic-icon-heart.svg +5 -0
  345. package/src/svg/icon-d/ic-icon-load.svg +8 -0
  346. package/src/svg/icon-d/ic-icon-location.svg +8 -0
  347. package/src/svg/icon-d/ic-icon-polygon.svg +5 -0
  348. package/src/svg/icon-d/ic-icon-star-2.svg +5 -0
  349. package/src/svg/icon-d/ic-icon-star.svg +5 -0
  350. package/src/svg/icon-d/ic-icon.svg +5 -0
  351. package/src/svg/icon-d/ic-mask-load.svg +8 -0
  352. package/src/svg/icon-d/ic-mask.svg +6 -0
  353. package/src/svg/icon-d/ic-redo.svg +7 -0
  354. package/src/svg/icon-d/ic-reset.svg +7 -0
  355. package/src/svg/icon-d/ic-resize.svg +13 -0
  356. package/src/svg/icon-d/ic-rotate-clockwise.svg +7 -0
  357. package/src/svg/icon-d/ic-rotate-counterclockwise.svg +7 -0
  358. package/src/svg/icon-d/ic-rotate.svg +7 -0
  359. package/src/svg/icon-d/ic-shape-circle.svg +5 -0
  360. package/src/svg/icon-d/ic-shape-rectangle.svg +5 -0
  361. package/src/svg/icon-d/ic-shape-triangle.svg +5 -0
  362. package/src/svg/icon-d/ic-shape.svg +6 -0
  363. package/src/svg/icon-d/ic-text-align-center.svg +6 -0
  364. package/src/svg/icon-d/ic-text-align-left.svg +6 -0
  365. package/src/svg/icon-d/ic-text-align-right.svg +6 -0
  366. package/src/svg/icon-d/ic-text-bold.svg +7 -0
  367. package/src/svg/icon-d/ic-text-italic.svg +6 -0
  368. package/src/svg/icon-d/ic-text-underline.svg +7 -0
  369. package/src/svg/icon-d/ic-text.svg +7 -0
  370. package/src/svg/icon-d/ic-undo.svg +7 -0
  371. package/src/svg/icon-d/ic-zoom-hand.svg +8 -0
  372. package/src/svg/icon-d/ic-zoom-zoom-in.svg +12 -0
  373. package/src/svg/icon-d/ic-zoom-zoom-out.svg +11 -0
  374. package/src/svg/icon-d/img-bi.svg +5 -0
@@ -0,0 +1,708 @@
1
+ import { fabric } from 'fabric';
2
+ import Component from '@/interface/component';
3
+ import { clamp } from '@/util';
4
+ import { componentNames, eventNames, keyCodes, zoomModes } from '@/consts';
5
+
6
+ const MOUSE_MOVE_THRESHOLD = 10;
7
+ const DEFAULT_SCROLL_OPTION = {
8
+ left: 0,
9
+ top: 0,
10
+ width: 0,
11
+ height: 0,
12
+ stroke: '#000000',
13
+ strokeWidth: 0,
14
+ fill: '#000000',
15
+ opacity: 0.4,
16
+ evented: false,
17
+ selectable: false,
18
+ hoverCursor: 'auto',
19
+ };
20
+ const DEFAULT_VERTICAL_SCROLL_RATIO = {
21
+ SIZE: 0.0045,
22
+ MARGIN: 0.003,
23
+ BORDER_RADIUS: 0.003,
24
+ };
25
+ const DEFAULT_HORIZONTAL_SCROLL_RATIO = {
26
+ SIZE: 0.0066,
27
+ MARGIN: 0.0044,
28
+ BORDER_RADIUS: 0.003,
29
+ };
30
+ const DEFAULT_ZOOM_LEVEL = 1.0;
31
+ const {
32
+ ZOOM_CHANGED,
33
+ ADD_TEXT,
34
+ TEXT_EDITING,
35
+ OBJECT_MODIFIED,
36
+ KEY_DOWN,
37
+ KEY_UP,
38
+ HAND_STARTED,
39
+ HAND_STOPPED,
40
+ } = eventNames;
41
+
42
+ /**
43
+ * Zoom components
44
+ * @param {Graphics} graphics - Graphics instance
45
+ * @extends {Component}
46
+ * @class Zoom
47
+ * @ignore
48
+ */
49
+ class Zoom extends Component {
50
+ constructor(graphics) {
51
+ super(componentNames.ZOOM, graphics);
52
+
53
+ /**
54
+ * zoomArea
55
+ * @type {?fabric.Rect}
56
+ * @private
57
+ */
58
+ this.zoomArea = null;
59
+
60
+ /**
61
+ * Start point of zoom area
62
+ * @type {?{x: number, y: number}}
63
+ */
64
+ this._startPoint = null;
65
+
66
+ /**
67
+ * Center point of every zoom
68
+ * @type {Array.<{prevZoomLevel: number, zoomLevel: number, x: number, y: number}>}
69
+ */
70
+ this._centerPoints = [];
71
+
72
+ /**
73
+ * Zoom level (default: 100%(1.0), max: 400%(4.0))
74
+ * @type {number}
75
+ */
76
+ this.zoomLevel = DEFAULT_ZOOM_LEVEL;
77
+
78
+ /**
79
+ * Zoom mode ('normal', 'zoom', 'hand')
80
+ * @type {string}
81
+ */
82
+ this.zoomMode = zoomModes.DEFAULT;
83
+
84
+ /**
85
+ * Listeners
86
+ * @type {Object.<string, Function>}
87
+ * @private
88
+ */
89
+ this._listeners = {
90
+ startZoom: this._onMouseDownWithZoomMode.bind(this),
91
+ moveZoom: this._onMouseMoveWithZoomMode.bind(this),
92
+ stopZoom: this._onMouseUpWithZoomMode.bind(this),
93
+ startHand: this._onMouseDownWithHandMode.bind(this),
94
+ moveHand: this._onMouseMoveWithHandMode.bind(this),
95
+ stopHand: this._onMouseUpWithHandMode.bind(this),
96
+ zoomChanged: this._changeScrollState.bind(this),
97
+ keydown: this._startHandModeWithSpaceBar.bind(this),
98
+ keyup: this._endHandModeWithSpaceBar.bind(this),
99
+ };
100
+
101
+ const canvas = this.getCanvas();
102
+
103
+ /**
104
+ * Width:Height ratio (ex. width=1.5, height=1 -> aspectRatio=1.5)
105
+ * @private
106
+ */
107
+ this.aspectRatio = canvas.width / canvas.height;
108
+
109
+ /**
110
+ * vertical scroll bar
111
+ * @type {fabric.Rect}
112
+ * @private
113
+ */
114
+ this._verticalScroll = new fabric.Rect(DEFAULT_SCROLL_OPTION);
115
+
116
+ /**
117
+ * horizontal scroll bar
118
+ * @type {fabric.Rect}
119
+ * @private
120
+ */
121
+ this._horizontalScroll = new fabric.Rect(DEFAULT_SCROLL_OPTION);
122
+
123
+ canvas.on(ZOOM_CHANGED, this._listeners.zoomChanged);
124
+
125
+ this.graphics.on(ADD_TEXT, this._startTextEditingHandler.bind(this));
126
+ this.graphics.on(TEXT_EDITING, this._startTextEditingHandler.bind(this));
127
+ this.graphics.on(OBJECT_MODIFIED, this._stopTextEditingHandler.bind(this));
128
+ }
129
+
130
+ /**
131
+ * Attach zoom keyboard events
132
+ */
133
+ attachKeyboardZoomEvents() {
134
+ fabric.util.addListener(document, KEY_DOWN, this._listeners.keydown);
135
+ fabric.util.addListener(document, KEY_UP, this._listeners.keyup);
136
+ }
137
+
138
+ /**
139
+ * Detach zoom keyboard events
140
+ */
141
+ detachKeyboardZoomEvents() {
142
+ fabric.util.removeListener(document, KEY_DOWN, this._listeners.keydown);
143
+ fabric.util.removeListener(document, KEY_UP, this._listeners.keyup);
144
+ }
145
+
146
+ /**
147
+ * Handler when you started editing text
148
+ * @private
149
+ */
150
+ _startTextEditingHandler() {
151
+ this.isTextEditing = true;
152
+ }
153
+
154
+ /**
155
+ * Handler when you stopped editing text
156
+ * @private
157
+ */
158
+ _stopTextEditingHandler() {
159
+ this.isTextEditing = false;
160
+ }
161
+
162
+ /**
163
+ * Handler who turns on hand mode when the space bar is down
164
+ * @param {KeyboardEvent} e - Event object
165
+ * @private
166
+ */
167
+ _startHandModeWithSpaceBar(e) {
168
+ if (this.withSpace || this.isTextEditing) {
169
+ return;
170
+ }
171
+
172
+ if (e.keyCode === keyCodes.SPACE) {
173
+ this.withSpace = true;
174
+ this.startHandMode();
175
+ }
176
+ }
177
+
178
+ /**
179
+ * Handler who turns off hand mode when space bar is up
180
+ * @param {KeyboardEvent} e - Event object
181
+ * @private
182
+ */
183
+ _endHandModeWithSpaceBar(e) {
184
+ if (e.keyCode === keyCodes.SPACE) {
185
+ this.withSpace = false;
186
+ this.endHandMode();
187
+ }
188
+ }
189
+
190
+ /**
191
+ * Start zoom-in mode
192
+ */
193
+ startZoomInMode() {
194
+ if (this.zoomArea) {
195
+ return;
196
+ }
197
+ this.endHandMode();
198
+ this.zoomMode = zoomModes.ZOOM;
199
+
200
+ const canvas = this.getCanvas();
201
+
202
+ this._changeObjectsEventedState(false);
203
+
204
+ this.zoomArea = new fabric.Rect({
205
+ left: 0,
206
+ top: 0,
207
+ width: 0.5,
208
+ height: 0.5,
209
+ stroke: 'black',
210
+ strokeWidth: 1,
211
+ fill: 'transparent',
212
+ hoverCursor: 'zoom-in',
213
+ });
214
+
215
+ canvas.discardActiveObject();
216
+ canvas.add(this.zoomArea);
217
+ canvas.on('mouse:down', this._listeners.startZoom);
218
+ canvas.selection = false;
219
+ canvas.defaultCursor = 'zoom-in';
220
+ }
221
+
222
+ /**
223
+ * End zoom-in mode
224
+ */
225
+ endZoomInMode() {
226
+ this.zoomMode = zoomModes.DEFAULT;
227
+
228
+ const canvas = this.getCanvas();
229
+ const { startZoom, moveZoom, stopZoom } = this._listeners;
230
+
231
+ canvas.selection = true;
232
+ canvas.defaultCursor = 'auto';
233
+ canvas.off({
234
+ 'mouse:down': startZoom,
235
+ 'mouse:move': moveZoom,
236
+ 'mouse:up': stopZoom,
237
+ });
238
+
239
+ this._changeObjectsEventedState(true);
240
+
241
+ canvas.remove(this.zoomArea);
242
+ this.zoomArea = null;
243
+ }
244
+
245
+ /**
246
+ * Start zoom drawing mode
247
+ */
248
+ start() {
249
+ this.zoomArea = null;
250
+ this._startPoint = null;
251
+ this._startHandPoint = null;
252
+ }
253
+
254
+ /**
255
+ * Stop zoom drawing mode
256
+ */
257
+ end() {
258
+ this.endZoomInMode();
259
+ this.endHandMode();
260
+ }
261
+
262
+ /**
263
+ * Start hand mode
264
+ */
265
+ startHandMode() {
266
+ this.endZoomInMode();
267
+ this.zoomMode = zoomModes.HAND;
268
+
269
+ const canvas = this.getCanvas();
270
+
271
+ this._changeObjectsEventedState(false);
272
+
273
+ canvas.discardActiveObject();
274
+ canvas.off('mouse:down', this._listeners.startHand);
275
+ canvas.on('mouse:down', this._listeners.startHand);
276
+ canvas.selection = false;
277
+ canvas.defaultCursor = 'grab';
278
+
279
+ canvas.fire(HAND_STARTED);
280
+ }
281
+
282
+ /**
283
+ * Stop hand mode
284
+ */
285
+ endHandMode() {
286
+ this.zoomMode = zoomModes.DEFAULT;
287
+ const canvas = this.getCanvas();
288
+
289
+ this._changeObjectsEventedState(true);
290
+
291
+ canvas.off('mouse:down', this._listeners.startHand);
292
+ canvas.selection = true;
293
+ canvas.defaultCursor = 'auto';
294
+
295
+ this._startHandPoint = null;
296
+
297
+ canvas.fire(HAND_STOPPED);
298
+ }
299
+
300
+ /**
301
+ * onMousedown handler in fabric canvas
302
+ * @param {{target: fabric.Object, e: MouseEvent}} fEvent - Fabric event
303
+ * @private
304
+ */
305
+ _onMouseDownWithZoomMode({ target, e }) {
306
+ if (target) {
307
+ return;
308
+ }
309
+
310
+ const canvas = this.getCanvas();
311
+
312
+ canvas.selection = false;
313
+
314
+ this._startPoint = canvas.getPointer(e);
315
+ this.zoomArea.set({ width: 0, height: 0 });
316
+
317
+ const { moveZoom, stopZoom } = this._listeners;
318
+ canvas.on({
319
+ 'mouse:move': moveZoom,
320
+ 'mouse:up': stopZoom,
321
+ });
322
+ }
323
+
324
+ /**
325
+ * onMousemove handler in fabric canvas
326
+ * @param {{e: MouseEvent}} fEvent - Fabric event
327
+ * @private
328
+ */
329
+ _onMouseMoveWithZoomMode({ e }) {
330
+ const canvas = this.getCanvas();
331
+ const pointer = canvas.getPointer(e);
332
+ const { x, y } = pointer;
333
+ const { zoomArea, _startPoint } = this;
334
+ const deltaX = Math.abs(x - _startPoint.x);
335
+ const deltaY = Math.abs(y - _startPoint.y);
336
+
337
+ if (deltaX + deltaY > MOUSE_MOVE_THRESHOLD) {
338
+ canvas.remove(zoomArea);
339
+ zoomArea.set(this._calcRectDimensionFromPoint(x, y));
340
+ canvas.add(zoomArea);
341
+ }
342
+ }
343
+
344
+ /**
345
+ * Get rect dimension setting from Canvas-Mouse-Position(x, y)
346
+ * @param {number} x - Canvas-Mouse-Position x
347
+ * @param {number} y - Canvas-Mouse-Position Y
348
+ * @returns {{left: number, top: number, width: number, height: number}}
349
+ * @private
350
+ */
351
+ _calcRectDimensionFromPoint(x, y) {
352
+ const canvas = this.getCanvas();
353
+ const canvasWidth = canvas.getWidth();
354
+ const canvasHeight = canvas.getHeight();
355
+ const { x: startX, y: startY } = this._startPoint;
356
+ const { min } = Math;
357
+
358
+ const left = min(startX, x);
359
+ const top = min(startY, y);
360
+ const width = clamp(x, startX, canvasWidth) - left; // (startX <= x(mouse) <= canvasWidth) - left
361
+ const height = clamp(y, startY, canvasHeight) - top; // (startY <= y(mouse) <= canvasHeight) - top
362
+
363
+ return { left, top, width, height };
364
+ }
365
+
366
+ /**
367
+ * onMouseup handler in fabric canvas
368
+ * @private
369
+ */
370
+ _onMouseUpWithZoomMode() {
371
+ let { zoomLevel } = this;
372
+ const { zoomArea } = this;
373
+ const { moveZoom, stopZoom } = this._listeners;
374
+ const canvas = this.getCanvas();
375
+ const center = this._getCenterPoint();
376
+ const { x, y } = center;
377
+
378
+ if (!this._isMaxZoomLevel()) {
379
+ this._centerPoints.push({
380
+ x,
381
+ y,
382
+ prevZoomLevel: zoomLevel,
383
+ zoomLevel: zoomLevel + 1,
384
+ });
385
+ zoomLevel += 1;
386
+ canvas.zoomToPoint({ x, y }, zoomLevel);
387
+
388
+ this._fireZoomChanged(canvas, zoomLevel);
389
+
390
+ this.zoomLevel = zoomLevel;
391
+ }
392
+
393
+ canvas.off({
394
+ 'mouse:move': moveZoom,
395
+ 'mouse:up': stopZoom,
396
+ });
397
+
398
+ canvas.remove(zoomArea);
399
+ this._startPoint = null;
400
+ }
401
+
402
+ /**
403
+ * Get center point
404
+ * @returns {{x: number, y: number}}
405
+ * @private
406
+ */
407
+ _getCenterPoint() {
408
+ const { left, top, width, height } = this.zoomArea;
409
+ const { x, y } = this._startPoint;
410
+ const { aspectRatio } = this;
411
+
412
+ if (width < MOUSE_MOVE_THRESHOLD && height < MOUSE_MOVE_THRESHOLD) {
413
+ return { x, y };
414
+ }
415
+
416
+ return width > height
417
+ ? { x: left + (aspectRatio * height) / 2, y: top + height / 2 }
418
+ : { x: left + width / 2, y: top + width / aspectRatio / 2 };
419
+ }
420
+
421
+ /**
422
+ * Zoom the canvas
423
+ * @param {{x: number, y: number}} center - center of zoom
424
+ * @param {?number} zoomLevel - zoom level
425
+ */
426
+ zoom({ x, y }, zoomLevel = this.zoomLevel) {
427
+ const canvas = this.getCanvas();
428
+ const centerPoints = this._centerPoints;
429
+
430
+ for (let i = centerPoints.length - 1; i >= 0; i -= 1) {
431
+ if (centerPoints[i].zoomLevel < zoomLevel) {
432
+ break;
433
+ }
434
+
435
+ const { x: prevX, y: prevY, prevZoomLevel } = centerPoints.pop();
436
+
437
+ canvas.zoomToPoint({ x: prevX, y: prevY }, prevZoomLevel);
438
+ this.zoomLevel = prevZoomLevel;
439
+ }
440
+
441
+ canvas.zoomToPoint({ x, y }, zoomLevel);
442
+ if (!this._isDefaultZoomLevel(zoomLevel)) {
443
+ this._centerPoints.push({
444
+ x,
445
+ y,
446
+ zoomLevel,
447
+ prevZoomLevel: this.zoomLevel,
448
+ });
449
+ }
450
+ this.zoomLevel = zoomLevel;
451
+
452
+ this._fireZoomChanged(canvas, zoomLevel);
453
+ }
454
+
455
+ /**
456
+ * Zoom out one step
457
+ */
458
+ zoomOut() {
459
+ const centerPoints = this._centerPoints;
460
+
461
+ if (!centerPoints.length) {
462
+ return;
463
+ }
464
+
465
+ const canvas = this.getCanvas();
466
+ const point = centerPoints.pop();
467
+ const { x, y, prevZoomLevel } = point;
468
+
469
+ if (this._isDefaultZoomLevel(prevZoomLevel)) {
470
+ canvas.setViewportTransform([1, 0, 0, 1, 0, 0]);
471
+ } else {
472
+ canvas.zoomToPoint({ x, y }, prevZoomLevel);
473
+ }
474
+
475
+ this.zoomLevel = prevZoomLevel;
476
+
477
+ this._fireZoomChanged(canvas, this.zoomLevel);
478
+ }
479
+
480
+ /**
481
+ * Zoom reset
482
+ */
483
+ resetZoom() {
484
+ const canvas = this.getCanvas();
485
+
486
+ canvas.setViewportTransform([1, 0, 0, 1, 0, 0]);
487
+
488
+ this.zoomLevel = DEFAULT_ZOOM_LEVEL;
489
+ this._centerPoints = [];
490
+
491
+ this._fireZoomChanged(canvas, this.zoomLevel);
492
+ }
493
+
494
+ /**
495
+ * Whether zoom level is max (5.0)
496
+ * @returns {boolean}
497
+ * @private
498
+ */
499
+ _isMaxZoomLevel() {
500
+ return this.zoomLevel >= 5.0;
501
+ }
502
+
503
+ /**
504
+ * Move point of zoom
505
+ * @param {{x: number, y: number}} delta - move amount
506
+ * @private
507
+ */
508
+ _movePointOfZoom({ x: deltaX, y: deltaY }) {
509
+ const centerPoints = this._centerPoints;
510
+
511
+ if (!centerPoints.length) {
512
+ return;
513
+ }
514
+
515
+ const canvas = this.getCanvas();
516
+ const { zoomLevel } = this;
517
+
518
+ const point = centerPoints.pop();
519
+ const { x: originX, y: originY, prevZoomLevel } = point;
520
+ const x = originX - deltaX;
521
+ const y = originY - deltaY;
522
+
523
+ canvas.zoomToPoint({ x: originX, y: originY }, prevZoomLevel);
524
+ canvas.zoomToPoint({ x, y }, zoomLevel);
525
+ centerPoints.push({ x, y, prevZoomLevel, zoomLevel });
526
+
527
+ this._fireZoomChanged(canvas, zoomLevel);
528
+ }
529
+
530
+ /**
531
+ * onMouseDown handler in fabric canvas
532
+ * @param {{target: fabric.Object, e: MouseEvent}} fEvent - Fabric event
533
+ * @private
534
+ */
535
+ _onMouseDownWithHandMode({ target, e }) {
536
+ if (target) {
537
+ return;
538
+ }
539
+
540
+ const canvas = this.getCanvas();
541
+
542
+ if (this.zoomLevel <= DEFAULT_ZOOM_LEVEL) {
543
+ return;
544
+ }
545
+
546
+ canvas.selection = false;
547
+
548
+ this._startHandPoint = canvas.getPointer(e);
549
+
550
+ const { moveHand, stopHand } = this._listeners;
551
+ canvas.on({
552
+ 'mouse:move': moveHand,
553
+ 'mouse:up': stopHand,
554
+ });
555
+ }
556
+
557
+ /**
558
+ * onMouseMove handler in fabric canvas
559
+ * @param {{e: MouseEvent}} fEvent - Fabric event
560
+ * @private
561
+ */
562
+ _onMouseMoveWithHandMode({ e }) {
563
+ const canvas = this.getCanvas();
564
+ const { x, y } = canvas.getPointer(e);
565
+ const deltaX = x - this._startHandPoint.x;
566
+ const deltaY = y - this._startHandPoint.y;
567
+
568
+ this._movePointOfZoom({ x: deltaX, y: deltaY });
569
+ }
570
+
571
+ /**
572
+ * onMouseUp handler in fabric canvas
573
+ * @private
574
+ */
575
+ _onMouseUpWithHandMode() {
576
+ const canvas = this.getCanvas();
577
+ const { moveHand, stopHand } = this._listeners;
578
+
579
+ canvas.off({
580
+ 'mouse:move': moveHand,
581
+ 'mouse:up': stopHand,
582
+ });
583
+
584
+ this._startHandPoint = null;
585
+ }
586
+
587
+ /**
588
+ * onChangeZoom handler in fabric canvas
589
+ * @private
590
+ */
591
+ _changeScrollState({ viewport, zoomLevel }) {
592
+ const canvas = this.getCanvas();
593
+
594
+ canvas.remove(this._verticalScroll);
595
+ canvas.remove(this._horizontalScroll);
596
+
597
+ if (this._isDefaultZoomLevel(zoomLevel)) {
598
+ return;
599
+ }
600
+
601
+ const canvasWidth = canvas.width;
602
+ const canvasHeight = canvas.height;
603
+
604
+ const { tl, tr, bl } = viewport;
605
+ const viewportWidth = tr.x - tl.x;
606
+ const viewportHeight = bl.y - tl.y;
607
+
608
+ const horizontalScrollWidth = (viewportWidth * viewportWidth) / canvasWidth;
609
+ const horizontalScrollHeight = viewportHeight * DEFAULT_HORIZONTAL_SCROLL_RATIO.SIZE;
610
+ const horizontalScrollLeft = clamp(
611
+ tl.x + (tl.x / canvasWidth) * viewportWidth,
612
+ tl.x,
613
+ tr.x - horizontalScrollWidth
614
+ );
615
+ const horizontalScrollMargin = viewportHeight * DEFAULT_HORIZONTAL_SCROLL_RATIO.MARGIN;
616
+ const horizontalScrollBorderRadius =
617
+ viewportHeight * DEFAULT_HORIZONTAL_SCROLL_RATIO.BORDER_RADIUS;
618
+
619
+ this._horizontalScroll.set({
620
+ left: horizontalScrollLeft,
621
+ top: bl.y - horizontalScrollHeight - horizontalScrollMargin,
622
+ width: horizontalScrollWidth,
623
+ height: horizontalScrollHeight,
624
+ rx: horizontalScrollBorderRadius,
625
+ ry: horizontalScrollBorderRadius,
626
+ });
627
+
628
+ const verticalScrollWidth = viewportWidth * DEFAULT_VERTICAL_SCROLL_RATIO.SIZE;
629
+ const verticalScrollHeight = (viewportHeight * viewportHeight) / canvasHeight;
630
+ const verticalScrollTop = clamp(
631
+ tl.y + (tl.y / canvasHeight) * viewportHeight,
632
+ tr.y,
633
+ bl.y - verticalScrollHeight
634
+ );
635
+ const verticalScrollMargin = viewportWidth * DEFAULT_VERTICAL_SCROLL_RATIO.MARGIN;
636
+ const verticalScrollBorderRadius = viewportWidth * DEFAULT_VERTICAL_SCROLL_RATIO.BORDER_RADIUS;
637
+
638
+ this._verticalScroll.set({
639
+ left: tr.x - verticalScrollWidth - verticalScrollMargin,
640
+ top: verticalScrollTop,
641
+ width: verticalScrollWidth,
642
+ height: verticalScrollHeight,
643
+ rx: verticalScrollBorderRadius,
644
+ ry: verticalScrollBorderRadius,
645
+ });
646
+
647
+ this._addScrollBar();
648
+ }
649
+
650
+ /**
651
+ * Change objects 'evented' state
652
+ * @param {boolean} [evented=true] - objects 'evented' state
653
+ */
654
+ _changeObjectsEventedState(evented = true) {
655
+ const canvas = this.getCanvas();
656
+
657
+ canvas.forEachObject((obj) => {
658
+ // {@link http://fabricjs.com/docs/fabric.Object.html#evented}
659
+ obj.evented = evented;
660
+ });
661
+ }
662
+
663
+ /**
664
+ * Add scroll bar and set remove timer
665
+ */
666
+ _addScrollBar() {
667
+ const canvas = this.getCanvas();
668
+
669
+ canvas.add(this._horizontalScroll);
670
+ canvas.add(this._verticalScroll);
671
+
672
+ if (this.scrollBarTid) {
673
+ clearTimeout(this.scrollBarTid);
674
+ }
675
+
676
+ this.scrollBarTid = setTimeout(() => {
677
+ canvas.remove(this._horizontalScroll);
678
+ canvas.remove(this._verticalScroll);
679
+ }, 3000);
680
+ }
681
+
682
+ /**
683
+ * Check zoom level is default zoom level (1.0)
684
+ * @param {number} zoomLevel - zoom level
685
+ * @returns {boolean} - whether zoom level is 1.0
686
+ */
687
+ _isDefaultZoomLevel(zoomLevel) {
688
+ return zoomLevel === DEFAULT_ZOOM_LEVEL;
689
+ }
690
+
691
+ /**
692
+ * Fire 'zoomChanged' event
693
+ * @param {fabric.Canvas} canvas - fabric canvas
694
+ * @param {number} zoomLevel - 'zoomChanged' event params
695
+ */
696
+ _fireZoomChanged(canvas, zoomLevel) {
697
+ canvas.fire(ZOOM_CHANGED, { viewport: canvas.calcViewportBoundaries(), zoomLevel });
698
+ }
699
+
700
+ /**
701
+ * Get zoom mode
702
+ */
703
+ get mode() {
704
+ return this.zoomMode;
705
+ }
706
+ }
707
+
708
+ export default Zoom;