UNPKG

@aurigma/design-atoms

Version:

Design Atoms is a part of Customer's Canvas SDK which allows for manipulating individual design elements through your code.

30 lines 1.55 kB
import { BaseTextItem, GroupItem } from "@aurigma/design-atoms-model"; var TextsWorkaroundItemsComparer = /** @class */ (function () { function TextsWorkaroundItemsComparer() { this._sourceItemsToCompare = new Map(); } TextsWorkaroundItemsComparer.prototype.itemsEqual = function (source, destination) { if (source.type === destination.type && this._requiresSpecialComparison(source)) { if (this._sourceItemsToCompare.has(source.id)) { var areEqual = this._sourceItemsToCompare.get(source.id).equals(source); if (areEqual) { return true; } this._sourceItemsToCompare.set(source.id, source.clone()); return false; } this._sourceItemsToCompare.set(source.id, source.clone()); } return source.equals(destination); }; /**Text items and groups from source surface require comparison with its own clones, * but not with ones from PreviewCanvas. * This is due to sourceRectangle of the text item that is on PreviewCanvas * becomes slightly different from the source item after server-side update is performed. */ TextsWorkaroundItemsComparer.prototype._requiresSpecialComparison = function (item) { return item instanceof BaseTextItem || item instanceof GroupItem; }; return TextsWorkaroundItemsComparer; }()); export { TextsWorkaroundItemsComparer }; //# sourceMappingURL=TextsWorkaroundItemsComparer.js.map