1
1
import { Vector } from '../core' ;
2
2
import { ViewportController } from '../designer-extension' ;
3
+ import { DesignerState } from '../designer-state' ;
3
4
import { ViewportAnimator } from '../workspace/viewport/viewport-animator' ;
4
5
import { ZoomByWheelCalculator } from '../workspace/viewport/zoom-by-wheel-calculator' ;
5
6
import { WorkspaceControllerWrapper } from '../workspace/workspace-controller' ;
6
- import { WorkspaceApi } from './workspace-api' ;
7
7
8
8
export class ViewportApi {
9
- private readonly animator = new ViewportAnimator ( this . api ) ;
9
+ private readonly animator = new ViewportAnimator ( this . state ) ;
10
10
11
11
public constructor (
12
+ private readonly state : DesignerState ,
12
13
private readonly workspaceController : WorkspaceControllerWrapper ,
13
- private readonly viewportController : ViewportController ,
14
- private readonly api : WorkspaceApi
14
+ private readonly viewportController : ViewportController
15
15
) { }
16
16
17
17
public limitScale ( scale : number ) : number {
@@ -20,13 +20,13 @@ export class ViewportApi {
20
20
21
21
public resetViewport ( ) {
22
22
const defaultViewport = this . viewportController . getDefault ( ) ;
23
- this . api . setViewport ( defaultViewport ) ;
23
+ this . state . setViewport ( defaultViewport ) ;
24
24
}
25
25
26
26
public zoom ( direction : boolean ) {
27
27
const viewport = this . viewportController . getZoomed ( direction ) ;
28
28
if ( viewport ) {
29
- this . api . setViewport ( viewport ) ;
29
+ this . state . setViewport ( viewport ) ;
30
30
}
31
31
}
32
32
@@ -43,12 +43,11 @@ export class ViewportApi {
43
43
}
44
44
45
45
public handleWheelEvent ( e : WheelEvent ) {
46
- const viewport = this . api . getViewport ( ) ;
47
- const canvasPosition = this . api . getCanvasPosition ( ) ;
46
+ const canvasPosition = this . workspaceController . getCanvasPosition ( ) ;
48
47
49
- const newViewport = ZoomByWheelCalculator . calculate ( this . viewportController , viewport , canvasPosition , e ) ;
48
+ const newViewport = ZoomByWheelCalculator . calculate ( this . viewportController , this . state . viewport , canvasPosition , e ) ;
50
49
if ( newViewport ) {
51
- this . api . setViewport ( newViewport ) ;
50
+ this . state . setViewport ( newViewport ) ;
52
51
}
53
52
}
54
53
}
0 commit comments