mirror of
https://bitbucket.org/wisemapping/wisemapping-frontend.git
synced 2024-11-26 08:04:56 +01:00
Zoom toolbar reandered during load.
This commit is contained in:
parent
0dcdfc69ff
commit
3d8e8dce38
@ -80,24 +80,22 @@ const Editor = ({
|
|||||||
const locale = options.locale;
|
const locale = options.locale;
|
||||||
const msg = I18nMsg.loadLocaleData(locale);
|
const msg = I18nMsg.loadLocaleData(locale);
|
||||||
|
|
||||||
const menubarConfiguration = buildAppBarConfig(
|
|
||||||
model,
|
|
||||||
options.mapTitle,
|
|
||||||
capability,
|
|
||||||
onAction,
|
|
||||||
accountConfiguration,
|
|
||||||
() => {
|
|
||||||
model.save(true);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
// if the Toolbar is not hidden before the variable 'isMobile' is defined, it appears intermittently when the page loads
|
|
||||||
// if the Toolbar is not rendered, Menu.ts cant find buttons for create event listeners
|
|
||||||
// so, with this hack the Toolbar is rendered but no visible until the variable 'isMobile' is defined
|
|
||||||
return (
|
return (
|
||||||
<ThemeProvider theme={editorTheme}>
|
<ThemeProvider theme={editorTheme}>
|
||||||
<IntlProvider locale={locale} messages={msg}>
|
<IntlProvider locale={locale} messages={msg}>
|
||||||
<AppBar configurations={menubarConfiguration} />
|
<AppBar
|
||||||
|
configurations={buildAppBarConfig(
|
||||||
|
model,
|
||||||
|
options.mapTitle,
|
||||||
|
capability,
|
||||||
|
onAction,
|
||||||
|
accountConfiguration,
|
||||||
|
() => {
|
||||||
|
model.save(true);
|
||||||
|
},
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
|
||||||
<Popover
|
<Popover
|
||||||
id="popover"
|
id="popover"
|
||||||
open={popoverOpen}
|
open={popoverOpen}
|
||||||
@ -117,7 +115,7 @@ const Editor = ({
|
|||||||
></Toolbar>
|
></Toolbar>
|
||||||
)}
|
)}
|
||||||
<Toolbar
|
<Toolbar
|
||||||
configurations={buildZoomToolbarConfig(capability, model?.getDesigner())}
|
configurations={buildZoomToolbarConfig(model, capability)}
|
||||||
position={{
|
position={{
|
||||||
position: {
|
position: {
|
||||||
right: '7px',
|
right: '7px',
|
||||||
|
@ -300,40 +300,45 @@ export function buildToolbarConfig(designer: Designer): ActionConfig[] {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function buildZoomToolbarConfig(capability: Capability, designer: Designer): ActionConfig[] {
|
export function buildZoomToolbarConfig(model: Editor, capability: Capability): ActionConfig[] {
|
||||||
if (!designer) return [];
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
icon: <CenterFocusStrongOutlinedIcon />,
|
icon: <CenterFocusStrongOutlinedIcon />,
|
||||||
tooltip: $msg('CENTER_POSITION'),
|
tooltip: $msg('CENTER_POSITION'),
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
designer.zoomToFit();
|
model.getDesigner().zoomToFit();
|
||||||
},
|
},
|
||||||
|
disabled: () => !model?.isMapLoadded(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// zoom value candidate, neds to fixit
|
// zoom value candidate, neds to fixit
|
||||||
render: () => (
|
render: () => (
|
||||||
<Box sx={{ p: 0.5 }}>
|
<Box sx={{ p: 0.5 }}>
|
||||||
<Typography variant="overline" color="gray">
|
<Typography variant="overline" color="gray">
|
||||||
%{Math.floor((1 / designer.getWorkSpace()?.getZoom()) * 100)}
|
%
|
||||||
|
{!model?.isMapLoadded()
|
||||||
|
? 100
|
||||||
|
: Math.floor((1 / designer.getWorkSpace()?.getZoom()) * 100)}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
),
|
),
|
||||||
|
disabled: () => !model?.isMapLoadded(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon: <ZoomInOutlinedIcon />,
|
icon: <ZoomInOutlinedIcon />,
|
||||||
tooltip: $msg('ZOOM_IN'),
|
tooltip: $msg('ZOOM_IN'),
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
designer.zoomIn();
|
model.getDesigner().zoomIn();
|
||||||
},
|
},
|
||||||
|
disabled: () => !model?.isMapLoadded(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon: <ZoomOutOutlinedIcon />,
|
icon: <ZoomOutOutlinedIcon />,
|
||||||
tooltip: $msg('ZOOM_OUT'),
|
tooltip: $msg('ZOOM_OUT'),
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
designer.zoomOut();
|
model.getDesigner().zoomOut();
|
||||||
},
|
},
|
||||||
|
disabled: () => !model?.isMapLoadded(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon: <KeyboardOutlined />,
|
icon: <KeyboardOutlined />,
|
||||||
|
Loading…
Reference in New Issue
Block a user