Skip to content

Commit

Permalink
refactor: remove legacy unused linkView and interactivity options (#2502
Browse files Browse the repository at this point in the history
)
  • Loading branch information
kumilingus committed Jan 24, 2024
1 parent 4d2f3db commit 1f61873
Show file tree
Hide file tree
Showing 14 changed files with 17 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@
longLinkLength: 155,
linkToolsOffset: 40,
doubleLinkToolsOffset: 65,
sampleInterval: 50
},

_labelCache: null,
Expand Down
2 changes: 1 addition & 1 deletion packages/joint-core/demo/marey/src/marey.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ const paper = new dia.Paper({
async: true,
width: 'calc(100% - 20px)',
height: 'calc(100% - 70px)',
interactive: { linkMove: false, vertexMove: true },
interactive: { linkMove: false },
background: {
color: BG_COLOR
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@
return {
linkMove: false,
labelMove: view.model.get('enabled'),
arrowheadMove: false,
vertexMove: false,
vertexAdd: false,
vertexRemove: false,
useLinkTools: false
};
},
model: graph,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@
return {
linkMove: false,
labelMove: view.model.get('enabled'),
arrowheadMove: false,
vertexMove: false,
vertexAdd: false,
vertexRemove: false,
useLinkTools: false
};
},
model: graph,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@
return {
linkMove: view.model.get('enabled'),
labelMove: false,
arrowheadMove: false,
vertexMove: false,
vertexAdd: false,
vertexRemove: false,
useLinkTools: false
};
},
model: graph,
Expand Down
29 changes: 9 additions & 20 deletions packages/joint-core/docs/src/joint/api/dia/LinkView/intro.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,30 @@

<p>To find the view associated with a specific link model, use the <code>paper.findViewByModel()</code> <a href="#dia.Paper.prototype.findViewByModel">method</a>:</p>

<pre><code>var linkView = paper.findViewByModel(link);</code></pre>
<pre><code>const linkView = paper.findViewByModel(link);
// const linkView = link.findView(paper); // alternatively</code></pre>
</code></pre>

<h4>Custom LinkView</h4>

<p>It is possible to use a custom default link view for all your links in a paper. This can be set up via the <code>linkView</code> option on the <a href="#dia.Paper.prototype.options">paper object</a>. Several options in <code>joint.dia.LinkView</code> may be overridden in a custom LinkView:</p>
<p>It is possible to use a custom default link view for all your links in a paper. This can be set up via the <code>linkView</code> option on the <a href="#dia.Paper.prototype.options">paper object</a>.</p>

<ul>
<li><b>shortLinkLength</b> - if link is shorter than the length specified, the size of link tools is scaled down by half. Defaults to <code>105</code>.</li>
<li><b>doubleLinkTools</b> - render link tools on both ends of the link (only if the link is longer than <code>longLinkLength</code>). Defaults to <code>false</code>.</li>
<li><b>longLinkLength</b> - if length is longer than the length specified and <code>doubleLinkTools: true</code>, render link tools on both ends of the link. Defaults to <code>155</code>.</li>
<li><b>linkToolsOffset</b> - the offset of link tools from the beginning of the link. Defaults to <code>40</code>.</li>
<li><b>doubleLinkToolsOffset</b> - the offset of duplicate link tools from the end of the link, if length is longer than <code>longLinkLength</code> and <code>doubleLinkTools: true</code>. Defaults to <code>65</code>.</li>
</ul>

<p>A custom LinkView type may also override default LinkView event handlers, or provide new ones. It may be necessary to modify the <code>interactive</code> <a href="#dia.Paper.prototype.options.interactive">paper option</a> to prevent interference from builtin event handlers (most notably <code>vertexAdd</code> which listens for pointerdown events).</p>
<p>A custom LinkView type may also override default LinkView event handlers, or provide new ones. It may be necessary to modify the <code>interactive</code> <a href="#dia.Paper.prototype.options.interactive">paper option</a> to prevent interference from builtin event handlers.</p>

<p>Example:</p>

<pre><code>var CustomLinkView = joint.dia.LinkView.extend({
<pre><code>const CustomLinkView = dia.LinkView.extend({
// custom interactions:
pointerdblclick: function(evt, x, y) {
this.addVertex(x, y);
},

contextmenu: function(evt, x, y) {
this.addLabel(x, y);
},

// custom options:
options: joint.util.defaults({
doubleLinkTools: true,
}, joint.dia.LinkView.prototype.options)
}
});

var paper = new joint.dia.Paper({
const paper = new dia.Paper({
//...
linkView: CustomLinkView,
interactive: { vertexAdd: false } // disable default vertexAdd interaction
});</code></pre>
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,5 @@

var paper = new joint.dia.Paper({
// ...
linkView: CustomLinkView,
interactive: { vertexAdd: false } // disable default vertexAdd interaction
linkView: CustomLinkView
});</code></pre>
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@

var paper = new joint.dia.Paper({
// ...
linkView: CustomLinkView,
interactive: { vertexAdd: false } // disable default vertexAdd interaction
linkView: CustomLinkView
});</code></pre>
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,5 @@

var paper = new joint.dia.Paper({
// ...
linkView: CustomLinkView,
interactive: { vertexAdd: false } // disable default vertexAdd interaction
linkView: CustomLinkView
});</code></pre>
10 changes: 0 additions & 10 deletions packages/joint-core/src/dia/LinkView.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,6 @@ export const LinkView = CellView.extend({
return classNames.join(' ');
},

options: {

shortLinkLength: 105,
doubleLinkTools: false,
longLinkLength: 155,
linkToolsOffset: 40,
doubleLinkToolsOffset: 65,
sampleInterval: 50
},

_labelCache: null,
_labelSelectors: null,
_V: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,7 @@
snapLabels: true,
interactive: {
linkMove: false,
labelMove: true,
arrowheadMove: false,
vertexMove: false,
vertexAdd: false,
vertexRemove: false,
useLinkTools: false,
labelMove: true
}
});

Expand Down
7 changes: 1 addition & 6 deletions packages/joint-core/tutorials/js/link-labels-interaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@
cellViewNamespace: namespace,
interactive: {
linkMove: false,
labelMove: true,
arrowheadMove: false,
vertexMove: false,
vertexAdd: false,
vertexRemove: false,
useLinkTools: false,
labelMove: true
}
});

Expand Down
14 changes: 2 additions & 12 deletions packages/joint-core/tutorials/link-labels.html
Original file line number Diff line number Diff line change
Expand Up @@ -406,12 +406,7 @@ <h3>Interaction</h3>
// ...
interactive: {
linkMove: false,
labelMove: true,
arrowheadMove: false,
vertexMove: false,
vertexAdd: false,
vertexRemove: false,
useLinkTools: false
labelMove: true
}
});</code></pre>

Expand All @@ -430,12 +425,7 @@ <h3>Interaction</h3>
snapLabels: true,
interactive: {
linkMove: false,
labelMove: true,
arrowheadMove: false,
vertexMove: false,
vertexAdd: false,
vertexRemove: false,
useLinkTools: false
labelMove: true
}
});</code></pre>

Expand Down
11 changes: 0 additions & 11 deletions packages/joint-core/types/joint.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -983,13 +983,8 @@ export namespace dia {
}

interface InteractivityOptions {
vertexAdd?: boolean;
vertexMove?: boolean;
vertexRemove?: boolean;
arrowheadMove?: boolean;
labelMove?: boolean;
linkMove?: boolean;
useLinkTools?: boolean;
}

interface LabelOptions extends Cell.Options {
Expand All @@ -1005,12 +1000,6 @@ export namespace dia {
}

interface Options extends mvc.ViewOptions<Link, SVGElement> {
shortLinkLength?: number;
doubleLinkTools?: boolean;
longLinkLength?: number;
linkToolsOffset?: number;
doubleLinkToolsOffset?: number;
sampleInterval?: number;
labelsLayer?: Paper.Layers | string | false;
}
}
Expand Down

0 comments on commit 1f61873

Please sign in to comment.