-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: reenable shadows for blocks being dragged (#79)
* fix: reenable shadows for blocks being dragged * fix: apply drop shadows to all dragging things via CSS * chore: add a license to shadows.js
- Loading branch information
Showing
4 changed files
with
56 additions
and
2 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
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
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* @license | ||
* Copyright 2024 Google LLC | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import * as Blockly from 'blockly/core'; | ||
import {Colours} from '../core/colours.js'; | ||
|
||
export function buildShadowFilter(workspace) { | ||
const svg = workspace.getParentSvg(); | ||
const defs = Blockly.utils.dom.createSvgElement(Blockly.utils.Svg.DEFS, {}, svg); | ||
// Adjust these width/height, x/y properties to stop the shadow from clipping | ||
var dragShadowFilter = Blockly.utils.dom.createSvgElement('filter', | ||
{ | ||
'id': 'blocklyDragShadowFilter', | ||
'height': '140%', | ||
'width': '140%', | ||
'y': '-20%', | ||
'x': '-20%' | ||
}, | ||
defs); | ||
Blockly.utils.dom.createSvgElement('feGaussianBlur', | ||
{ | ||
'in': 'SourceAlpha', | ||
'stdDeviation': '6' | ||
}, | ||
dragShadowFilter); | ||
var componentTransfer = Blockly.utils.dom.createSvgElement( | ||
'feComponentTransfer', {'result': 'offsetBlur'}, dragShadowFilter); | ||
// Shadow opacity is specified in the adjustable colour library, | ||
// since the darkness of the shadow largely depends on the workspace colour. | ||
Blockly.utils.dom.createSvgElement('feFuncA', | ||
{ | ||
'type': 'linear', | ||
'slope': Colours.dragShadowOpacity | ||
}, | ||
componentTransfer); | ||
Blockly.utils.dom.createSvgElement('feComposite', | ||
{ | ||
'in': 'SourceGraphic', | ||
'in2': 'offsetBlur', | ||
'operator': 'over' | ||
}, | ||
dragShadowFilter); | ||
} |