mirror of
https://github.com/scratchfoundation/scratch-blocks.git
synced 2025-08-28 22:10:31 -04:00
Randomized id for svg filters
This commit is contained in:
parent
e38969831e
commit
d9c91d958d
4 changed files with 15 additions and 6 deletions
|
@ -335,7 +335,9 @@ Blockly.BlockSvg.prototype.updateColour = function() {
|
|||
*/
|
||||
Blockly.BlockSvg.prototype.highlightForReplacement = function(add) {
|
||||
if (add) {
|
||||
this.svgPath_.setAttribute('filter', 'url(#blocklyReplacementGlowFilter)');
|
||||
var replacementGlowFilterId = this.workspace.options.replacementGlowFilterId
|
||||
|| 'blocklyReplacementGlowFilter';
|
||||
this.svgPath_.setAttribute('filter', 'url(#' + replacementGlowFilterId + ')');
|
||||
Blockly.utils.addClass(/** @type {!Element} */ (this.svgGroup_),
|
||||
'blocklyReplaceable');
|
||||
} else {
|
||||
|
|
|
@ -560,7 +560,9 @@ Blockly.BlockSvg.prototype.updateColour = function() {
|
|||
*/
|
||||
Blockly.BlockSvg.prototype.highlightForReplacement = function(add) {
|
||||
if (add) {
|
||||
this.svgPath_.setAttribute('filter', 'url(#blocklyReplacementGlowFilter)');
|
||||
var replacementGlowFilterId = this.workspace.options.replacementGlowFilterId
|
||||
|| 'blocklyReplacementGlowFilter';
|
||||
this.svgPath_.setAttribute('filter', 'url(#' + replacementGlowFilterId + ')');
|
||||
Blockly.utils.addClass(/** @type {!Element} */ (this.svgGroup_),
|
||||
'blocklyReplaceable');
|
||||
} else {
|
||||
|
@ -585,8 +587,10 @@ Blockly.BlockSvg.prototype.highlightShapeForInput = function(conn, add) {
|
|||
return;
|
||||
}
|
||||
if (add) {
|
||||
var replacementGlowFilterId = this.workspace.options.replacementGlowFilterId
|
||||
|| 'blocklyReplacementGlowFilter';
|
||||
input.outlinePath.setAttribute('filter',
|
||||
'url(#blocklyReplacementGlowFilter)');
|
||||
'url(#' + replacementGlowFilterId + ')');
|
||||
Blockly.utils.addClass(/** @type {!Element} */ (this.svgGroup_),
|
||||
'blocklyReplaceable');
|
||||
} else {
|
||||
|
|
|
@ -231,7 +231,8 @@ Blockly.BlockSvg.prototype.setGlowStack = function(isGlowingStack) {
|
|||
// Update the applied SVG filter if the property has changed
|
||||
var svg = this.getSvgRoot();
|
||||
if (this.isGlowingStack_ && !svg.hasAttribute('filter')) {
|
||||
svg.setAttribute('filter', 'url(#blocklyStackGlowFilter)');
|
||||
var stackGlowFilterId = this.workspace.options.stackGlowFilterId || 'blocklyStackGlowFilter';
|
||||
svg.setAttribute('filter', 'url(#' + stackGlowFilterId + ')');
|
||||
} else if (!this.isGlowingStack_ && svg.hasAttribute('filter')) {
|
||||
svg.removeAttribute('filter');
|
||||
}
|
||||
|
|
|
@ -132,7 +132,7 @@ Blockly.createDom_ = function(container, options) {
|
|||
// Instead use a gaussian blur, and then set all alpha to 1 with a transfer.
|
||||
var stackGlowFilter = Blockly.utils.createSvgElement('filter',
|
||||
{
|
||||
'id': 'blocklyStackGlowFilter',
|
||||
'id': 'blocklyStackGlowFilter' + rnd,
|
||||
'height': '160%',
|
||||
'width': '180%',
|
||||
y: '-30%',
|
||||
|
@ -180,7 +180,7 @@ Blockly.createDom_ = function(container, options) {
|
|||
// Filter for replacement marker
|
||||
var replacementGlowFilter = Blockly.utils.createSvgElement('filter',
|
||||
{
|
||||
'id': 'blocklyReplacementGlowFilter',
|
||||
'id': 'blocklyReplacementGlowFilter' + rnd,
|
||||
'height': '160%',
|
||||
'width': '180%',
|
||||
y: '-30%',
|
||||
|
@ -253,6 +253,8 @@ Blockly.createDom_ = function(container, options) {
|
|||
'stroke': '#cc0'
|
||||
},
|
||||
disabledPattern);
|
||||
options.stackGlowFilterId = stackGlowFilter.id;
|
||||
options.replacementGlowFilterId = replacementGlowFilter.id;
|
||||
options.disabledPatternId = disabledPattern.id;
|
||||
|
||||
options.gridPattern = Blockly.Grid.createDom(rnd, options.gridOptions, defs);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue