Skip to content

Commit

Permalink
fixed zooming back from component
Browse files Browse the repository at this point in the history
  • Loading branch information
ishubin committed Dec 2, 2024
1 parent f8fb294 commit 53eab26
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/ui/components/editor/Component.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ export function loadAndMountExternalComponent(schemeContainer, userEventBus, ite
const componentSchemeContainer = new SchemeContainer(scheme, schemeContainer.editorId, VIEW_MODE, $store.state.apiClient, {
onSchemeChangeCommitted: () => {}
});
// linking to the same screen transform so that it is possible to zoom to items inside of component
componentSchemeContainer.screenTransform = schemeContainer.screenTransform;
componentSchemeContainer.prepareFrameAnimationsForItems();

const componentUserEventBus = new UserEventBus(schemeContainer.editorId);
Expand Down
1 change: 0 additions & 1 deletion src/ui/scheme/SchemeContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import myMath from '../myMath.js';
import utils from '../utils.js';
import shortid from 'shortid';
import Shape from '../components/editor/items/shapes/Shape.js';
import {generateComponentGoBackButton} from '../components/editor/items/shapes/Component.vue';
import { traverseItems, defaultItemDefinition, defaultItem, findFirstItemBreadthFirst} from './Item';
import { enrichItemWithDefaults } from './ItemFixer';
import { enrichSchemeWithDefaults } from './Scheme';
Expand Down
3 changes: 2 additions & 1 deletion src/ui/userevents/functions/DestroyComponentFunction.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ export default {

execute(item, args, schemeContainer, userEventBus, resultCallback) {
try {
// Cleaning up the overlay layer with the custom component background
// and the "go back" button
traverseItems(item._childItems, subItem => {
userEventBus.clearEventsForItem(subItem.id);
});
item._childItems = [];
schemeContainer.reindexItems();
userEventBus.emitItemEvent(item.id, COMPONENT_DESTROYED);
EditorEventBus.item.changed.specific.$emit(schemeContainer.editorId, item.id);
}
Expand Down
5 changes: 4 additions & 1 deletion src/ui/userevents/functions/ZoomToItFunction.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ import EditorEventBus from '../../components/editor/EditorEventBus';
/**
* Recreating item transform because in some weird cases when some of ancestors were moved,
* the transforms in item metas are not properly recalculated.
* @param {Item} item
* @param {SchemeContainer} schemeContainer
* @returns
*/
function createItemTransform(item, schemeContainer) {
let transform = myMath.identityMatrix();
let transform = schemeContainer.shadowTransform ? schemeContainer.shadowTransform : myMath.identityMatrix();

if (item.meta.ancestorIds) {
for (let i = 0; i < item.meta.ancestorIds.length; i++) {
Expand Down

0 comments on commit 53eab26

Please sign in to comment.