2 * Copyright (c) 2017 ZTE Corporation.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * and the Apache License 2.0 which both accompany this distribution,
6 * and are available at http://www.eclipse.org/legal/epl-v10.html
7 * and http://www.apache.org/licenses/LICENSE-2.0
10 * ZTE - initial API and implementation and/or initial documentation
13 import { AfterViewInit, Directive, ElementRef } from '@angular/core';
14 import * as $ from 'jquery';
16 import { JsPlumbService } from '../../services/jsplumb.service';
17 import { ModelService } from '../../services/model.service';
19 @Directive({ selector: '[wfmResizable]' })
20 export class ResizableDirective implements AfterViewInit {
22 constructor(private el: ElementRef,
23 private jsPlumbService: JsPlumbService,
24 private planModelService: ModelService) {
27 public ngAfterViewInit() {
28 console.log('init resizble.');
30 $(this.el.nativeElement).resizable({
32 resize: (event, ui) => {
33 const element = ui.helper[0];
34 this.planModelService.updatePosition(element.id,
35 element.offsetLeft, element.offsetTop, element.offsetWidth, element.offsetHeight - 12);
36 this.jsPlumbService.resizeParent(element, element.parentNode);
37 const node = this.planModelService.getNodeMap().get(element.id);
38 this.jsPlumbService.jsplumbInstanceMap.get(node.parentId).revalidate(element.id);