Skip to content

Commit

Permalink
chore: normalize event name
Browse files Browse the repository at this point in the history
  • Loading branch information
surunzi committed Dec 31, 2024
1 parent e186ac0 commit c434e39
Show file tree
Hide file tree
Showing 27 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/box-model/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default class BoxModel extends Component<IOptions> {
this.bindEvent()
}
private bindEvent() {
this.on('optionChange', (name) => {
this.on('changeOption', (name) => {
switch (name) {
case 'element':
this.render()
Expand Down
2 changes: 1 addition & 1 deletion src/color-picker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default class ColorPicker extends Component<IOptions> {
this.$saturation.on(pointerEvent('down'), this.onSaturationStart)

const updateColor = throttle(this.updateColor, 50)
this.on('optionChange', (name, val) => {
this.on('changeOption', (name, val) => {
switch (name) {
case 'color':
this.color = new Color(val)
Expand Down
2 changes: 1 addition & 1 deletion src/console/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ export default class Console extends Component<IOptions> {
self.selectLog(this.log)
})

this.on('optionChange', (name, val) => {
this.on('changeOption', (name, val) => {
const { logs } = this
switch (name) {
case 'maxNum':
Expand Down
2 changes: 1 addition & 1 deletion src/cropper/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export default class Cropper extends Component<IOptions> {
this.resizeSensor.addListener(this.onResize)
this.$container.on(pointerEvent('down'), this.onCropStart)

this.on('optionChange', (name, val) => {
this.on('changeOption', (name, val) => {
switch (name) {
case 'preview':
if (val) {
Expand Down
2 changes: 1 addition & 1 deletion src/data-grid/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ export default class DataGrid extends Component<IOptions> {
self.onResizeColStart(e)
})

this.on('optionChange', (name) => {
this.on('changeOption', (name) => {
switch (name) {
case 'minHeight':
case 'maxHeight':
Expand Down
2 changes: 1 addition & 1 deletion src/dom-highlighter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ export default class DomHighlighter extends Component<IOptions> {
window.addEventListener('resize', this.redraw)
window.addEventListener('scroll', this.redraw)

this.on('optionChange', () => this.redraw())
this.on('changeOption', () => this.redraw())
}
private reset = () => {
const viewportWidth = document.documentElement.clientWidth
Expand Down
2 changes: 1 addition & 1 deletion src/image-viewer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ export default class ImageViewer extends Component<IOptions> {
.on(pointerEvent('down'), this.onMoveStart)
.on('wheel', this.onWheel)

this.on('optionChange', (name, val) => {
this.on('changeOption', (name, val) => {
switch (name) {
case 'image':
this.setImage(val)
Expand Down
2 changes: 1 addition & 1 deletion src/log/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default class Log extends Component<IOptions> {
this.textViewer.append(ansiToHtml(log))
}
private bindEvent() {
this.on('optionChange', (name, val) => {
this.on('changeOption', (name, val) => {
switch (name) {
case 'log':
this.textViewer.setOption('text', ansiToHtml(val))
Expand Down
2 changes: 1 addition & 1 deletion src/logcat/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ export default class Logcat extends Component<IOptions> {
private bindEvent() {
const { c } = this

this.on('optionChange', (name, val) => {
this.on('changeOption', (name, val) => {
const { entries } = this

switch (name) {
Expand Down
2 changes: 1 addition & 1 deletion src/markdown-viewer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export default class MarkdownViewer extends Component<IOptions> {
private bindEvent() {
const { gallery } = this

this.on('optionChange', (name) => {
this.on('changeOption', (name) => {
switch (name) {
case 'markdown':
this.render()
Expand Down
8 changes: 4 additions & 4 deletions src/mask-editor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,14 @@ export default class MaskEditor extends Component<IOptions> {
const { painter, maskBrush } = this

painter.on(
'canvasRender',
'renderCanvas',
debounce(() => {
this.renderMask()
this.emit('change', this.canvas)
}, 20)
)

painter.on('foregroundColorChange', (color: string) => {
painter.on('changeForegroundColor', (color: string) => {
const c = new Color(color)
const rgb = Color.parse(c.toRgb()).val

Expand All @@ -169,14 +169,14 @@ export default class MaskEditor extends Component<IOptions> {
painter.renderCanvas()
})

maskBrush.on('optionChange', (name, val) => {
maskBrush.on('changeOption', (name, val) => {
if (name === 'layerOpacity') {
this.drawingLayer.opacity = val
painter.renderCanvas()
}
})

this.on('optionChange', (name) => {
this.on('changeOption', (name) => {
switch (name) {
case 'image':
this.loadImage()
Expand Down
2 changes: 1 addition & 1 deletion src/modal/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ export default class Modal extends Component<IOptions> {
}
private bindEvent() {
this.$body.on('click', this.c('.icon-close'), () => this.hide())
this.on('optionChange', this.render)
this.on('changeOption', this.render)
}
private render = () => {
const { options, c, $body } = this
Expand Down
2 changes: 1 addition & 1 deletion src/object-viewer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ export default class ObjectViewer extends Component<IOptions> {
private bindEvent() {
this.$container.on('click', 'li', this.onItemClick)

this.on('optionChange', (name, val) => {
this.on('changeOption', (name, val) => {
switch (name) {
case 'object':
this.set(val)
Expand Down
8 changes: 4 additions & 4 deletions src/painter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ export default class Painter extends Component<IOptions> {
}
setForegroundColor(color: string) {
this.$foregroundColor.val(color)
this.emit('foregroundColorChange', color)
this.emit('changeForegroundColor', color)
}
getBackgroundColor() {
return this.$backgroundColor.val()
Expand Down Expand Up @@ -231,7 +231,7 @@ export default class Painter extends Component<IOptions> {
ctx.globalCompositeOperation = 'source-over'
})

this.emit('canvasRender')
this.emit('renderCanvas')
}
private resizeCanvas(width: number, height: number) {
const { canvas } = this
Expand Down Expand Up @@ -320,7 +320,7 @@ export default class Painter extends Component<IOptions> {
})

$foregroundColor.on('change', () => {
this.emit('foregroundColorChange', $foregroundColor.val())
this.emit('changeForegroundColor', $foregroundColor.val())
})

this.resizeSensor.addListener(this.onResize)
Expand All @@ -333,7 +333,7 @@ export default class Painter extends Component<IOptions> {
this.resetViewport()
})

this.on('optionChange', (name, val) => {
this.on('changeOption', (name, val) => {
const { canvas } = this
switch (name) {
case 'width':
Expand Down
2 changes: 1 addition & 1 deletion src/painter/tools/Brush.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export default class Brush extends Tool {
private bindEvent() {
const { cursorCircle, painter } = this

this.on('optionChange', (name, val) => {
this.on('changeOption', (name, val) => {
if (name === 'size') {
cursorCircle.setSize(val)
}
Expand Down
2 changes: 1 addition & 1 deletion src/painter/tools/Eraser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default class Eraser extends Tool {
private bindEvent() {
const { cursorCircle, painter } = this

this.on('optionChange', (name, val) => {
this.on('changeOption', (name, val) => {
if (name === 'size') {
cursorCircle.setSize(val)
}
Expand Down
2 changes: 1 addition & 1 deletion src/painter/tools/Pencil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export default class Pencil extends Tool {
private bindEvent() {
const { cursorCircle } = this

this.on('optionChange', (name, val) => {
this.on('changeOption', (name, val) => {
if (name === 'size') {
cursorCircle.setSize(val)
}
Expand Down
2 changes: 1 addition & 1 deletion src/painter/tools/Tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default class Tool extends Emitter {
setOption(name: string, val: any, renderToolbar = true) {
const oldVal = this.options[name]
this.options[name] = val
this.emit('optionChange', name, val, oldVal)
this.emit('changeOption', name, val, oldVal)

if (renderToolbar) {
this.renderToolbar()
Expand Down
2 changes: 1 addition & 1 deletion src/painter/tools/Zoom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export default class Zoom extends Tool {
}
})

this.on('optionChange', (name, val) => {
this.on('changeOption', (name, val) => {
if (name === 'mode') {
const { c } = this.painter
const $icon = this.$cursorIcon
Expand Down
2 changes: 1 addition & 1 deletion src/performance-monitor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export default class PerformanceMonitor extends Component<IOptions> {
this.resizeSensor.addListener(this.onResize)
dpr.on('change', this.onResize)

this.on('optionChange', (name) => {
this.on('changeOption', (name) => {
if (name === 'color') {
this.updateColor()
} else if (name === 'title') {
Expand Down
2 changes: 1 addition & 1 deletion src/setting/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ export default class Setting extends Component<IOptions> {
private bindEvent() {
const { c } = this

this.on('optionChange', (name) => {
this.on('changeOption', (name) => {
switch (name) {
case 'filter':
this.renderSettings()
Expand Down
2 changes: 1 addition & 1 deletion src/shader-toy-player/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export default class ShaderToyPlayer extends Component<IOptions> {

this.$canvas.on(pointerEvent('down'), this.onDragStart)

this.on('optionChange', (name, val) => {
this.on('changeOption', (name, val) => {
if (name === 'renderPass') {
this.load(val)
}
Expand Down
4 changes: 2 additions & 2 deletions src/share/Component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default class Component<
this.c(`platform-${getPlatform()}`),
])

this.on('optionChange', (name, val) => {
this.on('changeOption', (name, val) => {
if (name === 'theme' && val) {
let t = val
if (val === 'auto') {
Expand Down Expand Up @@ -88,7 +88,7 @@ export default class Component<
if (val === oldVal) {
return
}
this.emit('optionChange', name, val, oldVal)
this.emit('changeOption', name, val, oldVal)
})
}
getOption(name: string) {
Expand Down
2 changes: 1 addition & 1 deletion src/syntax-highlighter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export default class SyntaxHighlighter extends Component {
this.bindEvent()
}
private bindEvent() {
this.on('optionChange', (name, val) => {
this.on('changeOption', (name, val) => {
switch (name) {
case 'code':
val = this.getHighlightCode(val)
Expand Down
2 changes: 1 addition & 1 deletion src/tab/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export default class Tab extends Component<IOptions> {
private bindEvent() {
const { tabs, c } = this

this.on('optionChange', (name) => {
this.on('changeOption', (name) => {
switch (name) {
case 'height':
this.updateHeight()
Expand Down
2 changes: 1 addition & 1 deletion src/text-viewer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export default class TextViewer extends Component {
)
}
private bindEvent() {
this.on('optionChange', (name) => {
this.on('changeOption', (name) => {
switch (name) {
case 'maxHeight':
this.updateHeight()
Expand Down
2 changes: 1 addition & 1 deletion src/window/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ export default class Window extends Component<IOptions> {
private bindEvent() {
const { c } = this

this.on('optionChange', (name: string) => {
this.on('changeOption', (name: string) => {
switch (name) {
case 'content':
this.renderContent()
Expand Down

0 comments on commit c434e39

Please sign in to comment.