From d6d3dc0da329ae9740027bdb782f549c7b74970f Mon Sep 17 00:00:00 2001 From: redhoodsu Date: Tue, 6 Feb 2024 17:53:00 +0800 Subject: [PATCH] chore: small changes --- src/painter/tools/Hand.ts | 10 ++++++++++ src/painter/tools/Zoom.ts | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/src/painter/tools/Hand.ts b/src/painter/tools/Hand.ts index 4e2a81b..c83c9c4 100644 --- a/src/painter/tools/Hand.ts +++ b/src/painter/tools/Hand.ts @@ -1,4 +1,5 @@ import Tool from './Tool' +import Zoom from './Zoom' import { eventClient } from '../../share/util' export default class Hand extends Tool { @@ -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') + } } diff --git a/src/painter/tools/Zoom.ts b/src/painter/tools/Zoom.ts index 6025c1d..ef9cb73 100644 --- a/src/painter/tools/Zoom.ts +++ b/src/painter/tools/Zoom.ts @@ -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)