File tree Expand file tree Collapse file tree 4 files changed +56
-2
lines changed Expand file tree Collapse file tree 4 files changed +56
-2
lines changed Original file line number Diff line number Diff line change 103
103
"textFieldText" : "#575E75" ,
104
104
"insertionMarker" : "#000000" ,
105
105
"insertionMarkerOpacity" : 0.2 ,
106
- "dragShadowOpacity" : 0.3 ,
106
+ "dragShadowOpacity" : 0.6 ,
107
107
"stackGlow" : "#FFF200" ,
108
108
"stackGlowSize" : 4 ,
109
109
"stackGlowOpacity" : 1 ,
Original file line number Diff line number Diff line change @@ -284,6 +284,12 @@ const styles = `
284
284
cursor: -webkit-grabbing;
285
285
cursor: -moz-grabbing;
286
286
}
287
+
288
+ /* All the blocks being dragged get the blocklyDragging class, so match only the root one */
289
+ :not(.blocklyDragging) > .blocklyDragging {
290
+ filter: url(#blocklyDragShadowFilter);
291
+ }
292
+
287
293
/* Changes cursor on mouse down. Not effective in Firefox because of
288
294
https://bugzilla.mozilla.org/show_bug.cgi?id=771241 */
289
295
.blocklyDraggable:active {
Original file line number Diff line number Diff line change @@ -31,9 +31,10 @@ import {
31
31
ContinuousMetrics ,
32
32
} from '@blockly/continuous-toolbox' ;
33
33
import { CheckableContinuousFlyout } from './checkable_continuous_flyout.js' ;
34
- import { ScratchContinuousToolbox } from './scratch_continuous_toolbox.js' ;
35
34
import { buildGlowFilter , glowStack } from './glows.js' ;
35
+ import { ScratchContinuousToolbox } from './scratch_continuous_toolbox.js' ;
36
36
import './scratch_continuous_category.js' ;
37
+ import { buildShadowFilter } from './shadows.js' ;
37
38
38
39
export * from 'blockly' ;
39
40
export * from './block_reporting.js' ;
@@ -66,6 +67,7 @@ export function inject(container, options) {
66
67
}
67
68
68
69
buildGlowFilter ( workspace ) ;
70
+ buildShadowFilter ( workspace ) ;
69
71
70
72
Blockly . config . dragRadius = 3 ;
71
73
Blockly . config . snapRadius = 48 ;
Original file line number Diff line number Diff line change
1
+ /**
2
+ * @license
3
+ * Copyright 2024 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ import * as Blockly from 'blockly/core' ;
8
+ import { Colours } from '../core/colours.js' ;
9
+
10
+ export function buildShadowFilter ( workspace ) {
11
+ const svg = workspace . getParentSvg ( ) ;
12
+ const defs = Blockly . utils . dom . createSvgElement ( Blockly . utils . Svg . DEFS , { } , svg ) ;
13
+ // Adjust these width/height, x/y properties to stop the shadow from clipping
14
+ var dragShadowFilter = Blockly . utils . dom . createSvgElement ( 'filter' ,
15
+ {
16
+ 'id' : 'blocklyDragShadowFilter' ,
17
+ 'height' : '140%' ,
18
+ 'width' : '140%' ,
19
+ 'y' : '-20%' ,
20
+ 'x' : '-20%'
21
+ } ,
22
+ defs ) ;
23
+ Blockly . utils . dom . createSvgElement ( 'feGaussianBlur' ,
24
+ {
25
+ 'in' : 'SourceAlpha' ,
26
+ 'stdDeviation' : '6'
27
+ } ,
28
+ dragShadowFilter ) ;
29
+ var componentTransfer = Blockly . utils . dom . createSvgElement (
30
+ 'feComponentTransfer' , { 'result' : 'offsetBlur' } , dragShadowFilter ) ;
31
+ // Shadow opacity is specified in the adjustable colour library,
32
+ // since the darkness of the shadow largely depends on the workspace colour.
33
+ Blockly . utils . dom . createSvgElement ( 'feFuncA' ,
34
+ {
35
+ 'type' : 'linear' ,
36
+ 'slope' : Colours . dragShadowOpacity
37
+ } ,
38
+ componentTransfer ) ;
39
+ Blockly . utils . dom . createSvgElement ( 'feComposite' ,
40
+ {
41
+ 'in' : 'SourceGraphic' ,
42
+ 'in2' : 'offsetBlur' ,
43
+ 'operator' : 'over'
44
+ } ,
45
+ dragShadowFilter ) ;
46
+ }
You can’t perform that action at this time.
0 commit comments