-
Notifications
You must be signed in to change notification settings - Fork 859
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(highlighters.Opacity)!: add alphaValue option (#2428)
- Loading branch information
1 parent
fa5b94a
commit 80ab3ee
Showing
5 changed files
with
22 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 7 additions & 4 deletions
11
packages/joint-core/docs/src/joint/api/highlighters/opacity.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
<p>Changes the opacity of an arbitrary cell view's SVG node.</p> | ||
|
||
<p>When a cell is highlighted with the opacity highlighter, the node determined by the selector is given the <code data-lang="css">.joint-highlight-opacity</code> class. To customize the look of this highlighted state, you can add custom CSS rules that affect this class name.</p> | ||
|
||
<p>This highlighter does not currently have any options.</p> | ||
<p>Available options:</p> | ||
<ul> | ||
<li><b>alphaValue</b> - a value that represents the degree to which content behind an element is hidden. It's a number in the range 0.0 to 1.0, inclusive. The default is <code>0.3</code>.</li> | ||
</ul> | ||
|
||
<p>Example usage:</p> | ||
<pre><code>joint.highlighters.opacity.add(cellView, 'body', 'my-highlighter-id');</code></pre> | ||
<pre><code>joint.highlighters.opacity.add(cellView, 'body', 'my-highlighter-id', { | ||
alphaValue: 0.4 | ||
});</code></pre> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,17 @@ | ||
import * as util from '../util/index.mjs'; | ||
import V from '../V/index.mjs'; | ||
import { HighlighterView } from '../dia/HighlighterView.mjs'; | ||
|
||
export const opacity = HighlighterView.extend({ | ||
|
||
UPDATABLE: false, | ||
MOUNTABLE: false, | ||
|
||
opacityClassName: util.addClassNamePrefix('highlight-opacity'), | ||
|
||
highlight: function(_cellView, node) { | ||
V(node).addClass(this.opacityClassName); | ||
const { alphaValue = 0.3 } = this.options; | ||
node.style.opacity = alphaValue; | ||
}, | ||
|
||
unhighlight: function(_cellView, node) { | ||
V(node).removeClass(this.opacityClassName); | ||
node.style.opacity = ''; | ||
} | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters