Skip to content

Commit

Permalink
chore: small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
surunzi committed Feb 6, 2024
1 parent 3e3b008 commit d6d3dc0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/painter/tools/Hand.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Tool from './Tool'
import Zoom from './Zoom'
import { eventClient } from '../../share/util'

export default class Hand extends Tool {
Expand Down Expand Up @@ -27,4 +28,13 @@ export default class Hand extends Tool {
viewport.scrollLeft = (viewport.scrollWidth - viewport.clientWidth) / 2
viewport.scrollTop = (viewport.scrollHeight - viewport.clientHeight) / 2
}
protected renderToolbar() {
super.renderToolbar()

const { toolbar } = this
toolbar.appendButton('100%', () => {
const zoom = this.painter.getTool('zoom') as Zoom
zoom.zoomTo(1)
}, 'hover')
}
}
8 changes: 8 additions & 0 deletions src/painter/tools/Zoom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ export default class Zoom extends Tool {
},
options.zoomIn ? '' : 'active'
)
toolbar.appendSeparator()
toolbar.appendButton(
'100%',
() => {
this.zoomTo(1)
},
'hover'
)
}
private bindEvent() {
this.$viewport.on('wheel', this.onWheel)
Expand Down

0 comments on commit d6d3dc0

Please sign in to comment.