Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/design ui useable #38

Merged
merged 37 commits into from
Jun 20, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
4d12fd3
feat: ui improvement start
jinwoo-kim-nhn Jun 8, 2018
6bede58
feat: shape, draw menu Improved usability.
jinwoo-kim-nhn Jun 11, 2018
2e070e8
middle commit
jinwoo-kim-nhn Jun 11, 2018
a65c61b
add icon add with resize
Jun 11, 2018
9c9f738
icon useable resize icon
Jun 11, 2018
3cff2e4
complete icon menu useable
jinwoo-kim-nhn Jun 12, 2018
694ba62
middle commit
jinwoo-kim-nhn Jun 12, 2018
322a05b
middle commit2
Jun 12, 2018
d8d25f5
fixed middlecommit 3
Jun 12, 2018
59f5b5d
fixed bug all
Jun 13, 2018
504fe05
refactoring icon action
Jun 13, 2018
80b3045
feat: group selction style & action for ui usable
jinwoo-kim-nhn Jun 14, 2018
9aa3f67
fixed: shape stroke limit maxsize
jinwoo-kim-nhn Jun 14, 2018
959258c
fixed: submenu transition and mask apply hidden
Jun 14, 2018
d46b595
fixed crop zone bug
Jun 14, 2018
58be310
fixed action test
Jun 14, 2018
5cd6b06
added big menu tooltip
jinwoo-kim-nhn Jun 15, 2018
ebc9292
crop zone Flicker removal.
jinwoo-kim-nhn Jun 15, 2018
cf932dd
fixed shape standard mode
jinwoo-kim-nhn Jun 15, 2018
e5792cd
fixed shpae change stanbymode bug and filter partition height
jinwoo-kim-nhn Jun 15, 2018
3a41377
added iconsize theme
jinwoo-kim-nhn Jun 15, 2018
6d0cc9b
add jsdoc
jinwoo-kim-nhn Jun 15, 2018
f7a650d
add jsdoc & editor-wrap style
jinwoo-kim-nhn Jun 15, 2018
0527890
add test code job - 1
jinwoo-kim-nhn Jun 15, 2018
f065c12
feat: design - ui useable - add test all
Jun 17, 2018
8f3ae35
fixed undo stack bug
Jun 17, 2018
866158c
broken test fixed
jinwoo-kim-nhn Jun 18, 2018
ba1e4f4
fixed broken test2
jinwoo-kim-nhn Jun 18, 2018
4ed8c4b
fixed broken test 3
jinwoo-kim-nhn Jun 18, 2018
040766a
fixed broken test - 4
jinwoo-kim-nhn Jun 18, 2018
140530c
apply ui review
Jun 18, 2018
e05f58f
fixed: added file cleanup and theme properties.
jinwoo-kim-nhn Jun 19, 2018
c9e429b
fixed typpo
jinwoo-kim-nhn Jun 19, 2018
5368e6e
apply codereview
jinwoo-kim-nhn Jun 19, 2018
80bad1f
add sample bg file
jinwoo-kim-nhn Jun 19, 2018
9b51ae1
fixed broken test
jinwoo-kim-nhn Jun 19, 2018
60d64da
apply codereview
jinwoo-kim-nhn Jun 20, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixed: shape stroke limit maxsize
  • Loading branch information
jinwoo-kim-nhn committed Jun 14, 2018
commit 9aa3f67cc6d5c608ae8de291b791218af150e65d
72 changes: 41 additions & 31 deletions src/js/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,37 +24,6 @@ export default {
};
},

_commonAction() {
return {
deactivateAll: () => {
this.deactivateAll();
},
changeSelectableAll: selectable => {
this.changeSelectableAll(selectable);
},
discardSelection: () => {
this.discardSelection();
},
modeChange: menu => {
switch (menu) {
case 'text':
this._changeActivateMode('TEXT');
break;
case 'crop':
this.startDrawingMode('CROPPER');
break;
case 'shape':
this._changeActivateMode('SHAPE');
this.setDrawingShape(this.ui.shape.type, this.ui.shape.options);
break;
default:
break;
}
},
stopDrawingMode: this.stopDrawingMode.bind(this)
};
},

/**
* Main Action
* @returns {Object} actions for ui main
Expand Down Expand Up @@ -425,6 +394,8 @@ export default {
strokeWidth: obj.strokeWidth,
fillColor: obj.fill
});

this.ui.shape.setMaxStrokeValue(obj);
} else if (obj.type === 'path' || obj.type === 'line') {
this.stopDrawingMode();
if (this.ui.submenu) {
Expand Down Expand Up @@ -457,9 +428,18 @@ export default {
Promise.reject(message)
));
},
addObjectAfter: obj => {
if (['rect', 'circle', 'triangle'].indexOf(obj.type) > -1) {
this.ui.shape.setMaxStrokeValue(obj);
}
},
objectScaled: obj => {
if (obj.type === 'i-text') {
this.ui.text.fontSize = util.toInteger(obj.fontSize);
} else if (['rect', 'circle', 'triangle'].indexOf(obj.type) >= 0) {
this.ui.shape._els.strokeRange.max = Math.min(obj.width, obj.height) - 1;
this.ui.shape.setMaxStrokeValue(obj);
// here job remaining
}
},
selectionCleared: () => {
Expand All @@ -473,6 +453,36 @@ export default {
});
},

/**
* Common Action
* @returns {Object} common actions for ui
* @private
*/
_commonAction() {
return {
modeChange: menu => {
switch (menu) {
case 'text':
this._changeActivateMode('TEXT');
break;
case 'crop':
this.startDrawingMode('CROPPER');
break;
case 'shape':
this._changeActivateMode('SHAPE');
this.setDrawingShape(this.ui.shape.type, this.ui.shape.options);
break;
default:
break;
}
},
deactivateAll: this.deactivateAll.bind(this),
changeSelectableAll: this.changeSelectableAll.bind(this),
discardSelection: this.discardSelection.bind(this),
stopDrawingMode: this.stopDrawingMode.bind(this)
};
},

/**
* Mixin
* @param {ImageEditor} ImageEditor instance
Expand Down
2 changes: 2 additions & 0 deletions src/js/component/shape.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,8 @@ class Shape extends Component {
resizeHelper.adjustOriginToCenter(shape);
}

this.fire(eventNames.ADD_OBJECT_AFTER, this.graphics.createObjectProperties(shape));

canvas.off({
'mouse:move': this._handlers.mousemove,
'mouse:up': this._handlers.mouseup
Expand Down
4 changes: 3 additions & 1 deletion src/js/consts.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,14 @@ module.exports = {
OBJECT_ACTIVATED: 'objectActivated',
OBJECT_MOVED: 'objectMoved',
OBJECT_SCALED: 'objectScaled',
OBJECT_CREATED: 'objectCreated',
TEXT_EDITING: 'textEditing',
TEXT_CHANGED: 'textChanged',
ICON_CREATE_RESIZE: 'iconCreateResize',
ICON_CREATE_END: 'iconCreateEnd',
ADD_TEXT: 'addText',
ADD_OBJECT: 'addObject',
ADD_OBJECT_AFTER: 'addObjectAfter',
MOUSE_DOWN: 'mousedown',
MOUSE_UP: 'mouseup',
MOUSE_MOVE: 'mousemove',
Expand Down Expand Up @@ -162,7 +164,7 @@ module.exports = {

defaultShapeStrokeValus: {
realTimeEvent: true,
min: 0,
min: 2,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

지난번과 비슷한데 상수 빠져있으면 좋겠습니다.

max: 300,
value: 3
},
Expand Down
8 changes: 7 additions & 1 deletion src/js/imageEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class ImageEditor {
createdPath: this._onCreatedPath,
addText: this._onAddText.bind(this),
addObject: this._onAddObject.bind(this),
addObjectAfter: this._onAddObjectAfter.bind(this),
textEditing: this._onTextEditing.bind(this),
textChanged: this._onTextChanged.bind(this),
iconCreateResize: this._onIconCreateResize.bind(this),
Expand Down Expand Up @@ -234,7 +235,8 @@ class ImageEditor {
'iconCreateResize': this._handlers.iconCreateResize,
'iconCreateEnd': this._handlers.iconCreateEnd,
'selectionCleared': this._handlers.selectionCleared,
'selectionCreated': this._handlers.selectionCreated
'selectionCreated': this._handlers.selectionCreated,
'addObjectAfter': this._handlers.addObjectAfter
});
}

Expand Down Expand Up @@ -1035,6 +1037,10 @@ class ImageEditor {
this._pushAddObjectCommand(obj);
}

_onAddObjectAfter(objectProps) {
this.fire(events.ADD_OBJECT_AFTER, objectProps);
}

_selectionCleared() {
this.fire(events.SELECTION_CLEARED);
}
Expand Down
24 changes: 16 additions & 8 deletions src/js/ui/shape.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ export default class Shape extends Submenu {
addEvent(actions) {
this.actions = actions;

this._els.shapeSelectButton.addEventListener('click', this._changeShape.bind(this));
this._els.strokeRange.on('change', this._changeStrokeRange.bind(this));
this._els.fillColorpicker.on('change', this._changeFillColor.bind(this));
this._els.strokeColorpicker.on('change', this._changeStrokeColor.bind(this));
this._els.shapeSelectButton.addEventListener('click', this._changeShapeHandler.bind(this));
this._els.strokeRange.on('change', this._changeStrokeRangeHandler.bind(this));
this._els.fillColorpicker.on('change', this._changeFillColorHandler.bind(this));
this._els.strokeColorpicker.on('change', this._changeStrokeColorHandler.bind(this));
this._els.strokeRangeValue.value = this._els.strokeRange.value;
this._els.strokeRangeValue.setAttribute('readonly', true);
}
Expand Down Expand Up @@ -84,12 +84,20 @@ export default class Shape extends Submenu {
this.actions.stopDrawingMode();
}

setMaxStrokeValue(obj) {
let strokeMaxValue = Math.min(obj.width, obj.height);
if (strokeMaxValue <= 0) {
strokeMaxValue = defaultShapeStrokeValus.max;
}
this._els.strokeRange.max = strokeMaxValue;
}

/**
* Change icon color
* @param {object} event - add button event object
* @private
*/
_changeShape(event) {
_changeShapeHandler(event) {
const button = event.target.closest('.tui-image-editor-button');
if (button) {
this.actions.stopDrawingMode();
Expand All @@ -115,7 +123,7 @@ export default class Shape extends Submenu {
* @param {number} value - stroke range value
* @private
*/
_changeStrokeRange(value) {
_changeStrokeRangeHandler(value) {
this.options.strokeWidth = toInteger(value);
this._els.strokeRangeValue.value = toInteger(value);

Expand All @@ -131,7 +139,7 @@ export default class Shape extends Submenu {
* @param {string} color - fill color
* @private
*/
_changeFillColor(color) {
_changeFillColorHandler(color) {
color = color || 'transparent';
this.options.fill = color;
this.actions.changeShape({
Expand All @@ -144,7 +152,7 @@ export default class Shape extends Submenu {
* @param {string} color - fill color
* @private
*/
_changeStrokeColor(color) {
_changeStrokeColorHandler(color) {
color = color || 'transparent';
this.options.stroke = color;
this.actions.changeShape({
Expand Down
24 changes: 17 additions & 7 deletions src/js/ui/tools/range.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ class Range {
this._drawRangeElement();

this.rangeWidth = toInteger(window.getComputedStyle(rangeElement, null).width) - 12;
this.min = options.min || 0;
this.max = options.max || 100;
this.absMax = (this.min * -1) + this.max;
this._min = options.min || 0;
this._max = options.max || 100;
this._absMax = (this._min * -1) + this._max;
this.realTimeEvent = options.realTimeEvent || false;

this._addClickEvent();
Expand All @@ -23,6 +23,16 @@ class Range {
this.trigger('change');
}

/**
* Set range max value and re position cursor
* @param {number} maxValue - max value
*/
set max(maxValue) {
this._max = maxValue;
this._absMax = (this._min * -1) + this._max;
this.value = this._value;
}

/**
* Get range value
* @returns {Number} range value
Expand All @@ -37,8 +47,8 @@ class Range {
* @param {Boolean} fire whether fire custom event or not
*/
set value(value) {
const absValue = value - this.min;
let leftPosition = (absValue * this.rangeWidth) / this.absMax;
const absValue = value - this._min;
let leftPosition = (absValue * this.rangeWidth) / this._absMax;

if (this.rangeWidth < leftPosition) {
leftPosition = this.rangeWidth;
Expand Down Expand Up @@ -90,7 +100,7 @@ class Range {
}
const touchPx = event.offsetX;
const ratio = touchPx / this.rangeWidth;
const value = (this.absMax * ratio) + this.min;
const value = (this._absMax * ratio) + this._min;
this.pointer.style.left = `${ratio * this.rangeWidth}px`;
this.subbar.style.right = `${(1 - ratio) * this.rangeWidth}px`;
this._value = value;
Expand Down Expand Up @@ -132,7 +142,7 @@ class Range {
this.pointer.style.left = `${touchPx}px`;
this.subbar.style.right = `${this.rangeWidth - touchPx}px`;
const ratio = touchPx / this.rangeWidth;
const value = (this.absMax * ratio) + this.min;
const value = (this._absMax * ratio) + this._min;

this._value = value;

Expand Down