-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
fix: add custom icon error #65
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,47 +61,55 @@ class Icon extends Component { | |
const canvas = this.getCanvas(); | ||
const path = this._pathMap[type]; | ||
const selectionStyle = consts.fObjectOptions.SELECTION_STYLE; | ||
const isDefaultIconPath = Object.keys(consts.defaultIconPath).indexOf(type) >= 0; | ||
const useDragAddIcon = this.useDragAddIcon && isDefaultIconPath; | ||
const icon = path ? this._createIcon(path) : null; | ||
|
||
if (!path) { | ||
if (!icon) { | ||
reject(rejectMessages.invalidParameters); | ||
} | ||
|
||
const icon = this._createIcon(path); | ||
|
||
icon.set(snippet.extend({ | ||
type: 'icon', | ||
fill: this._oColor | ||
}, selectionStyle, options, this.graphics.controlStyle)); | ||
|
||
if (this.useDragAddIcon) { | ||
canvas.add(icon).setActiveObject(icon); | ||
canvas.on({ | ||
'mouse:move': fEvent => { | ||
canvas.selection = false; | ||
|
||
this.fire(events.ICON_CREATE_RESIZE, { | ||
moveOriginPointer: canvas.getPointer(fEvent.e) | ||
}); | ||
}, | ||
'mouse:up': fEvent => { | ||
this.fire(events.ICON_CREATE_END, { | ||
moveOriginPointer: canvas.getPointer(fEvent.e) | ||
}); | ||
|
||
canvas.defaultCursor = 'default'; | ||
canvas.off('mouse:up'); | ||
canvas.off('mouse:move'); | ||
canvas.selection = true; | ||
} | ||
}); | ||
} else { | ||
canvas.add(icon).setActiveObject(icon); | ||
canvas.add(icon).setActiveObject(icon); | ||
|
||
if (useDragAddIcon) { | ||
this._addWithDrag(canvas); | ||
} | ||
|
||
resolve(this.graphics.createObjectProperties(icon)); | ||
}); | ||
} | ||
|
||
/** | ||
* Added icon drag | ||
* @param {fabric.Canvas} canvas - Canvas instance | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 넵 ! |
||
*/ | ||
_addWithDrag(canvas) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 메서드에서 하는 일은 이벤트를 등록하는 일뿐이네요. 메서드명에 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 넵! |
||
canvas.on({ | ||
'mouse:move': fEvent => { | ||
canvas.selection = false; | ||
|
||
this.fire(events.ICON_CREATE_RESIZE, { | ||
moveOriginPointer: canvas.getPointer(fEvent.e) | ||
}); | ||
}, | ||
'mouse:up': fEvent => { | ||
this.fire(events.ICON_CREATE_END, { | ||
moveOriginPointer: canvas.getPointer(fEvent.e) | ||
}); | ||
|
||
canvas.defaultCursor = 'default'; | ||
canvas.off('mouse:up'); | ||
canvas.off('mouse:move'); | ||
canvas.selection = true; | ||
} | ||
}); | ||
} | ||
|
||
/** | ||
* Register icon paths | ||
* @param {{key: string, value: string}} pathInfos - Path infos | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
그냥
registerdIcon
은 어떨까요? 커스텀은 유저가 등록하는 아이콘이고 그 외에 것은 이미 등록되어 있으니까요~There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵 좋은것 같습니다.