@knotx/plugins-canvas 0.4.3 → 0.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -245,6 +245,47 @@ class Canvas extends (_a = core.BasePlugin, _transform_dec = [decorators.registe
245
245
  __publicField(this, "removeListener", __runInitializers(_init, 44, this, (type, listener) => {
246
246
  this.listeners[type].delete(listener);
247
247
  })), __runInitializers(_init, 47, this);
248
+ __publicField(this, "onClick", (e) => {
249
+ if (!this.isCanvasEvent(e)) {
250
+ return;
251
+ }
252
+ if (!this.interaction.canInteract(core.InteractionPriority.CanvasClick)) {
253
+ return;
254
+ }
255
+ this.listeners.click.forEach((listener) => {
256
+ listener(e);
257
+ });
258
+ });
259
+ __publicField(this, "onContextMenu", (e) => {
260
+ if (!this.isCanvasEvent(e)) {
261
+ return;
262
+ }
263
+ if (!this.interaction.canInteract(core.InteractionPriority.CanvasContextMenu)) {
264
+ return;
265
+ }
266
+ this.listeners.contextmenu.forEach((listener) => {
267
+ listener(e);
268
+ });
269
+ });
270
+ __publicField(this, "onMouseMove", (e) => {
271
+ if (this.edgeScroll.config.enabled) {
272
+ const rect = e.currentTarget.getBoundingClientRect();
273
+ this.mousePosition = {
274
+ x: e.clientX - rect.left,
275
+ y: e.clientY - rect.top
276
+ };
277
+ if (this.edgeScrollAnimationFrame === null) {
278
+ this.edgeScrollAnimationFrame = requestAnimationFrame(this.handleEdgeScroll);
279
+ }
280
+ }
281
+ });
282
+ __publicField(this, "onMouseLeave", () => {
283
+ this.mousePosition = null;
284
+ if (this.edgeScrollAnimationFrame !== null) {
285
+ cancelAnimationFrame(this.edgeScrollAnimationFrame);
286
+ this.edgeScrollAnimationFrame = null;
287
+ }
288
+ });
248
289
  __publicField(this, "handleEdgeScroll", () => {
249
290
  if (!this.edgeScroll.config.enabled || !this.mousePosition || !this.ref) {
250
291
  return;
@@ -323,30 +364,7 @@ class Canvas extends (_a = core.BasePlugin, _transform_dec = [decorators.registe
323
364
  }
324
365
  render({ children } = { children: null }) {
325
366
  var _a2, _b, _c, _d;
326
- const defaultTransform = react.useMemo(() => {
327
- const defaultLocated = __spreadValues({}, this.config.defaultLocated);
328
- if (!(defaultLocated == null ? void 0 : defaultLocated.nodeId)) {
329
- return this.transform;
330
- }
331
- const node = this.getNode({ id: defaultLocated.nodeId });
332
- defaultLocated.inline || (defaultLocated.inline = "center");
333
- defaultLocated.block || (defaultLocated.block = "center");
334
- defaultLocated.scale || (defaultLocated.scale = this.transform.scale);
335
- const { positionX, positionY, scale: newScale } = calculateTransform(__spreadValues({
336
- node,
337
- container: this.container,
338
- transform: this.transform,
339
- contentSize: this.contentSize
340
- }, defaultLocated));
341
- const newTransform = {
342
- previousScale: this.transform.scale,
343
- scale: newScale,
344
- positionX: -positionX,
345
- positionY: -positionY
346
- };
347
- this.transform = newTransform;
348
- return newTransform;
349
- }, []);
367
+ const defaultTransform = react.useMemo(() => this.getDefaultTransform(), []);
350
368
  const [transformRef, setTransformRef] = react.useReducer((_, ref) => {
351
369
  var _a3;
352
370
  const dom = ref.instance.wrapperComponent;
@@ -358,21 +376,7 @@ class Canvas extends (_a = core.BasePlugin, _transform_dec = [decorators.registe
358
376
  }
359
377
  return ref;
360
378
  }, null);
361
- const [fixedLayers, childrenLayers] = react.useMemo(() => {
362
- const fixedLayers2 = [];
363
- const childrenLayers2 = [];
364
- for (const child of Array.isArray(children) ? children : [children]) {
365
- if (!(child == null ? void 0 : child.key)) {
366
- continue;
367
- }
368
- if (child.key <= core.Layer.Background << 1 || child.key > core.Layer.Foreground >> 1) {
369
- fixedLayers2.push(child);
370
- } else {
371
- childrenLayers2.push(child);
372
- }
373
- }
374
- return [fixedLayers2, childrenLayers2];
375
- }, [children]);
379
+ const [fixedLayers, childrenLayers] = react.useMemo(() => this.groupLayers(children), [children]);
376
380
  react.useLayoutEffect(() => {
377
381
  const wrapperElement = transformRef == null ? void 0 : transformRef.instance.wrapperComponent;
378
382
  const onScroll = (event) => {
@@ -413,47 +417,6 @@ class Canvas extends (_a = core.BasePlugin, _transform_dec = [decorators.registe
413
417
  wrapperElement == null ? void 0 : wrapperElement.removeEventListener("scroll", onScroll, { capture: true });
414
418
  };
415
419
  }, [transformRef]);
416
- const onClick = react.useCallback((e) => {
417
- if (!this.isCanvasEvent(e)) {
418
- return;
419
- }
420
- if (!this.interaction.canInteract(core.InteractionPriority.CanvasClick)) {
421
- return;
422
- }
423
- this.listeners.click.forEach((listener) => {
424
- listener(e);
425
- });
426
- }, []);
427
- const onContextMenu = react.useCallback((e) => {
428
- if (!this.isCanvasEvent(e)) {
429
- return;
430
- }
431
- if (!this.interaction.canInteract(core.InteractionPriority.CanvasContextMenu)) {
432
- return;
433
- }
434
- this.listeners.contextmenu.forEach((listener) => {
435
- listener(e);
436
- });
437
- }, []);
438
- const onMouseMove = react.useCallback((e) => {
439
- if (this.edgeScroll.config.enabled) {
440
- const rect = e.currentTarget.getBoundingClientRect();
441
- this.mousePosition = {
442
- x: e.clientX - rect.left,
443
- y: e.clientY - rect.top
444
- };
445
- if (this.edgeScrollAnimationFrame === null) {
446
- this.edgeScrollAnimationFrame = requestAnimationFrame(this.handleEdgeScroll);
447
- }
448
- }
449
- }, []);
450
- const onMouseLeave = react.useCallback(() => {
451
- this.mousePosition = null;
452
- if (this.edgeScrollAnimationFrame !== null) {
453
- cancelAnimationFrame(this.edgeScrollAnimationFrame);
454
- this.edgeScrollAnimationFrame = null;
455
- }
456
- }, []);
457
420
  return /* @__PURE__ */ jsxRuntime.jsxs(
458
421
  reactZoomPanPinch.TransformWrapper,
459
422
  __spreadProps(__spreadValues({}, this.config), {
@@ -470,14 +433,15 @@ class Canvas extends (_a = core.BasePlugin, _transform_dec = [decorators.registe
470
433
  wrapperStyle: {
471
434
  width: "100%",
472
435
  height: "100%",
473
- zIndex: core.Layer.Nodes | core.Layer.Edges,
436
+ zIndex: core.Layer.Nodes,
474
437
  contain: "strict"
475
438
  },
476
439
  wrapperProps: {
477
- onClick,
478
- onContextMenu,
479
- onMouseMove,
480
- onMouseLeave
440
+ id: this.pluginId,
441
+ onClick: this.onClick,
442
+ onContextMenu: this.onContextMenu,
443
+ onMouseMove: this.onMouseMove,
444
+ onMouseLeave: this.onMouseLeave
481
445
  },
482
446
  contentClass: core.bem(this.name, "content"),
483
447
  contentStyle: {
@@ -514,6 +478,45 @@ class Canvas extends (_a = core.BasePlugin, _transform_dec = [decorators.registe
514
478
  this.rootElement = null;
515
479
  });
516
480
  }
481
+ groupLayers(children) {
482
+ const fixedLayers = [];
483
+ const childrenLayers = [];
484
+ for (const child of Array.isArray(children) ? children : [children]) {
485
+ if (!(child == null ? void 0 : child.key)) {
486
+ continue;
487
+ }
488
+ if (child.key <= core.Layer.Background << 1 || child.key > core.Layer.Foreground >> 1) {
489
+ fixedLayers.push(child);
490
+ } else {
491
+ childrenLayers.push(child);
492
+ }
493
+ }
494
+ return [fixedLayers, childrenLayers];
495
+ }
496
+ getDefaultTransform() {
497
+ const defaultLocated = __spreadValues({}, this.config.defaultLocated);
498
+ if (!(defaultLocated == null ? void 0 : defaultLocated.nodeId) && !defaultLocated.limitToBounds) {
499
+ return this.transform;
500
+ }
501
+ const node = defaultLocated.nodeId ? this.getNode({ id: defaultLocated.nodeId }) : void 0;
502
+ defaultLocated.inline || (defaultLocated.inline = "center");
503
+ defaultLocated.block || (defaultLocated.block = "center");
504
+ defaultLocated.scale || (defaultLocated.scale = this.transform.scale);
505
+ const { positionX, positionY, scale: newScale } = calculateTransform(__spreadValues({
506
+ node,
507
+ container: this.container,
508
+ transform: this.transform,
509
+ contentSize: this.contentSize
510
+ }, defaultLocated));
511
+ const newTransform = {
512
+ previousScale: this.transform.scale,
513
+ scale: newScale,
514
+ positionX: -positionX,
515
+ positionY: -positionY
516
+ };
517
+ this.transform = newTransform;
518
+ return newTransform;
519
+ }
517
520
  isCanvasEvent(e) {
518
521
  return e.target === e.currentTarget || e.target.classList.contains(core.bem(this.name, "content"));
519
522
  }
package/dist/index.d.cts CHANGED
@@ -25,6 +25,9 @@ interface ScrollNodeIntoViewOptions {
25
25
  animationTime?: number;
26
26
  limitToBounds?: boolean;
27
27
  }
28
+ interface DefaultLocatedOptions extends Omit<ScrollNodeIntoViewOptions, 'nodeId'> {
29
+ nodeId?: string | null;
30
+ }
28
31
  interface EdgeScrollConfig {
29
32
  enabled: boolean;
30
33
  edgeSize: number;
@@ -33,7 +36,7 @@ interface EdgeScrollConfig {
33
36
  }
34
37
 
35
38
  type CanvasConfig = ReactZoomPanPinchProps & {
36
- defaultLocated?: ScrollNodeIntoViewOptions;
39
+ defaultLocated?: DefaultLocatedOptions;
37
40
  };
38
41
  declare module '@knotx/core' {
39
42
  interface PluginData {
@@ -176,12 +179,18 @@ declare class Canvas extends BasePlugin<'canvas', CanvasConfig> {
176
179
  };
177
180
  };
178
181
  }>): void;
179
- private handleEdgeScroll;
180
182
  render({ children }?: {
181
183
  children: ReactNode;
182
184
  }): JSX.Element;
183
185
  init(config: CanvasConfig): void;
186
+ private groupLayers;
187
+ private getDefaultTransform;
188
+ private onClick;
189
+ private onContextMenu;
190
+ private onMouseMove;
191
+ private onMouseLeave;
192
+ private handleEdgeScroll;
184
193
  private isCanvasEvent;
185
194
  }
186
195
 
187
- export { Canvas, type CanvasConfig, type CanvasContentSize, type CanvasEventListener, type CanvasEventType, type CanvasTransformState, type EdgeScrollConfig, type ScrollNodeIntoViewOptions };
196
+ export { Canvas, type CanvasConfig, type CanvasContentSize, type CanvasEventListener, type CanvasEventType, type CanvasTransformState, type DefaultLocatedOptions, type EdgeScrollConfig, type ScrollNodeIntoViewOptions };
package/dist/index.d.mts CHANGED
@@ -25,6 +25,9 @@ interface ScrollNodeIntoViewOptions {
25
25
  animationTime?: number;
26
26
  limitToBounds?: boolean;
27
27
  }
28
+ interface DefaultLocatedOptions extends Omit<ScrollNodeIntoViewOptions, 'nodeId'> {
29
+ nodeId?: string | null;
30
+ }
28
31
  interface EdgeScrollConfig {
29
32
  enabled: boolean;
30
33
  edgeSize: number;
@@ -33,7 +36,7 @@ interface EdgeScrollConfig {
33
36
  }
34
37
 
35
38
  type CanvasConfig = ReactZoomPanPinchProps & {
36
- defaultLocated?: ScrollNodeIntoViewOptions;
39
+ defaultLocated?: DefaultLocatedOptions;
37
40
  };
38
41
  declare module '@knotx/core' {
39
42
  interface PluginData {
@@ -176,12 +179,18 @@ declare class Canvas extends BasePlugin<'canvas', CanvasConfig> {
176
179
  };
177
180
  };
178
181
  }>): void;
179
- private handleEdgeScroll;
180
182
  render({ children }?: {
181
183
  children: ReactNode;
182
184
  }): JSX.Element;
183
185
  init(config: CanvasConfig): void;
186
+ private groupLayers;
187
+ private getDefaultTransform;
188
+ private onClick;
189
+ private onContextMenu;
190
+ private onMouseMove;
191
+ private onMouseLeave;
192
+ private handleEdgeScroll;
184
193
  private isCanvasEvent;
185
194
  }
186
195
 
187
- export { Canvas, type CanvasConfig, type CanvasContentSize, type CanvasEventListener, type CanvasEventType, type CanvasTransformState, type EdgeScrollConfig, type ScrollNodeIntoViewOptions };
196
+ export { Canvas, type CanvasConfig, type CanvasContentSize, type CanvasEventListener, type CanvasEventType, type CanvasTransformState, type DefaultLocatedOptions, type EdgeScrollConfig, type ScrollNodeIntoViewOptions };
package/dist/index.d.ts CHANGED
@@ -25,6 +25,9 @@ interface ScrollNodeIntoViewOptions {
25
25
  animationTime?: number;
26
26
  limitToBounds?: boolean;
27
27
  }
28
+ interface DefaultLocatedOptions extends Omit<ScrollNodeIntoViewOptions, 'nodeId'> {
29
+ nodeId?: string | null;
30
+ }
28
31
  interface EdgeScrollConfig {
29
32
  enabled: boolean;
30
33
  edgeSize: number;
@@ -33,7 +36,7 @@ interface EdgeScrollConfig {
33
36
  }
34
37
 
35
38
  type CanvasConfig = ReactZoomPanPinchProps & {
36
- defaultLocated?: ScrollNodeIntoViewOptions;
39
+ defaultLocated?: DefaultLocatedOptions;
37
40
  };
38
41
  declare module '@knotx/core' {
39
42
  interface PluginData {
@@ -176,12 +179,18 @@ declare class Canvas extends BasePlugin<'canvas', CanvasConfig> {
176
179
  };
177
180
  };
178
181
  }>): void;
179
- private handleEdgeScroll;
180
182
  render({ children }?: {
181
183
  children: ReactNode;
182
184
  }): JSX.Element;
183
185
  init(config: CanvasConfig): void;
186
+ private groupLayers;
187
+ private getDefaultTransform;
188
+ private onClick;
189
+ private onContextMenu;
190
+ private onMouseMove;
191
+ private onMouseLeave;
192
+ private handleEdgeScroll;
184
193
  private isCanvasEvent;
185
194
  }
186
195
 
187
- export { Canvas, type CanvasConfig, type CanvasContentSize, type CanvasEventListener, type CanvasEventType, type CanvasTransformState, type EdgeScrollConfig, type ScrollNodeIntoViewOptions };
196
+ export { Canvas, type CanvasConfig, type CanvasContentSize, type CanvasEventListener, type CanvasEventType, type CanvasTransformState, type DefaultLocatedOptions, type EdgeScrollConfig, type ScrollNodeIntoViewOptions };
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { jsxs, jsx } from '@knotx/jsx/jsx-runtime';
2
- import { Layer, DOMElement, InteractionPriority, bem, BasePlugin } from '@knotx/core';
2
+ import { Layer, DOMElement, bem, BasePlugin, InteractionPriority } from '@knotx/core';
3
3
  import { register, inject, tool, layer, OnInit } from '@knotx/decorators';
4
4
  import { isEqual, merge } from 'lodash-es';
5
- import { useMemo, useReducer, useLayoutEffect, useCallback, Fragment } from 'react';
5
+ import { useMemo, useReducer, useLayoutEffect, Fragment } from 'react';
6
6
  import { TransformWrapper, TransformComponent } from 'react-zoom-pan-pinch';
7
7
 
8
8
  function calculateTransform({
@@ -243,6 +243,47 @@ class Canvas extends (_a = BasePlugin, _transform_dec = [register("transform")],
243
243
  __publicField(this, "removeListener", __runInitializers(_init, 44, this, (type, listener) => {
244
244
  this.listeners[type].delete(listener);
245
245
  })), __runInitializers(_init, 47, this);
246
+ __publicField(this, "onClick", (e) => {
247
+ if (!this.isCanvasEvent(e)) {
248
+ return;
249
+ }
250
+ if (!this.interaction.canInteract(InteractionPriority.CanvasClick)) {
251
+ return;
252
+ }
253
+ this.listeners.click.forEach((listener) => {
254
+ listener(e);
255
+ });
256
+ });
257
+ __publicField(this, "onContextMenu", (e) => {
258
+ if (!this.isCanvasEvent(e)) {
259
+ return;
260
+ }
261
+ if (!this.interaction.canInteract(InteractionPriority.CanvasContextMenu)) {
262
+ return;
263
+ }
264
+ this.listeners.contextmenu.forEach((listener) => {
265
+ listener(e);
266
+ });
267
+ });
268
+ __publicField(this, "onMouseMove", (e) => {
269
+ if (this.edgeScroll.config.enabled) {
270
+ const rect = e.currentTarget.getBoundingClientRect();
271
+ this.mousePosition = {
272
+ x: e.clientX - rect.left,
273
+ y: e.clientY - rect.top
274
+ };
275
+ if (this.edgeScrollAnimationFrame === null) {
276
+ this.edgeScrollAnimationFrame = requestAnimationFrame(this.handleEdgeScroll);
277
+ }
278
+ }
279
+ });
280
+ __publicField(this, "onMouseLeave", () => {
281
+ this.mousePosition = null;
282
+ if (this.edgeScrollAnimationFrame !== null) {
283
+ cancelAnimationFrame(this.edgeScrollAnimationFrame);
284
+ this.edgeScrollAnimationFrame = null;
285
+ }
286
+ });
246
287
  __publicField(this, "handleEdgeScroll", () => {
247
288
  if (!this.edgeScroll.config.enabled || !this.mousePosition || !this.ref) {
248
289
  return;
@@ -321,30 +362,7 @@ class Canvas extends (_a = BasePlugin, _transform_dec = [register("transform")],
321
362
  }
322
363
  render({ children } = { children: null }) {
323
364
  var _a2, _b, _c, _d;
324
- const defaultTransform = useMemo(() => {
325
- const defaultLocated = __spreadValues({}, this.config.defaultLocated);
326
- if (!(defaultLocated == null ? void 0 : defaultLocated.nodeId)) {
327
- return this.transform;
328
- }
329
- const node = this.getNode({ id: defaultLocated.nodeId });
330
- defaultLocated.inline || (defaultLocated.inline = "center");
331
- defaultLocated.block || (defaultLocated.block = "center");
332
- defaultLocated.scale || (defaultLocated.scale = this.transform.scale);
333
- const { positionX, positionY, scale: newScale } = calculateTransform(__spreadValues({
334
- node,
335
- container: this.container,
336
- transform: this.transform,
337
- contentSize: this.contentSize
338
- }, defaultLocated));
339
- const newTransform = {
340
- previousScale: this.transform.scale,
341
- scale: newScale,
342
- positionX: -positionX,
343
- positionY: -positionY
344
- };
345
- this.transform = newTransform;
346
- return newTransform;
347
- }, []);
365
+ const defaultTransform = useMemo(() => this.getDefaultTransform(), []);
348
366
  const [transformRef, setTransformRef] = useReducer((_, ref) => {
349
367
  var _a3;
350
368
  const dom = ref.instance.wrapperComponent;
@@ -356,21 +374,7 @@ class Canvas extends (_a = BasePlugin, _transform_dec = [register("transform")],
356
374
  }
357
375
  return ref;
358
376
  }, null);
359
- const [fixedLayers, childrenLayers] = useMemo(() => {
360
- const fixedLayers2 = [];
361
- const childrenLayers2 = [];
362
- for (const child of Array.isArray(children) ? children : [children]) {
363
- if (!(child == null ? void 0 : child.key)) {
364
- continue;
365
- }
366
- if (child.key <= Layer.Background << 1 || child.key > Layer.Foreground >> 1) {
367
- fixedLayers2.push(child);
368
- } else {
369
- childrenLayers2.push(child);
370
- }
371
- }
372
- return [fixedLayers2, childrenLayers2];
373
- }, [children]);
377
+ const [fixedLayers, childrenLayers] = useMemo(() => this.groupLayers(children), [children]);
374
378
  useLayoutEffect(() => {
375
379
  const wrapperElement = transformRef == null ? void 0 : transformRef.instance.wrapperComponent;
376
380
  const onScroll = (event) => {
@@ -411,47 +415,6 @@ class Canvas extends (_a = BasePlugin, _transform_dec = [register("transform")],
411
415
  wrapperElement == null ? void 0 : wrapperElement.removeEventListener("scroll", onScroll, { capture: true });
412
416
  };
413
417
  }, [transformRef]);
414
- const onClick = useCallback((e) => {
415
- if (!this.isCanvasEvent(e)) {
416
- return;
417
- }
418
- if (!this.interaction.canInteract(InteractionPriority.CanvasClick)) {
419
- return;
420
- }
421
- this.listeners.click.forEach((listener) => {
422
- listener(e);
423
- });
424
- }, []);
425
- const onContextMenu = useCallback((e) => {
426
- if (!this.isCanvasEvent(e)) {
427
- return;
428
- }
429
- if (!this.interaction.canInteract(InteractionPriority.CanvasContextMenu)) {
430
- return;
431
- }
432
- this.listeners.contextmenu.forEach((listener) => {
433
- listener(e);
434
- });
435
- }, []);
436
- const onMouseMove = useCallback((e) => {
437
- if (this.edgeScroll.config.enabled) {
438
- const rect = e.currentTarget.getBoundingClientRect();
439
- this.mousePosition = {
440
- x: e.clientX - rect.left,
441
- y: e.clientY - rect.top
442
- };
443
- if (this.edgeScrollAnimationFrame === null) {
444
- this.edgeScrollAnimationFrame = requestAnimationFrame(this.handleEdgeScroll);
445
- }
446
- }
447
- }, []);
448
- const onMouseLeave = useCallback(() => {
449
- this.mousePosition = null;
450
- if (this.edgeScrollAnimationFrame !== null) {
451
- cancelAnimationFrame(this.edgeScrollAnimationFrame);
452
- this.edgeScrollAnimationFrame = null;
453
- }
454
- }, []);
455
418
  return /* @__PURE__ */ jsxs(
456
419
  TransformWrapper,
457
420
  __spreadProps(__spreadValues({}, this.config), {
@@ -468,14 +431,15 @@ class Canvas extends (_a = BasePlugin, _transform_dec = [register("transform")],
468
431
  wrapperStyle: {
469
432
  width: "100%",
470
433
  height: "100%",
471
- zIndex: Layer.Nodes | Layer.Edges,
434
+ zIndex: Layer.Nodes,
472
435
  contain: "strict"
473
436
  },
474
437
  wrapperProps: {
475
- onClick,
476
- onContextMenu,
477
- onMouseMove,
478
- onMouseLeave
438
+ id: this.pluginId,
439
+ onClick: this.onClick,
440
+ onContextMenu: this.onContextMenu,
441
+ onMouseMove: this.onMouseMove,
442
+ onMouseLeave: this.onMouseLeave
479
443
  },
480
444
  contentClass: bem(this.name, "content"),
481
445
  contentStyle: {
@@ -512,6 +476,45 @@ class Canvas extends (_a = BasePlugin, _transform_dec = [register("transform")],
512
476
  this.rootElement = null;
513
477
  });
514
478
  }
479
+ groupLayers(children) {
480
+ const fixedLayers = [];
481
+ const childrenLayers = [];
482
+ for (const child of Array.isArray(children) ? children : [children]) {
483
+ if (!(child == null ? void 0 : child.key)) {
484
+ continue;
485
+ }
486
+ if (child.key <= Layer.Background << 1 || child.key > Layer.Foreground >> 1) {
487
+ fixedLayers.push(child);
488
+ } else {
489
+ childrenLayers.push(child);
490
+ }
491
+ }
492
+ return [fixedLayers, childrenLayers];
493
+ }
494
+ getDefaultTransform() {
495
+ const defaultLocated = __spreadValues({}, this.config.defaultLocated);
496
+ if (!(defaultLocated == null ? void 0 : defaultLocated.nodeId) && !defaultLocated.limitToBounds) {
497
+ return this.transform;
498
+ }
499
+ const node = defaultLocated.nodeId ? this.getNode({ id: defaultLocated.nodeId }) : void 0;
500
+ defaultLocated.inline || (defaultLocated.inline = "center");
501
+ defaultLocated.block || (defaultLocated.block = "center");
502
+ defaultLocated.scale || (defaultLocated.scale = this.transform.scale);
503
+ const { positionX, positionY, scale: newScale } = calculateTransform(__spreadValues({
504
+ node,
505
+ container: this.container,
506
+ transform: this.transform,
507
+ contentSize: this.contentSize
508
+ }, defaultLocated));
509
+ const newTransform = {
510
+ previousScale: this.transform.scale,
511
+ scale: newScale,
512
+ positionX: -positionX,
513
+ positionY: -positionY
514
+ };
515
+ this.transform = newTransform;
516
+ return newTransform;
517
+ }
515
518
  isCanvasEvent(e) {
516
519
  return e.target === e.currentTarget || e.target.classList.contains(bem(this.name, "content"));
517
520
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knotx/plugins-canvas",
3
- "version": "0.4.3",
3
+ "version": "0.4.5",
4
4
  "description": "Canvas Plugin for Knotx",
5
5
  "author": "boenfu",
6
6
  "license": "MIT",
@@ -29,23 +29,23 @@
29
29
  ],
30
30
  "peerDependencies": {
31
31
  "react": ">=17.0.0",
32
- "@knotx/jsx": "0.4.3"
32
+ "@knotx/jsx": "0.4.5"
33
33
  },
34
34
  "dependencies": {
35
35
  "lodash-es": "^4.17.21",
36
36
  "react-zoom-pan-pinch": "^3.7.0",
37
37
  "rxjs": "^7.8.1",
38
- "@knotx/core": "0.4.3",
39
- "@knotx/decorators": "0.4.3"
38
+ "@knotx/core": "0.4.5",
39
+ "@knotx/decorators": "0.4.5"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@types/lodash-es": "^4.17.12",
43
43
  "@types/react": "^17.0.0",
44
44
  "react": "^17.0.0",
45
- "@knotx/build-config": "0.4.3",
46
- "@knotx/eslint-config": "0.4.3",
47
- "@knotx/jsx": "0.4.3",
48
- "@knotx/typescript-config": "0.4.3"
45
+ "@knotx/build-config": "0.4.5",
46
+ "@knotx/eslint-config": "0.4.5",
47
+ "@knotx/jsx": "0.4.5",
48
+ "@knotx/typescript-config": "0.4.5"
49
49
  },
50
50
  "scripts": {
51
51
  "build": "unbuild",