Skip to content

Commit

Permalink
Highlight optimization (#630)
Browse files Browse the repository at this point in the history
  • Loading branch information
DubrovinPavel authored Feb 10, 2020
1 parent 254e89d commit 4e2c718
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 15 deletions.
37 changes: 25 additions & 12 deletions addon/objects/uml-primitives/fd-uml-primitive.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,6 @@ joint.highlighters.strokeAndButtons = {

this._buttons[id].addObject(g);
cellView.vel.append(g);
cellView.model.attr(`.${name}`, get(button, 'attrs.element'));
cellView.model.attr(`.${name}>circle`, get(button, 'attrs.circle'));
cellView.model.attr(`.${name}>text`, get(button, 'attrs.text'));
}, this);
},

Expand All @@ -336,9 +333,6 @@ joint.highlighters.strokeAndButtons = {

this._buttons[id].addObject(g);
cellView.vel.append(g);
cellView.model.attr(`.${name}`, get(button, 'attrs.element'));
cellView.model.attr(`.${name}>circle`, get(button, 'attrs.circle'));
cellView.model.attr(`.${name}>text`, get(button, 'attrs.text'));
}, this);
},

Expand All @@ -363,9 +357,11 @@ joint.util.setByPath(joint.shapes, 'flexberry.uml.PrimitiveElementView', primiti

joint.shapes.flexberry.uml.PrimitiveElementView = joint.dia.ElementView.extend({
getButtons() {
let readonly = this.paper.options.interactive;
if (!readonly && typeof readonly !== 'object') {
return A([]);
if (this.paper) {
let readonly = this.paper.options.interactive;
if (!readonly && typeof readonly !== 'object') {
return A();
}
}

return A([{
Expand All @@ -381,9 +377,11 @@ joint.shapes.flexberry.uml.PrimitiveElementView = joint.dia.ElementView.extend({
},

getSizeChangers() {
let readonly = this.paper.options.interactive;
if (!readonly && typeof readonly !== 'object') {
return A([]);
if (this.paper) {
let readonly = this.paper.options.interactive;
if (!readonly && typeof readonly !== 'object') {
return A();
}
}

return A([{
Expand Down Expand Up @@ -427,6 +425,21 @@ joint.shapes.flexberry.uml.PrimitiveElementView = joint.dia.ElementView.extend({
}

this.setColors();
this.setButtonStyles();
},

setButtonStyles() {
const _this = this;
const buttons = this.getButtons();
const sizeChangers = this.getSizeChangers();
buttons.addObjects(sizeChangers);
buttons.forEach(button => {
let style = {};
style[`.${get(button, 'name')}`] = get(button, 'attrs.element');
style[`.${get(button, 'name')}>circle`] = get(button, 'attrs.circle');
style[`.${get(button, 'name')}>text`] = get(button, 'attrs.text');
_this.model.attr(style);
});
},

getTextColor() {
Expand Down
21 changes: 18 additions & 3 deletions addon/objects/uml-primitives/links-view/fd-empty-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export let EmptyView = joint.dia.LinkView.extend({
this.$el.addClass('linktools-disabled')

this.setColors();
this.setButtonStyles();

this.model.on('change:source', function(element, newSource) {
let objectModel = this.model.get('objectModel');
Expand Down Expand Up @@ -146,6 +147,18 @@ export let EmptyView = joint.dia.LinkView.extend({
}
},

setButtonStyles() {
const _this = this;
const buttons = this.getButtons();
buttons.forEach(button => {
let style = {};
style[`.${get(button, 'name')}`] = get(button, 'attrs.element');
style[`.${get(button, 'name')}>circle`] = get(button, 'attrs.circle');
style[`.${get(button, 'name')}>text`] = get(button, 'attrs.text');
_this.model.attr(style);
});
},

pointerdblclick: function(evt, x, y) {
let readonly = this.paper.options.interactive;
if (!isNone(readonly) && typeof readonly === 'object') {
Expand All @@ -157,9 +170,11 @@ export let EmptyView = joint.dia.LinkView.extend({
},

getButtons() {
let readonly = this.paper.options.interactive;
if (!readonly && typeof readonly !== 'object') {
return A([]);
if (this.paper) {
let readonly = this.paper.options.interactive;
if (!readonly && typeof readonly !== 'object') {
return A();
}
}

return A([{
Expand Down

0 comments on commit 4e2c718

Please sign in to comment.