Fix stuck svg pan zoom + improve minimap
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
d5f89523db
commit
bc6d44db6a
2 changed files with 16 additions and 29 deletions
|
@ -5,12 +5,13 @@ import { ContainerModel } from './Elements/ContainerModel';
|
||||||
import { Selector } from './Elements/Selector';
|
import { Selector } from './Elements/Selector';
|
||||||
|
|
||||||
interface ISVGProps {
|
interface ISVGProps {
|
||||||
|
width: number,
|
||||||
|
height: number,
|
||||||
children: ContainerModel | ContainerModel[] | null,
|
children: ContainerModel | ContainerModel[] | null,
|
||||||
selected: ContainerModel | null
|
selected: ContainerModel | null
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ISVGState {
|
interface ISVGState {
|
||||||
viewBox: number[],
|
|
||||||
value: Value,
|
value: Value,
|
||||||
tool: Tool
|
tool: Tool
|
||||||
}
|
}
|
||||||
|
@ -22,12 +23,6 @@ export class SVG extends React.Component<ISVGProps> {
|
||||||
constructor(props: ISVGProps) {
|
constructor(props: ISVGProps) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
viewBox: [
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
window.innerWidth,
|
|
||||||
window.innerHeight
|
|
||||||
],
|
|
||||||
value: {
|
value: {
|
||||||
viewerWidth: window.innerWidth,
|
viewerWidth: window.innerWidth,
|
||||||
viewerHeight: window.innerHeight
|
viewerHeight: window.innerHeight
|
||||||
|
@ -37,30 +32,12 @@ export class SVG extends React.Component<ISVGProps> {
|
||||||
this.svg = React.createRef<SVGSVGElement>();
|
this.svg = React.createRef<SVGSVGElement>();
|
||||||
}
|
}
|
||||||
|
|
||||||
resizeViewBox() {
|
|
||||||
this.setState({
|
|
||||||
viewBox: [
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
window.innerWidth,
|
|
||||||
window.innerHeight
|
|
||||||
]
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
window.addEventListener('resize', this.resizeViewBox.bind(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
componentWillUnmount() {
|
|
||||||
window.removeEventListener('resize', this.resizeViewBox.bind(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const xmlns = '<http://www.w3.org/2000/svg>';
|
const xmlns = '<http://www.w3.org/2000/svg>';
|
||||||
|
|
||||||
const properties = {
|
const properties = {
|
||||||
viewBox: this.state.viewBox.join(' '),
|
width: this.props.width,
|
||||||
|
height: this.props.height,
|
||||||
xmlns
|
xmlns
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -79,6 +56,12 @@ export class SVG extends React.Component<ISVGProps> {
|
||||||
defaultTool='pan'
|
defaultTool='pan'
|
||||||
value={this.state.value} onChangeValue={value => this.setState({ value })}
|
value={this.state.value} onChangeValue={value => this.setState({ value })}
|
||||||
tool={this.state.tool} onChangeTool={tool => this.setState({ tool })}
|
tool={this.state.tool} onChangeTool={tool => this.setState({ tool })}
|
||||||
|
miniatureProps={{
|
||||||
|
position: 'left',
|
||||||
|
background: '#616264',
|
||||||
|
width: window.innerWidth - 12,
|
||||||
|
height: 120
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<svg ref={this.svg} {...properties}>
|
<svg ref={this.svg} {...properties}>
|
||||||
{ children }
|
{ children }
|
||||||
|
|
|
@ -327,11 +327,15 @@ class Editor extends React.Component<IEditorProps> {
|
||||||
☰ History
|
☰ History
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<SVG selected={current.SelectedContainer}>
|
<SVG
|
||||||
|
width={Number(current.MainContainer?.properties.width)}
|
||||||
|
height={Number(current.MainContainer?.properties.height)}
|
||||||
|
selected={current.SelectedContainer}
|
||||||
|
>
|
||||||
{ current.MainContainer }
|
{ current.MainContainer }
|
||||||
</SVG>
|
</SVG>
|
||||||
<button
|
<button
|
||||||
className={`fixed transition-all ${buttonRightOffsetClasses} bottom-10 w-14 h-14 p-2 align-middle items-center justify-center rounded-full bg-blue-500 hover:bg-blue-800`}
|
className={`fixed transition-all ${buttonRightOffsetClasses} bottom-40 w-14 h-14 p-2 align-middle items-center justify-center rounded-full bg-blue-500 hover:bg-blue-800`}
|
||||||
title='Export as JSON'
|
title='Export as JSON'
|
||||||
onClick={() => this.SaveEditor()}
|
onClick={() => this.SaveEditor()}
|
||||||
>
|
>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue