File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed
Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import { selectBlockById } from "../store/block/selectors";
1010import { TConnection , TConnectionId } from "../store/connection/ConnectionState" ;
1111import { selectConnectionById } from "../store/connection/selectors" ;
1212import { TGraphSettingsConfig } from "../store/settings" ;
13- import { getElementsRect , startAnimation } from "../utils/functions" ;
13+ import { getBlocksRect , getElementsRect , startAnimation } from "../utils/functions" ;
1414import { TRect } from "../utils/types/shapes" ;
1515
1616export type ZoomConfig = {
@@ -36,10 +36,13 @@ export class PublicGraphApi {
3636 * ```
3737 */
3838 public zoomToBlocks ( blockIds : TBlockId [ ] , zoomConfig ?: ZoomConfig ) {
39- return this . zoomToElements (
40- this . graph . rootStore . blocksList . getBlockStates ( blockIds ) . map ( ( blockState ) => blockState . getViewComponent ( ) ) ,
41- zoomConfig
42- ) ;
39+ const blocks = this . graph . rootStore . blocksList . getBlocks ( blockIds ) ;
40+ if ( blocks . length === 0 ) {
41+ return false ;
42+ }
43+ const blocksRect = getBlocksRect ( blocks ) ;
44+ this . zoomToRect ( blocksRect , zoomConfig ) ;
45+ return true ;
4346 }
4447
4548 /**
Original file line number Diff line number Diff line change @@ -446,6 +446,6 @@ export class BlockListStore {
446446 * @returns {BlockState[] } Block states
447447 */
448448 public getBlockStates ( ids : BlockState [ "id" ] [ ] ) {
449- return ids . map ( ( id ) => this . getBlockState ( id ) ) . filter ( Boolean ) ;
449+ return ids . map ( ( id ) => this . getBlockState ( id ) ) . filter ( ( block ) : block is BlockState => block !== undefined ) ;
450450 }
451451}
You can’t perform that action at this time.
0 commit comments