Browse Source

Up TS for utils

pull/4746/head
Artur Arseniev 4 years ago
parent
commit
97f55853ca
  1. 2
      src/editor/index.ts
  2. 9
      src/panels/view/PanelView.ts
  3. 2
      src/utils/Resizer.ts
  4. 2
      src/utils/index.ts

2
src/editor/index.ts

@ -58,6 +58,7 @@ import { EventHandler } from 'backbone';
import { isUndefined } from 'underscore'; import { isUndefined } from 'underscore';
import { IBaseModule } from '../abstract/Module'; import { IBaseModule } from '../abstract/Module';
import CanvasModule from '../canvas'; import CanvasModule from '../canvas';
import UtilsModule from '../utils';
import cash from '../utils/cash-dom'; import cash from '../utils/cash-dom';
import html from '../utils/html'; import html from '../utils/html';
import defaults from './config/config'; import defaults from './config/config';
@ -97,7 +98,6 @@ export default class EditorModule implements IBaseModule<typeof defaults> {
get I18n(): I18nModule { get I18n(): I18nModule {
return this.em.get('I18n'); return this.em.get('I18n');
} }
//@ts-ignore
get Utils(): UtilsModule { get Utils(): UtilsModule {
return this.em.get('Utils'); return this.em.get('Utils');
} }

9
src/panels/view/PanelView.ts

@ -1,5 +1,6 @@
import { View } from '../../abstract'; import { View } from '../../abstract';
import EditorModule from '../../editor'; import EditorModule from '../../editor';
import Resizer from '../../utils/Resizer';
import Panel from '../model/Panel'; import Panel from '../model/Panel';
import ButtonsView from './ButtonsView'; import ButtonsView from './ButtonsView';
@ -67,7 +68,7 @@ export default class PanelView extends View<Panel> {
cl = resz[3]; cl = resz[3];
} }
var resizer = new editor.Utils.Resizer({ const resizer: Resizer = new editor.Utils.Resizer({
tc, tc,
cr, cr,
bc, bc,
@ -84,10 +85,10 @@ export default class PanelView extends View<Panel> {
em && em.trigger('change:canvasOffset'); em && em.trigger('change:canvasOffset');
}, },
posFetcher: (el: HTMLElement, { target }: any) => { posFetcher: (el: HTMLElement, { target }: any) => {
const style = el.style; const style = el.style as any;
const config = resizer.getConfig(); const config = resizer.getConfig();
const keyWidth = config.keyWidth; const keyWidth = config.keyWidth!;
const keyHeight = config.keyHeight; const keyHeight = config.keyHeight!;
const rect = el.getBoundingClientRect(); const rect = el.getBoundingClientRect();
const forContainer = target == 'container'; const forContainer = target == 'container';
const styleWidth = style[keyWidth]; const styleWidth = style[keyWidth];

2
src/utils/Resizer.ts

@ -262,7 +262,7 @@ export default class Resizer {
* Init the Resizer with options * Init the Resizer with options
* @param {Object} options * @param {Object} options
*/ */
constructor(opts = {}) { constructor(opts: ResizerOptions = {}) {
this.opts = { this.opts = {
ratioDefault: false, ratioDefault: false,
onUpdateContainer: () => {}, onUpdateContainer: () => {},

2
src/utils/index.ts

@ -7,7 +7,7 @@ import EditorModel from '../editor/model/Editor';
export default class UtilsModule extends Module { export default class UtilsModule extends Module {
Sorter = Sorter; Sorter = Sorter;
Resizer = Resizer; Resizer: typeof Resizer = Resizer;
Dragger = Dragger; Dragger = Dragger;
helpers = { ...mixins }; helpers = { ...mixins };

Loading…
Cancel
Save