Browse Source

TS fixes

pull/5321/head
Artur Arseniev 3 years ago
parent
commit
f6d6305364
  1. 4
      src/commands/view/MoveComponent.ts
  2. 18
      src/commands/view/SelectComponent.ts
  3. 5
      src/dom_components/model/Component.ts

4
src/commands/view/MoveComponent.ts

@ -92,8 +92,8 @@ export default extend({}, SelectPosition, SelectComponent, {
// Avoid badge showing on move
this.cacheEl = null;
const lastModel = models[models.length - 1];
const frame = (this.em.get('currentFrame') || {}).model;
const el = lastModel.getEl(frame)!;
const frameView = this.em.getCurrentFrame();
const el = lastModel.getEl(frameView?.model)!;
const doc = el.ownerDocument;
this.startSelectPosition(el, doc, { onStart: this.onStart });
this.sorter.draggable = lastModel.get('draggable');

18
src/commands/view/SelectComponent.ts

@ -30,6 +30,7 @@ let showOffsets: boolean;
*/
export default {
init() {
this.onSelect = debounce(this.onSelect, 0);
bindAll(
this,
'onHover',
@ -129,7 +130,7 @@ export default {
this.currentDoc = trg.ownerDocument;
em.setHovered(model, { useValid: true });
frameView && em.set('currentFrame', frameView);
frameView && em.setCurrentFrame(frameView);
},
onFrameUpdated() {
@ -170,30 +171,25 @@ export default {
* @param {Object} el
* @private
* */
onSelect: debounce(function () {
// @ts-ignore
onSelect() {
const { em } = this;
const component = em.getSelected();
const currentFrame = em.get('currentFrame') || {};
const view = component && component.getView(currentFrame.model);
const currentFrame = em.getCurrentFrame();
const view = component && component.getView(currentFrame?.model);
let el = view && view.el;
let result = {};
if (el && isVisible(el)) {
// @ts-ignore
const pos = this.getElementPos(el);
result = { el, pos, component, view: getViewEl(el) };
}
// @ts-ignore
this.elSelected = result;
// @ts-ignore
this.updateToolsGlobal();
// @ts-ignore This will hide some elements from the select component
// This will hide some elements from the select component
this.updateLocalPos(result);
// @ts-ignore
this.initResize(component);
}, 0),
},
updateGlobalPos() {
const sel = this.getElSelected();

5
src/dom_components/model/Component.ts

@ -1701,7 +1701,7 @@ export default class Component extends StyleableModel<ComponentProperties> {
* @param {Frame} frame Specific frame from which taking the element
* @return {HTMLElement}
*/
getEl(frame = undefined) {
getEl(frame?: Frame) {
const view = this.getView(frame);
return view && view.el;
}
@ -1723,7 +1723,8 @@ export default class Component extends StyleableModel<ComponentProperties> {
}
getCurrentView() {
const frame = (this.em.get('currentFrame') || {}).model;
const frameView = this.em.getCurrentFrame();
const frame = frameView?.model;
return this.getView(frame);
}

Loading…
Cancel
Save