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.
- package/README.md +193 -0
- package/dist/svg/icon-a.svg +376 -0
- package/dist/svg/icon-b.svg +369 -0
- package/dist/svg/icon-c.svg +369 -0
- package/dist/svg/icon-d.svg +369 -0
- package/dist/tui-image-editor.css +6 -0
- package/dist/tui-image-editor.js +62329 -0
- package/dist/tui-image-editor.min.css +5 -0
- package/dist/tui-image-editor.min.js +15 -0
- package/index.d.ts +334 -0
- package/package.json +52 -0
- package/src/css/buttons.styl +102 -0
- package/src/css/checkbox.styl +86 -0
- package/src/css/colorpicker.styl +98 -0
- package/src/css/gridtable.styl +45 -0
- package/src/css/icon.styl +44 -0
- package/src/css/index.styl +17 -0
- package/src/css/main.styl +163 -0
- package/src/css/position.styl +309 -0
- package/src/css/range.styl +91 -0
- package/src/css/submenu.styl +168 -0
- package/src/index.js +29 -0
- package/src/js/action.js +686 -0
- package/src/js/command/addIcon.js +42 -0
- package/src/js/command/addImageObject.js +34 -0
- package/src/js/command/addObject.js +43 -0
- package/src/js/command/addShape.js +51 -0
- package/src/js/command/addText.js +73 -0
- package/src/js/command/applyFilter.js +95 -0
- package/src/js/command/changeIconColor.js +48 -0
- package/src/js/command/changeSelection.js +31 -0
- package/src/js/command/changeShape.js +84 -0
- package/src/js/command/changeText.js +44 -0
- package/src/js/command/changeTextStyle.js +80 -0
- package/src/js/command/clearObjects.js +33 -0
- package/src/js/command/flip.js +36 -0
- package/src/js/command/loadImage.js +58 -0
- package/src/js/command/removeFilter.js +38 -0
- package/src/js/command/removeObject.js +37 -0
- package/src/js/command/resize.js +41 -0
- package/src/js/command/resizeCanvasDimension.js +40 -0
- package/src/js/command/rotate.js +64 -0
- package/src/js/command/setObjectPosition.js +50 -0
- package/src/js/command/setObjectProperties.js +55 -0
- package/src/js/component/cropper.js +407 -0
- package/src/js/component/filter.js +229 -0
- package/src/js/component/flip.js +146 -0
- package/src/js/component/freeDrawing.js +144 -0
- package/src/js/component/icon.js +246 -0
- package/src/js/component/imageLoader.js +84 -0
- package/src/js/component/line.js +205 -0
- package/src/js/component/resize.js +103 -0
- package/src/js/component/rotation.js +91 -0
- package/src/js/component/shape.js +601 -0
- package/src/js/component/text.js +572 -0
- package/src/js/component/zoom.js +708 -0
- package/src/js/consts.js +404 -0
- package/src/js/drawingMode/cropper.js +35 -0
- package/src/js/drawingMode/freeDrawing.js +36 -0
- package/src/js/drawingMode/icon.js +35 -0
- package/src/js/drawingMode/lineDrawing.js +36 -0
- package/src/js/drawingMode/resize.js +35 -0
- package/src/js/drawingMode/shape.js +35 -0
- package/src/js/drawingMode/text.js +35 -0
- package/src/js/drawingMode/zoom.js +37 -0
- package/src/js/extension/arrowLine.js +172 -0
- package/src/js/extension/blur.js +29 -0
- package/src/js/extension/colorFilter.js +104 -0
- package/src/js/extension/cropzone.js +568 -0
- package/src/js/extension/emboss.js +29 -0
- package/src/js/extension/mask.js +90 -0
- package/src/js/extension/sharpen.js +29 -0
- package/src/js/factory/command.js +36 -0
- package/src/js/factory/errorMessage.js +27 -0
- package/src/js/graphics.js +1539 -0
- package/src/js/helper/imagetracer.js +1396 -0
- package/src/js/helper/selectionModifyHelper.js +86 -0
- package/src/js/helper/shapeFilterFillHelper.js +564 -0
- package/src/js/helper/shapeResizeHelper.js +237 -0
- package/src/js/imageEditor.js +1795 -0
- package/src/js/interface/command.js +131 -0
- package/src/js/interface/component.js +127 -0
- package/src/js/interface/drawingMode.js +47 -0
- package/src/js/invoker.js +292 -0
- package/src/js/polyfill.js +498 -0
- package/src/js/ui/crop.js +139 -0
- package/src/js/ui/draw.js +187 -0
- package/src/js/ui/filter.js +510 -0
- package/src/js/ui/flip.js +87 -0
- package/src/js/ui/history.js +171 -0
- package/src/js/ui/icon.js +191 -0
- package/src/js/ui/locale/locale.js +19 -0
- package/src/js/ui/mask.js +96 -0
- package/src/js/ui/panelMenu.js +130 -0
- package/src/js/ui/resize.js +241 -0
- package/src/js/ui/rotate.js +123 -0
- package/src/js/ui/shape.js +265 -0
- package/src/js/ui/submenuBase.js +122 -0
- package/src/js/ui/template/controls.js +21 -0
- package/src/js/ui/template/mainContainer.js +38 -0
- package/src/js/ui/template/style.js +146 -0
- package/src/js/ui/template/submenu/crop.js +73 -0
- package/src/js/ui/template/submenu/draw.js +42 -0
- package/src/js/ui/template/submenu/filter.js +157 -0
- package/src/js/ui/template/submenu/flip.js +41 -0
- package/src/js/ui/template/submenu/history.js +22 -0
- package/src/js/ui/template/submenu/icon.js +108 -0
- package/src/js/ui/template/submenu/mask.js +30 -0
- package/src/js/ui/template/submenu/resize.js +54 -0
- package/src/js/ui/template/submenu/rotate.js +32 -0
- package/src/js/ui/template/submenu/shape.js +45 -0
- package/src/js/ui/template/submenu/text.js +67 -0
- package/src/js/ui/template/submenu/zoom.js +41 -0
- package/src/js/ui/text.js +279 -0
- package/src/js/ui/theme/standard.js +220 -0
- package/src/js/ui/theme/theme.js +249 -0
- package/src/js/ui/tools/colorpicker.js +250 -0
- package/src/js/ui/tools/range.js +390 -0
- package/src/js/ui.js +858 -0
- package/src/js/util.js +551 -0
- package/src/svg/default.svg +335 -0
- package/src/svg/icon-a/ic-apply.svg +6 -0
- package/src/svg/icon-a/ic-cancel.svg +6 -0
- package/src/svg/icon-a/ic-color-transparent-w.svg +12 -0
- package/src/svg/icon-a/ic-crop.svg +7 -0
- package/src/svg/icon-a/ic-delete-all.svg +6 -0
- package/src/svg/icon-a/ic-delete.svg +6 -0
- package/src/svg/icon-a/ic-draw-free.svg +5 -0
- package/src/svg/icon-a/ic-draw-line.svg +5 -0
- package/src/svg/icon-a/ic-draw.svg +6 -0
- package/src/svg/icon-a/ic-filter.svg +7 -0
- package/src/svg/icon-a/ic-flip-reset.svg +7 -0
- package/src/svg/icon-a/ic-flip-x.svg +6 -0
- package/src/svg/icon-a/ic-flip-y.svg +6 -0
- package/src/svg/icon-a/ic-flip.svg +6 -0
- package/src/svg/icon-a/ic-history-check.svg +5 -0
- package/src/svg/icon-a/ic-history-crop.svg +7 -0
- package/src/svg/icon-a/ic-history-delete.svg +9 -0
- package/src/svg/icon-a/ic-history-draw.svg +7 -0
- package/src/svg/icon-a/ic-history-filter.svg +8 -0
- package/src/svg/icon-a/ic-history-flip.svg +6 -0
- package/src/svg/icon-a/ic-history-group.svg +9 -0
- package/src/svg/icon-a/ic-history-icon.svg +6 -0
- package/src/svg/icon-a/ic-history-load.svg +7 -0
- package/src/svg/icon-a/ic-history-mask.svg +9 -0
- package/src/svg/icon-a/ic-history-resize.svg +12 -0
- package/src/svg/icon-a/ic-history-rotate.svg +16 -0
- package/src/svg/icon-a/ic-history-shape.svg +7 -0
- package/src/svg/icon-a/ic-history-text.svg +8 -0
- package/src/svg/icon-a/ic-history.svg +6 -0
- package/src/svg/icon-a/ic-icon-arrow-2.svg +5 -0
- package/src/svg/icon-a/ic-icon-arrow-3.svg +5 -0
- package/src/svg/icon-a/ic-icon-arrow.svg +5 -0
- package/src/svg/icon-a/ic-icon-bubble.svg +5 -0
- package/src/svg/icon-a/ic-icon-heart.svg +5 -0
- package/src/svg/icon-a/ic-icon-load.svg +8 -0
- package/src/svg/icon-a/ic-icon-location.svg +8 -0
- package/src/svg/icon-a/ic-icon-polygon.svg +5 -0
- package/src/svg/icon-a/ic-icon-star-2.svg +5 -0
- package/src/svg/icon-a/ic-icon-star.svg +5 -0
- package/src/svg/icon-a/ic-icon.svg +5 -0
- package/src/svg/icon-a/ic-mask-load.svg +8 -0
- package/src/svg/icon-a/ic-mask.svg +6 -0
- package/src/svg/icon-a/ic-redo.svg +7 -0
- package/src/svg/icon-a/ic-reset.svg +7 -0
- package/src/svg/icon-a/ic-resize.svg +13 -0
- package/src/svg/icon-a/ic-rotate-clockwise.svg +7 -0
- package/src/svg/icon-a/ic-rotate-counterclockwise.svg +7 -0
- package/src/svg/icon-a/ic-rotate.svg +7 -0
- package/src/svg/icon-a/ic-shape-circle.svg +5 -0
- package/src/svg/icon-a/ic-shape-rectangle.svg +5 -0
- package/src/svg/icon-a/ic-shape-triangle.svg +5 -0
- package/src/svg/icon-a/ic-shape.svg +6 -0
- package/src/svg/icon-a/ic-text-align-center.svg +6 -0
- package/src/svg/icon-a/ic-text-align-left.svg +6 -0
- package/src/svg/icon-a/ic-text-align-right.svg +6 -0
- package/src/svg/icon-a/ic-text-bold.svg +7 -0
- package/src/svg/icon-a/ic-text-italic.svg +6 -0
- package/src/svg/icon-a/ic-text-underline.svg +7 -0
- package/src/svg/icon-a/ic-text.svg +7 -0
- package/src/svg/icon-a/ic-undo.svg +7 -0
- package/src/svg/icon-a/ic-zoom-hand.svg +8 -0
- package/src/svg/icon-a/ic-zoom-zoom-in.svg +10 -0
- package/src/svg/icon-a/ic-zoom-zoom-out.svg +9 -0
- package/src/svg/icon-a/img-bi.svg +5 -0
- package/src/svg/icon-b/ic-apply.svg +6 -0
- package/src/svg/icon-b/ic-cancel.svg +6 -0
- package/src/svg/icon-b/ic-crop.svg +7 -0
- package/src/svg/icon-b/ic-delete-all.svg +6 -0
- package/src/svg/icon-b/ic-delete.svg +6 -0
- package/src/svg/icon-b/ic-draw-free.svg +5 -0
- package/src/svg/icon-b/ic-draw-line.svg +5 -0
- package/src/svg/icon-b/ic-draw.svg +6 -0
- package/src/svg/icon-b/ic-filter.svg +7 -0
- package/src/svg/icon-b/ic-flip-reset.svg +7 -0
- package/src/svg/icon-b/ic-flip-x.svg +6 -0
- package/src/svg/icon-b/ic-flip-y.svg +6 -0
- package/src/svg/icon-b/ic-flip.svg +6 -0
- package/src/svg/icon-b/ic-history-check.svg +5 -0
- package/src/svg/icon-b/ic-history-crop.svg +7 -0
- package/src/svg/icon-b/ic-history-delete.svg +9 -0
- package/src/svg/icon-b/ic-history-draw.svg +7 -0
- package/src/svg/icon-b/ic-history-filter.svg +8 -0
- package/src/svg/icon-b/ic-history-flip.svg +6 -0
- package/src/svg/icon-b/ic-history-group.svg +9 -0
- package/src/svg/icon-b/ic-history-icon.svg +6 -0
- package/src/svg/icon-b/ic-history-load.svg +7 -0
- package/src/svg/icon-b/ic-history-mask.svg +9 -0
- package/src/svg/icon-b/ic-history-resize.svg +12 -0
- package/src/svg/icon-b/ic-history-rotate.svg +16 -0
- package/src/svg/icon-b/ic-history-shape.svg +7 -0
- package/src/svg/icon-b/ic-history-text.svg +8 -0
- package/src/svg/icon-b/ic-history.svg +6 -0
- package/src/svg/icon-b/ic-icon-arrow-2.svg +5 -0
- package/src/svg/icon-b/ic-icon-arrow-3.svg +5 -0
- package/src/svg/icon-b/ic-icon-arrow.svg +5 -0
- package/src/svg/icon-b/ic-icon-bubble.svg +5 -0
- package/src/svg/icon-b/ic-icon-heart.svg +5 -0
- package/src/svg/icon-b/ic-icon-load.svg +8 -0
- package/src/svg/icon-b/ic-icon-location.svg +8 -0
- package/src/svg/icon-b/ic-icon-polygon.svg +5 -0
- package/src/svg/icon-b/ic-icon-star-2.svg +5 -0
- package/src/svg/icon-b/ic-icon-star.svg +5 -0
- package/src/svg/icon-b/ic-icon.svg +5 -0
- package/src/svg/icon-b/ic-mask-load.svg +8 -0
- package/src/svg/icon-b/ic-mask.svg +6 -0
- package/src/svg/icon-b/ic-redo.svg +7 -0
- package/src/svg/icon-b/ic-reset.svg +7 -0
- package/src/svg/icon-b/ic-resize.svg +13 -0
- package/src/svg/icon-b/ic-rotate-clockwise.svg +7 -0
- package/src/svg/icon-b/ic-rotate-counterclockwise.svg +7 -0
- package/src/svg/icon-b/ic-rotate.svg +7 -0
- package/src/svg/icon-b/ic-shape-circle.svg +5 -0
- package/src/svg/icon-b/ic-shape-rectangle.svg +5 -0
- package/src/svg/icon-b/ic-shape-triangle.svg +5 -0
- package/src/svg/icon-b/ic-shape.svg +6 -0
- package/src/svg/icon-b/ic-text-align-center.svg +6 -0
- package/src/svg/icon-b/ic-text-align-left.svg +6 -0
- package/src/svg/icon-b/ic-text-align-right.svg +6 -0
- package/src/svg/icon-b/ic-text-bold.svg +7 -0
- package/src/svg/icon-b/ic-text-italic.svg +6 -0
- package/src/svg/icon-b/ic-text-underline.svg +7 -0
- package/src/svg/icon-b/ic-text.svg +7 -0
- package/src/svg/icon-b/ic-undo.svg +7 -0
- package/src/svg/icon-b/ic-zoom-hand.svg +8 -0
- package/src/svg/icon-b/ic-zoom-zoom-in.svg +12 -0
- package/src/svg/icon-b/ic-zoom-zoom-out.svg +11 -0
- package/src/svg/icon-b/img-bi.svg +5 -0
- package/src/svg/icon-c/ic-apply.svg +6 -0
- package/src/svg/icon-c/ic-cancel.svg +6 -0
- package/src/svg/icon-c/ic-crop.svg +7 -0
- package/src/svg/icon-c/ic-delete-all.svg +6 -0
- package/src/svg/icon-c/ic-delete.svg +6 -0
- package/src/svg/icon-c/ic-draw-free.svg +5 -0
- package/src/svg/icon-c/ic-draw-line.svg +5 -0
- package/src/svg/icon-c/ic-draw.svg +6 -0
- package/src/svg/icon-c/ic-filter.svg +7 -0
- package/src/svg/icon-c/ic-flip-reset.svg +7 -0
- package/src/svg/icon-c/ic-flip-x.svg +6 -0
- package/src/svg/icon-c/ic-flip-y.svg +6 -0
- package/src/svg/icon-c/ic-flip.svg +6 -0
- package/src/svg/icon-c/ic-history-check.svg +5 -0
- package/src/svg/icon-c/ic-history-crop.svg +7 -0
- package/src/svg/icon-c/ic-history-delete.svg +9 -0
- package/src/svg/icon-c/ic-history-draw.svg +7 -0
- package/src/svg/icon-c/ic-history-filter.svg +8 -0
- package/src/svg/icon-c/ic-history-flip.svg +6 -0
- package/src/svg/icon-c/ic-history-group.svg +9 -0
- package/src/svg/icon-c/ic-history-icon.svg +6 -0
- package/src/svg/icon-c/ic-history-load.svg +7 -0
- package/src/svg/icon-c/ic-history-mask.svg +9 -0
- package/src/svg/icon-c/ic-history-resize.svg +12 -0
- package/src/svg/icon-c/ic-history-rotate.svg +16 -0
- package/src/svg/icon-c/ic-history-shape.svg +7 -0
- package/src/svg/icon-c/ic-history-text.svg +8 -0
- package/src/svg/icon-c/ic-history.svg +6 -0
- package/src/svg/icon-c/ic-icon-arrow-2.svg +5 -0
- package/src/svg/icon-c/ic-icon-arrow-3.svg +5 -0
- package/src/svg/icon-c/ic-icon-arrow.svg +5 -0
- package/src/svg/icon-c/ic-icon-bubble.svg +5 -0
- package/src/svg/icon-c/ic-icon-heart.svg +5 -0
- package/src/svg/icon-c/ic-icon-load.svg +8 -0
- package/src/svg/icon-c/ic-icon-location.svg +8 -0
- package/src/svg/icon-c/ic-icon-polygon.svg +5 -0
- package/src/svg/icon-c/ic-icon-star-2.svg +5 -0
- package/src/svg/icon-c/ic-icon-star.svg +5 -0
- package/src/svg/icon-c/ic-icon.svg +5 -0
- package/src/svg/icon-c/ic-mask-load.svg +8 -0
- package/src/svg/icon-c/ic-mask.svg +6 -0
- package/src/svg/icon-c/ic-redo.svg +7 -0
- package/src/svg/icon-c/ic-reset.svg +7 -0
- package/src/svg/icon-c/ic-resize.svg +13 -0
- package/src/svg/icon-c/ic-rotate-clockwise.svg +7 -0
- package/src/svg/icon-c/ic-rotate-counterclockwise.svg +7 -0
- package/src/svg/icon-c/ic-rotate.svg +7 -0
- package/src/svg/icon-c/ic-shape-circle.svg +5 -0
- package/src/svg/icon-c/ic-shape-rectangle.svg +5 -0
- package/src/svg/icon-c/ic-shape-triangle.svg +5 -0
- package/src/svg/icon-c/ic-shape.svg +6 -0
- package/src/svg/icon-c/ic-text-align-center.svg +6 -0
- package/src/svg/icon-c/ic-text-align-left.svg +6 -0
- package/src/svg/icon-c/ic-text-align-right.svg +6 -0
- package/src/svg/icon-c/ic-text-bold.svg +7 -0
- package/src/svg/icon-c/ic-text-italic.svg +6 -0
- package/src/svg/icon-c/ic-text-underline.svg +7 -0
- package/src/svg/icon-c/ic-text.svg +7 -0
- package/src/svg/icon-c/ic-undo.svg +7 -0
- package/src/svg/icon-c/ic-zoom-hand.svg +8 -0
- package/src/svg/icon-c/ic-zoom-zoom-in.svg +12 -0
- package/src/svg/icon-c/ic-zoom-zoom-out.svg +11 -0
- package/src/svg/icon-c/img-bi.svg +5 -0
- package/src/svg/icon-d/ic-apply.svg +6 -0
- package/src/svg/icon-d/ic-cancel.svg +6 -0
- package/src/svg/icon-d/ic-crop.svg +7 -0
- package/src/svg/icon-d/ic-delete-all.svg +6 -0
- package/src/svg/icon-d/ic-delete.svg +6 -0
- package/src/svg/icon-d/ic-draw-free.svg +5 -0
- package/src/svg/icon-d/ic-draw-line.svg +5 -0
- package/src/svg/icon-d/ic-draw.svg +6 -0
- package/src/svg/icon-d/ic-filter.svg +7 -0
- package/src/svg/icon-d/ic-flip-reset.svg +7 -0
- package/src/svg/icon-d/ic-flip-x.svg +6 -0
- package/src/svg/icon-d/ic-flip-y.svg +6 -0
- package/src/svg/icon-d/ic-flip.svg +6 -0
- package/src/svg/icon-d/ic-history-check.svg +5 -0
- package/src/svg/icon-d/ic-history-crop.svg +7 -0
- package/src/svg/icon-d/ic-history-delete.svg +9 -0
- package/src/svg/icon-d/ic-history-draw.svg +7 -0
- package/src/svg/icon-d/ic-history-filter.svg +8 -0
- package/src/svg/icon-d/ic-history-flip.svg +6 -0
- package/src/svg/icon-d/ic-history-group.svg +9 -0
- package/src/svg/icon-d/ic-history-icon.svg +6 -0
- package/src/svg/icon-d/ic-history-load.svg +7 -0
- package/src/svg/icon-d/ic-history-mask.svg +9 -0
- package/src/svg/icon-d/ic-history-resize.svg +12 -0
- package/src/svg/icon-d/ic-history-rotate.svg +16 -0
- package/src/svg/icon-d/ic-history-shape.svg +7 -0
- package/src/svg/icon-d/ic-history-text.svg +8 -0
- package/src/svg/icon-d/ic-history.svg +6 -0
- package/src/svg/icon-d/ic-icon-arrow-2.svg +5 -0
- package/src/svg/icon-d/ic-icon-arrow-3.svg +5 -0
- package/src/svg/icon-d/ic-icon-arrow.svg +5 -0
- package/src/svg/icon-d/ic-icon-bubble.svg +5 -0
- package/src/svg/icon-d/ic-icon-heart.svg +5 -0
- package/src/svg/icon-d/ic-icon-load.svg +8 -0
- package/src/svg/icon-d/ic-icon-location.svg +8 -0
- package/src/svg/icon-d/ic-icon-polygon.svg +5 -0
- package/src/svg/icon-d/ic-icon-star-2.svg +5 -0
- package/src/svg/icon-d/ic-icon-star.svg +5 -0
- package/src/svg/icon-d/ic-icon.svg +5 -0
- package/src/svg/icon-d/ic-mask-load.svg +8 -0
- package/src/svg/icon-d/ic-mask.svg +6 -0
- package/src/svg/icon-d/ic-redo.svg +7 -0
- package/src/svg/icon-d/ic-reset.svg +7 -0
- package/src/svg/icon-d/ic-resize.svg +13 -0
- package/src/svg/icon-d/ic-rotate-clockwise.svg +7 -0
- package/src/svg/icon-d/ic-rotate-counterclockwise.svg +7 -0
- package/src/svg/icon-d/ic-rotate.svg +7 -0
- package/src/svg/icon-d/ic-shape-circle.svg +5 -0
- package/src/svg/icon-d/ic-shape-rectangle.svg +5 -0
- package/src/svg/icon-d/ic-shape-triangle.svg +5 -0
- package/src/svg/icon-d/ic-shape.svg +6 -0
- package/src/svg/icon-d/ic-text-align-center.svg +6 -0
- package/src/svg/icon-d/ic-text-align-left.svg +6 -0
- package/src/svg/icon-d/ic-text-align-right.svg +6 -0
- package/src/svg/icon-d/ic-text-bold.svg +7 -0
- package/src/svg/icon-d/ic-text-italic.svg +6 -0
- package/src/svg/icon-d/ic-text-underline.svg +7 -0
- package/src/svg/icon-d/ic-text.svg +7 -0
- package/src/svg/icon-d/ic-undo.svg +7 -0
- package/src/svg/icon-d/ic-zoom-hand.svg +8 -0
- package/src/svg/icon-d/ic-zoom-zoom-in.svg +12 -0
- package/src/svg/icon-d/ic-zoom-zoom-out.svg +11 -0
- package/src/svg/icon-d/img-bi.svg +5 -0
@@ -0,0 +1,250 @@
|
|
1
|
+
import forEach from 'tui-code-snippet/collection/forEach';
|
2
|
+
import CustomEvents from 'tui-code-snippet/customEvents/customEvents';
|
3
|
+
import tuiColorPicker from 'tui-color-picker';
|
4
|
+
|
5
|
+
const PICKER_COLOR = [
|
6
|
+
'#000000',
|
7
|
+
'#2a2a2a',
|
8
|
+
'#545454',
|
9
|
+
'#7e7e7e',
|
10
|
+
'#a8a8a8',
|
11
|
+
'#d2d2d2',
|
12
|
+
'#ffffff',
|
13
|
+
'',
|
14
|
+
'#ff4040',
|
15
|
+
'#ff6518',
|
16
|
+
'#ffbb3b',
|
17
|
+
'#03bd9e',
|
18
|
+
'#00a9ff',
|
19
|
+
'#515ce6',
|
20
|
+
'#9e5fff',
|
21
|
+
'#ff5583',
|
22
|
+
];
|
23
|
+
|
24
|
+
/**
|
25
|
+
* Colorpicker control class
|
26
|
+
* @class
|
27
|
+
* @ignore
|
28
|
+
*/
|
29
|
+
class Colorpicker {
|
30
|
+
constructor(
|
31
|
+
colorpickerElement,
|
32
|
+
{ defaultColor = '#7e7e7e', toggleDirection = 'up', usageStatistics }
|
33
|
+
) {
|
34
|
+
this.colorpickerElement = colorpickerElement;
|
35
|
+
this.usageStatistics = usageStatistics;
|
36
|
+
|
37
|
+
this._show = false;
|
38
|
+
|
39
|
+
this._colorpickerElement = colorpickerElement;
|
40
|
+
this._toggleDirection = toggleDirection;
|
41
|
+
this._makePickerButtonElement(defaultColor);
|
42
|
+
this._makePickerLayerElement(colorpickerElement, colorpickerElement.getAttribute('title'));
|
43
|
+
this._color = defaultColor;
|
44
|
+
this.picker = tuiColorPicker.create({
|
45
|
+
container: this.pickerElement,
|
46
|
+
preset: PICKER_COLOR,
|
47
|
+
color: defaultColor,
|
48
|
+
usageStatistics: this.usageStatistics,
|
49
|
+
});
|
50
|
+
|
51
|
+
this._addEvent();
|
52
|
+
}
|
53
|
+
|
54
|
+
/**
|
55
|
+
* Destroys the instance.
|
56
|
+
*/
|
57
|
+
destroy() {
|
58
|
+
this._removeEvent();
|
59
|
+
this.picker.destroy();
|
60
|
+
this.colorpickerElement.innerHTML = '';
|
61
|
+
forEach(this, (value, key) => {
|
62
|
+
this[key] = null;
|
63
|
+
});
|
64
|
+
}
|
65
|
+
|
66
|
+
/**
|
67
|
+
* Get color
|
68
|
+
* @returns {Number} color value
|
69
|
+
*/
|
70
|
+
get color() {
|
71
|
+
return this._color;
|
72
|
+
}
|
73
|
+
|
74
|
+
/**
|
75
|
+
* Set color
|
76
|
+
* @param {string} color color value
|
77
|
+
*/
|
78
|
+
set color(color) {
|
79
|
+
this._color = color;
|
80
|
+
this._changeColorElement(color);
|
81
|
+
}
|
82
|
+
|
83
|
+
/**
|
84
|
+
* Change color element
|
85
|
+
* @param {string} color color value
|
86
|
+
* #private
|
87
|
+
*/
|
88
|
+
_changeColorElement(color) {
|
89
|
+
if (color) {
|
90
|
+
this.colorElement.classList.remove('transparent');
|
91
|
+
this.colorElement.style.backgroundColor = color;
|
92
|
+
} else {
|
93
|
+
this.colorElement.style.backgroundColor = '#fff';
|
94
|
+
this.colorElement.classList.add('transparent');
|
95
|
+
}
|
96
|
+
}
|
97
|
+
|
98
|
+
/**
|
99
|
+
* Make picker button element
|
100
|
+
* @param {string} defaultColor color value
|
101
|
+
* @private
|
102
|
+
*/
|
103
|
+
_makePickerButtonElement(defaultColor) {
|
104
|
+
this.colorpickerElement.classList.add('tui-image-editor-button');
|
105
|
+
|
106
|
+
this.colorElement = document.createElement('div');
|
107
|
+
this.colorElement.className = 'color-picker-value';
|
108
|
+
if (defaultColor) {
|
109
|
+
this.colorElement.style.backgroundColor = defaultColor;
|
110
|
+
} else {
|
111
|
+
this.colorElement.classList.add('transparent');
|
112
|
+
}
|
113
|
+
}
|
114
|
+
|
115
|
+
/**
|
116
|
+
* Make picker layer element
|
117
|
+
* @param {HTMLElement} colorpickerElement color picker element
|
118
|
+
* @param {string} title picker title
|
119
|
+
* @private
|
120
|
+
*/
|
121
|
+
_makePickerLayerElement(colorpickerElement, title) {
|
122
|
+
const label = document.createElement('label');
|
123
|
+
const triangle = document.createElement('div');
|
124
|
+
|
125
|
+
this.pickerControl = document.createElement('div');
|
126
|
+
this.pickerControl.className = 'color-picker-control';
|
127
|
+
|
128
|
+
this.pickerElement = document.createElement('div');
|
129
|
+
this.pickerElement.className = 'color-picker';
|
130
|
+
|
131
|
+
label.innerHTML = title;
|
132
|
+
triangle.className = 'triangle';
|
133
|
+
|
134
|
+
this.pickerControl.appendChild(this.pickerElement);
|
135
|
+
this.pickerControl.appendChild(triangle);
|
136
|
+
|
137
|
+
colorpickerElement.appendChild(this.pickerControl);
|
138
|
+
colorpickerElement.appendChild(this.colorElement);
|
139
|
+
colorpickerElement.appendChild(label);
|
140
|
+
}
|
141
|
+
|
142
|
+
/**
|
143
|
+
* Add event
|
144
|
+
* @private
|
145
|
+
*/
|
146
|
+
_addEvent() {
|
147
|
+
this.picker.on('selectColor', (value) => {
|
148
|
+
this._changeColorElement(value.color);
|
149
|
+
this._color = value.color;
|
150
|
+
this.fire('change', value.color);
|
151
|
+
});
|
152
|
+
|
153
|
+
this.eventHandler = {
|
154
|
+
pickerToggle: this._pickerToggleEventHandler.bind(this),
|
155
|
+
pickerHide: () => this.hide(),
|
156
|
+
};
|
157
|
+
|
158
|
+
this.colorpickerElement.addEventListener('click', this.eventHandler.pickerToggle);
|
159
|
+
document.body.addEventListener('click', this.eventHandler.pickerHide);
|
160
|
+
}
|
161
|
+
|
162
|
+
/**
|
163
|
+
* Remove event
|
164
|
+
* @private
|
165
|
+
*/
|
166
|
+
_removeEvent() {
|
167
|
+
this.colorpickerElement.removeEventListener('click', this.eventHandler.pickerToggle);
|
168
|
+
document.body.removeEventListener('click', this.eventHandler.pickerHide);
|
169
|
+
this.picker.off();
|
170
|
+
}
|
171
|
+
|
172
|
+
/**
|
173
|
+
* Picker toggle event handler
|
174
|
+
* @param {object} event - change event
|
175
|
+
* @private
|
176
|
+
*/
|
177
|
+
_pickerToggleEventHandler(event) {
|
178
|
+
const { target } = event;
|
179
|
+
const isInPickerControl = target && this._isElementInColorPickerControl(target);
|
180
|
+
|
181
|
+
if (!isInPickerControl || (isInPickerControl && this._isPaletteButton(target))) {
|
182
|
+
this._show = !this._show;
|
183
|
+
this.pickerControl.style.display = this._show ? 'block' : 'none';
|
184
|
+
this._setPickerControlPosition();
|
185
|
+
this.fire('changeShow', this);
|
186
|
+
}
|
187
|
+
event.stopPropagation();
|
188
|
+
}
|
189
|
+
|
190
|
+
/**
|
191
|
+
* Check hex input or not
|
192
|
+
* @param {Element} target - Event target element
|
193
|
+
* @returns {boolean}
|
194
|
+
* @private
|
195
|
+
*/
|
196
|
+
_isPaletteButton(target) {
|
197
|
+
return target.className === 'tui-colorpicker-palette-button';
|
198
|
+
}
|
199
|
+
|
200
|
+
/**
|
201
|
+
* Check given element is in pickerControl element
|
202
|
+
* @param {Element} element - element to check
|
203
|
+
* @returns {boolean}
|
204
|
+
* @private
|
205
|
+
*/
|
206
|
+
_isElementInColorPickerControl(element) {
|
207
|
+
let parentNode = element;
|
208
|
+
|
209
|
+
while (parentNode !== document.body) {
|
210
|
+
if (!parentNode) {
|
211
|
+
break;
|
212
|
+
}
|
213
|
+
|
214
|
+
if (parentNode === this.pickerControl) {
|
215
|
+
return true;
|
216
|
+
}
|
217
|
+
|
218
|
+
parentNode = parentNode.parentNode;
|
219
|
+
}
|
220
|
+
|
221
|
+
return false;
|
222
|
+
}
|
223
|
+
|
224
|
+
hide() {
|
225
|
+
this._show = false;
|
226
|
+
this.pickerControl.style.display = 'none';
|
227
|
+
}
|
228
|
+
|
229
|
+
/**
|
230
|
+
* Set picker control position
|
231
|
+
* @private
|
232
|
+
*/
|
233
|
+
_setPickerControlPosition() {
|
234
|
+
const controlStyle = this.pickerControl.style;
|
235
|
+
const halfPickerWidth = this._colorpickerElement.clientWidth / 2 + 2;
|
236
|
+
const left = this.pickerControl.offsetWidth / 2 - halfPickerWidth;
|
237
|
+
let top = (this.pickerControl.offsetHeight + 10) * -1;
|
238
|
+
|
239
|
+
if (this._toggleDirection === 'down') {
|
240
|
+
top = 30;
|
241
|
+
}
|
242
|
+
|
243
|
+
controlStyle.top = `${top}px`;
|
244
|
+
controlStyle.left = `-${left}px`;
|
245
|
+
}
|
246
|
+
}
|
247
|
+
|
248
|
+
CustomEvents.mixin(Colorpicker);
|
249
|
+
|
250
|
+
export default Colorpicker;
|
@@ -0,0 +1,390 @@
|
|
1
|
+
import forEach from 'tui-code-snippet/collection/forEach';
|
2
|
+
import CustomEvents from 'tui-code-snippet/customEvents/customEvents';
|
3
|
+
import { toInteger, clamp } from '@/util';
|
4
|
+
import { keyCodes } from '@/consts';
|
5
|
+
|
6
|
+
const INPUT_FILTER_REGEXP = /(-?)([0-9]*)[^0-9]*([0-9]*)/g;
|
7
|
+
|
8
|
+
/**
|
9
|
+
* Range control class
|
10
|
+
* @class
|
11
|
+
* @ignore
|
12
|
+
*/
|
13
|
+
class Range {
|
14
|
+
/**
|
15
|
+
* @constructor
|
16
|
+
* @extends {View}
|
17
|
+
* @param {Object} rangeElements - Html resources for creating sliders
|
18
|
+
* @param {HTMLElement} rangeElements.slider - b
|
19
|
+
* @param {HTMLElement} [rangeElements.input] - c
|
20
|
+
* @param {Object} options - Slider make options
|
21
|
+
* @param {number} options.min - min value
|
22
|
+
* @param {number} options.max - max value
|
23
|
+
* @param {number} options.value - default value
|
24
|
+
* @param {number} [options.useDecimal] - Decimal point processing.
|
25
|
+
* @param {boolean} [options.realTimeEvent] - Reflect live events.
|
26
|
+
*/
|
27
|
+
constructor(rangeElements, options = {}) {
|
28
|
+
this._value = options.value || 0;
|
29
|
+
|
30
|
+
this.rangeElement = rangeElements.slider;
|
31
|
+
this.rangeInputElement = rangeElements.input;
|
32
|
+
|
33
|
+
this._drawRangeElement();
|
34
|
+
|
35
|
+
this.rangeWidth = this._getRangeWidth();
|
36
|
+
this._min = options.min || 0;
|
37
|
+
this._max = options.max || 100;
|
38
|
+
this._useDecimal = options.useDecimal;
|
39
|
+
this._absMax = this._min * -1 + this._max;
|
40
|
+
this.realTimeEvent = options.realTimeEvent || false;
|
41
|
+
this._userInputTimer = null;
|
42
|
+
|
43
|
+
this.eventHandler = {
|
44
|
+
startChangingSlide: this._startChangingSlide.bind(this),
|
45
|
+
stopChangingSlide: this._stopChangingSlide.bind(this),
|
46
|
+
changeSlide: this._changeSlide.bind(this),
|
47
|
+
changeSlideFinally: this._changeSlideFinally.bind(this),
|
48
|
+
changeInput: this._changeInput.bind(this),
|
49
|
+
changeInputFinally: this._changeValueWithInput.bind(this, true),
|
50
|
+
changeInputWithArrow: this._changeValueWithInputKeyEvent.bind(this),
|
51
|
+
};
|
52
|
+
|
53
|
+
this._addClickEvent();
|
54
|
+
this._addDragEvent();
|
55
|
+
this._addInputEvent();
|
56
|
+
this.value = options.value;
|
57
|
+
this.trigger('change');
|
58
|
+
}
|
59
|
+
|
60
|
+
/**
|
61
|
+
* Destroys the instance.
|
62
|
+
*/
|
63
|
+
destroy() {
|
64
|
+
this._removeClickEvent();
|
65
|
+
this._removeDragEvent();
|
66
|
+
this._removeInputEvent();
|
67
|
+
this.rangeElement.innerHTML = '';
|
68
|
+
forEach(this, (value, key) => {
|
69
|
+
this[key] = null;
|
70
|
+
});
|
71
|
+
}
|
72
|
+
|
73
|
+
get max() {
|
74
|
+
return this._max;
|
75
|
+
}
|
76
|
+
|
77
|
+
/**
|
78
|
+
* Set range max value and re position cursor
|
79
|
+
* @param {number} maxValue - max value
|
80
|
+
*/
|
81
|
+
set max(maxValue) {
|
82
|
+
this._max = maxValue;
|
83
|
+
this._absMax = this._min * -1 + this._max;
|
84
|
+
this.value = this._value;
|
85
|
+
}
|
86
|
+
|
87
|
+
get min() {
|
88
|
+
return this._min;
|
89
|
+
}
|
90
|
+
|
91
|
+
/**
|
92
|
+
* Set range min value and re position cursor
|
93
|
+
* @param {number} minValue - min value
|
94
|
+
*/
|
95
|
+
set min(minValue) {
|
96
|
+
this._min = minValue;
|
97
|
+
this.max = this._max;
|
98
|
+
}
|
99
|
+
|
100
|
+
/**
|
101
|
+
* Get range value
|
102
|
+
* @returns {Number} range value
|
103
|
+
*/
|
104
|
+
get value() {
|
105
|
+
return this._value;
|
106
|
+
}
|
107
|
+
|
108
|
+
/**
|
109
|
+
* Set range value
|
110
|
+
* @param {Number} value range value
|
111
|
+
*/
|
112
|
+
set value(value) {
|
113
|
+
value = this._useDecimal ? value : toInteger(value);
|
114
|
+
|
115
|
+
const absValue = value - this._min;
|
116
|
+
let leftPosition = (absValue * this.rangeWidth) / this._absMax;
|
117
|
+
|
118
|
+
if (this.rangeWidth < leftPosition) {
|
119
|
+
leftPosition = this.rangeWidth;
|
120
|
+
}
|
121
|
+
|
122
|
+
this.pointer.style.left = `${leftPosition}px`;
|
123
|
+
this.subbar.style.right = `${this.rangeWidth - leftPosition}px`;
|
124
|
+
|
125
|
+
this._value = value;
|
126
|
+
if (this.rangeInputElement) {
|
127
|
+
this.rangeInputElement.value = value;
|
128
|
+
}
|
129
|
+
}
|
130
|
+
|
131
|
+
/**
|
132
|
+
* event trigger
|
133
|
+
* @param {string} type - type
|
134
|
+
*/
|
135
|
+
trigger(type) {
|
136
|
+
this.fire(type, this._value);
|
137
|
+
}
|
138
|
+
|
139
|
+
/**
|
140
|
+
* Calculate slider width
|
141
|
+
* @returns {number} - slider width
|
142
|
+
*/
|
143
|
+
_getRangeWidth() {
|
144
|
+
const getElementWidth = (element) => toInteger(window.getComputedStyle(element, null).width);
|
145
|
+
|
146
|
+
return getElementWidth(this.rangeElement) - getElementWidth(this.pointer);
|
147
|
+
}
|
148
|
+
|
149
|
+
/**
|
150
|
+
* Make range element
|
151
|
+
* @private
|
152
|
+
*/
|
153
|
+
_drawRangeElement() {
|
154
|
+
this.rangeElement.classList.add('tui-image-editor-range');
|
155
|
+
|
156
|
+
this.bar = document.createElement('div');
|
157
|
+
this.bar.className = 'tui-image-editor-virtual-range-bar';
|
158
|
+
|
159
|
+
this.subbar = document.createElement('div');
|
160
|
+
this.subbar.className = 'tui-image-editor-virtual-range-subbar';
|
161
|
+
|
162
|
+
this.pointer = document.createElement('div');
|
163
|
+
this.pointer.className = 'tui-image-editor-virtual-range-pointer';
|
164
|
+
|
165
|
+
this.bar.appendChild(this.subbar);
|
166
|
+
this.bar.appendChild(this.pointer);
|
167
|
+
this.rangeElement.appendChild(this.bar);
|
168
|
+
}
|
169
|
+
|
170
|
+
/**
|
171
|
+
* Add range input editing event
|
172
|
+
* @private
|
173
|
+
*/
|
174
|
+
_addInputEvent() {
|
175
|
+
if (this.rangeInputElement) {
|
176
|
+
this.rangeInputElement.addEventListener('keydown', this.eventHandler.changeInputWithArrow);
|
177
|
+
this.rangeInputElement.addEventListener('keydown', this.eventHandler.changeInput);
|
178
|
+
this.rangeInputElement.addEventListener('blur', this.eventHandler.changeInputFinally);
|
179
|
+
}
|
180
|
+
}
|
181
|
+
|
182
|
+
/**
|
183
|
+
* Remove range input editing event
|
184
|
+
* @private
|
185
|
+
*/
|
186
|
+
_removeInputEvent() {
|
187
|
+
if (this.rangeInputElement) {
|
188
|
+
this.rangeInputElement.removeEventListener('keydown', this.eventHandler.changeInputWithArrow);
|
189
|
+
this.rangeInputElement.removeEventListener('keydown', this.eventHandler.changeInput);
|
190
|
+
this.rangeInputElement.removeEventListener('blur', this.eventHandler.changeInputFinally);
|
191
|
+
}
|
192
|
+
}
|
193
|
+
|
194
|
+
/**
|
195
|
+
* change angle event
|
196
|
+
* @param {object} event - key event
|
197
|
+
* @private
|
198
|
+
*/
|
199
|
+
_changeValueWithInputKeyEvent(event) {
|
200
|
+
const { keyCode, target } = event;
|
201
|
+
|
202
|
+
if ([keyCodes.ARROW_UP, keyCodes.ARROW_DOWN].indexOf(keyCode) < 0) {
|
203
|
+
return;
|
204
|
+
}
|
205
|
+
|
206
|
+
let value = Number(target.value);
|
207
|
+
|
208
|
+
value = this._valueUpDownForKeyEvent(value, keyCode);
|
209
|
+
|
210
|
+
const unChanged = value < this._min || value > this._max;
|
211
|
+
|
212
|
+
if (!unChanged) {
|
213
|
+
const clampValue = clamp(value, this._min, this.max);
|
214
|
+
this.value = clampValue;
|
215
|
+
this.fire('change', clampValue, false);
|
216
|
+
}
|
217
|
+
}
|
218
|
+
|
219
|
+
/**
|
220
|
+
* value up down for input
|
221
|
+
* @param {number} value - original value number
|
222
|
+
* @param {number} keyCode - input event key code
|
223
|
+
* @returns {number} value - changed value
|
224
|
+
* @private
|
225
|
+
*/
|
226
|
+
_valueUpDownForKeyEvent(value, keyCode) {
|
227
|
+
const step = this._useDecimal ? 0.1 : 1;
|
228
|
+
|
229
|
+
if (keyCode === keyCodes.ARROW_UP) {
|
230
|
+
value += step;
|
231
|
+
} else if (keyCode === keyCodes.ARROW_DOWN) {
|
232
|
+
value -= step;
|
233
|
+
}
|
234
|
+
|
235
|
+
return value;
|
236
|
+
}
|
237
|
+
|
238
|
+
_changeInput(event) {
|
239
|
+
clearTimeout(this._userInputTimer);
|
240
|
+
|
241
|
+
const { keyCode } = event;
|
242
|
+
if (keyCode < keyCodes.DIGIT_0 || keyCode > keyCodes.DIGIT_9) {
|
243
|
+
event.preventDefault();
|
244
|
+
|
245
|
+
return;
|
246
|
+
}
|
247
|
+
|
248
|
+
this._userInputTimer = setTimeout(() => {
|
249
|
+
this._inputSetValue(event.target.value);
|
250
|
+
}, 350);
|
251
|
+
}
|
252
|
+
|
253
|
+
_inputSetValue(stringValue) {
|
254
|
+
let value = this._useDecimal ? Number(stringValue) : toInteger(stringValue);
|
255
|
+
value = clamp(value, this._min, this.max);
|
256
|
+
|
257
|
+
this.value = value;
|
258
|
+
this.fire('change', value, true);
|
259
|
+
}
|
260
|
+
|
261
|
+
/**
|
262
|
+
* change angle event
|
263
|
+
* @param {boolean} isLast - Is last change
|
264
|
+
* @param {object} event - key event
|
265
|
+
* @private
|
266
|
+
*/
|
267
|
+
_changeValueWithInput(isLast, event) {
|
268
|
+
const { keyCode, target } = event;
|
269
|
+
|
270
|
+
if ([keyCodes.ARROW_UP, keyCodes.ARROW_DOWN].indexOf(keyCode) >= 0) {
|
271
|
+
return;
|
272
|
+
}
|
273
|
+
|
274
|
+
const stringValue = this._filterForInputText(target.value);
|
275
|
+
const waitForChange = !stringValue || isNaN(stringValue);
|
276
|
+
target.value = stringValue;
|
277
|
+
|
278
|
+
if (!waitForChange) {
|
279
|
+
this._inputSetValue(stringValue);
|
280
|
+
}
|
281
|
+
}
|
282
|
+
|
283
|
+
/**
|
284
|
+
* Add Range click event
|
285
|
+
* @private
|
286
|
+
*/
|
287
|
+
_addClickEvent() {
|
288
|
+
this.rangeElement.addEventListener('click', this.eventHandler.changeSlideFinally);
|
289
|
+
}
|
290
|
+
|
291
|
+
/**
|
292
|
+
* Remove Range click event
|
293
|
+
* @private
|
294
|
+
*/
|
295
|
+
_removeClickEvent() {
|
296
|
+
this.rangeElement.removeEventListener('click', this.eventHandler.changeSlideFinally);
|
297
|
+
}
|
298
|
+
|
299
|
+
/**
|
300
|
+
* Add Range drag event
|
301
|
+
* @private
|
302
|
+
*/
|
303
|
+
_addDragEvent() {
|
304
|
+
this.pointer.addEventListener('mousedown', this.eventHandler.startChangingSlide);
|
305
|
+
}
|
306
|
+
|
307
|
+
/**
|
308
|
+
* Remove Range drag event
|
309
|
+
* @private
|
310
|
+
*/
|
311
|
+
_removeDragEvent() {
|
312
|
+
this.pointer.removeEventListener('mousedown', this.eventHandler.startChangingSlide);
|
313
|
+
}
|
314
|
+
|
315
|
+
/**
|
316
|
+
* change angle event
|
317
|
+
* @param {object} event - change event
|
318
|
+
* @private
|
319
|
+
*/
|
320
|
+
_changeSlide(event) {
|
321
|
+
const changePosition = event.screenX;
|
322
|
+
const diffPosition = changePosition - this.firstPosition;
|
323
|
+
let touchPx = this.firstLeft + diffPosition;
|
324
|
+
touchPx = touchPx > this.rangeWidth ? this.rangeWidth : touchPx;
|
325
|
+
touchPx = touchPx < 0 ? 0 : touchPx;
|
326
|
+
|
327
|
+
this.pointer.style.left = `${touchPx}px`;
|
328
|
+
this.subbar.style.right = `${this.rangeWidth - touchPx}px`;
|
329
|
+
|
330
|
+
const ratio = touchPx / this.rangeWidth;
|
331
|
+
const resultValue = this._absMax * ratio + this._min;
|
332
|
+
const value = this._useDecimal ? resultValue : toInteger(resultValue);
|
333
|
+
const isValueChanged = this.value !== value;
|
334
|
+
|
335
|
+
if (isValueChanged) {
|
336
|
+
this.value = value;
|
337
|
+
if (this.realTimeEvent) {
|
338
|
+
this.fire('change', this._value, false);
|
339
|
+
}
|
340
|
+
}
|
341
|
+
}
|
342
|
+
|
343
|
+
_changeSlideFinally(event) {
|
344
|
+
event.stopPropagation();
|
345
|
+
if (event.target.className !== 'tui-image-editor-range') {
|
346
|
+
return;
|
347
|
+
}
|
348
|
+
const touchPx = event.offsetX;
|
349
|
+
const ratio = touchPx / this.rangeWidth;
|
350
|
+
const value = this._absMax * ratio + this._min;
|
351
|
+
this.pointer.style.left = `${ratio * this.rangeWidth}px`;
|
352
|
+
this.subbar.style.right = `${(1 - ratio) * this.rangeWidth}px`;
|
353
|
+
this.value = value;
|
354
|
+
|
355
|
+
this.fire('change', value, true);
|
356
|
+
}
|
357
|
+
|
358
|
+
_startChangingSlide(event) {
|
359
|
+
this.firstPosition = event.screenX;
|
360
|
+
this.firstLeft = toInteger(this.pointer.style.left) || 0;
|
361
|
+
|
362
|
+
document.addEventListener('mousemove', this.eventHandler.changeSlide);
|
363
|
+
document.addEventListener('mouseup', this.eventHandler.stopChangingSlide);
|
364
|
+
}
|
365
|
+
|
366
|
+
/**
|
367
|
+
* stop change angle event
|
368
|
+
* @private
|
369
|
+
*/
|
370
|
+
_stopChangingSlide() {
|
371
|
+
this.fire('change', this._value, true);
|
372
|
+
|
373
|
+
document.removeEventListener('mousemove', this.eventHandler.changeSlide);
|
374
|
+
document.removeEventListener('mouseup', this.eventHandler.stopChangingSlide);
|
375
|
+
}
|
376
|
+
|
377
|
+
/**
|
378
|
+
* Unnecessary string filtering.
|
379
|
+
* @param {string} inputValue - origin string of input
|
380
|
+
* @returns {string} filtered string
|
381
|
+
* @private
|
382
|
+
*/
|
383
|
+
_filterForInputText(inputValue) {
|
384
|
+
return inputValue.replace(INPUT_FILTER_REGEXP, '$1$2$3');
|
385
|
+
}
|
386
|
+
}
|
387
|
+
|
388
|
+
CustomEvents.mixin(Range);
|
389
|
+
|
390
|
+
export default Range;
|