Skip to content
This repository was archived by the owner on Jul 24, 2019. It is now read-only.

Commit 5fd47c7

Browse files
Merge pull request #14 from aaron-binary/flyout-shape-logic
Flyout Shape
2 parents 30efbdc + 793c005 commit 5fd47c7

11 files changed

+265
-177
lines changed

.stylelintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"property-case" : "lower",
5252
"plugin/no-unsupported-browser-features" : [true, {
5353
"severity": "warning",
54-
"ignore": ["calc", "user-select-none", "multicolumn", "css-appearance", "border-radius", "pointer"]
54+
"ignore": ["calc", "user-select-none", "multicolumn", "css-appearance", "border-radius", "pointer", "css-filters"]
5555
}],
5656
"rule-empty-line-before" : ["always", { "ignore": ["after-comment"], "except": ["inside-block-and-after-rule", "first-nested"] }],
5757
"selector-attribute-brackets-space-inside" : "never",

src/assets/sass/base/mixins.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@mixin vendor($property, $value) {
2+
$prefixes: ('moz', 'webkit', 'ms', 'o');
3+
@each $prefix in $prefixes {
4+
-#{$prefix}-#{$property}: #{$value};
5+
}
6+
#{$property}: #{$value};
7+
}

src/assets/sass/scratch/_blockly-toolbox.scss

Lines changed: 0 additions & 115 deletions
This file was deleted.

src/assets/sass/scratch/_flyout.scss

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
@import '../base/mixins';
2+
3+
.blocklyFlyout {
4+
@include vendor(filter, drop-shadow(0 10px 5px #999));
5+
}
6+
17
.blocklyFlyoutBackground {
28
height: calc(100% - 60px) !important;
39
fill: #fff !important;
410
fill-opacity: 0.95 !important;
5-
stroke: #ebebeb;
6-
stroke-width: 5px;
7-
}
11+
}

src/assets/sass/scratch/_toolbox.scss

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@import '../base/mixins';
2+
13
$category-colours: (
24
trade-definition: #303f9f,
35
before-purchase : #00897b,
@@ -30,7 +32,7 @@ $category-colours: (
3032
display: flex;
3133
flex-direction: column;
3234
margin-top: 20px;
33-
max-height: calc(100% - 40px) !important;
35+
max-height: calc(100vh - 100px);
3436
overflow: hidden;
3537
position: absolute;
3638
user-select: none;
@@ -63,8 +65,8 @@ $category-colours: (
6365
position: absolute;
6466
top: 0.6em;
6567
right: 0.6em;
66-
transform: rotate(90deg);
67-
transition: transform 0.25s ease;
68+
@include vendor(transform, rotate(90deg));
69+
@include vendor(transition, transform 0.25s ease);
6870
}
6971
&__item {
7072
position: relative;
@@ -90,7 +92,7 @@ $category-colours: (
9092
}
9193
#{$toolbox}__arrow {
9294
position: relative;
93-
transform: rotate(270deg);
95+
@include vendor(transform, rotate(270deg));
9496
margin-top: -2px;
9597
top: 0;
9698
right: -2px;

src/assets/sass/scratch/_workspace.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,8 @@
1212

1313
.blocklyText {
1414
fill: #000 !important;
15+
}
16+
17+
.blocklyMainWorkspaceScrollbar {
18+
display: none;
1519
}

src/scratch/hooks/block_svg.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
/* eslint-disable func-names, no-underscore-dangle */
21
import { translate } from '../../utils/lang/i18n';
32

3+
/* eslint-disable func-names, no-underscore-dangle */
4+
5+
// deriv-bot: Blockly value, Scratch resets this to 0, req for correct spacing in flyout.
6+
Blockly.BlockSvg.TAB_WIDTH = 8;
7+
48
/**
59
* Set whether the block is disabled or not.
610
* @param {boolean} disabled True if disabled.

src/scratch/hooks/flyout_base.js

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,34 @@
11
/* eslint-disable func-names, no-underscore-dangle */
2+
3+
/**
4+
* Corner radius of the flyout background.
5+
* @type {number}
6+
* @const
7+
*/
8+
Blockly.Flyout.prototype.CORNER_RADIUS = 10;
9+
210
/**
311
* Margin around the edges of the blocks in the flyout.
412
* @type {number}
513
* @const
614
*/
7-
Blockly.Flyout.prototype.MARGIN = 24;
15+
Blockly.Flyout.prototype.MARGIN = 30;
16+
17+
/**
18+
* Top/bottom padding between scrollbar and edge of flyout background.
19+
* deriv-bot: Should be equal to CORNER_RADIUS
20+
* @type {number}
21+
* @const
22+
*/
23+
Blockly.Flyout.prototype.SCROLLBAR_PADDING = 20;
24+
25+
/**
26+
* The fraction of the distance to the scroll target to move the flyout on
27+
* each animation frame, when auto-scrolling. Values closer to 1.0 will make
28+
* the scroll animation complete faster. Use 1.0 for no animation.
29+
* @type {number}
30+
*/
31+
Blockly.Flyout.prototype.scrollAnimationFraction = 1.0;
832

933
/**
1034
* Update the view based on coordinates calculated in position().
@@ -13,26 +37,31 @@ Blockly.Flyout.prototype.MARGIN = 24;
1337
* @param {number} x The computed x origin of the flyout's SVG group.
1438
* @param {number} y The computed y origin of the flyout's SVG group.
1539
* @protected
16-
* deriv-bot: Imported from Blockly, used in flyout_vertical.js
1740
*/
1841
Blockly.Flyout.prototype.positionAt_ = function(width, height, x, y) {
1942
this.svgGroup_.setAttribute('width', width);
2043
this.svgGroup_.setAttribute('height', height);
44+
2145
if (this.svgGroup_.tagName === 'svg') {
2246
const transform = `translate(${x}px,${y}px)`;
47+
2348
Blockly.utils.setCssTransform(this.svgGroup_, transform);
2449
} else {
2550
// IE and Edge don't support CSS transforms on SVG elements so
2651
// it's important to set the transform on the SVG element itself
2752
const transform = `translate(${x},${y})`;
53+
2854
this.svgGroup_.setAttribute('transform', transform);
2955
}
3056

3157
// Update the scrollbar (if one exists).
3258
if (this.scrollbar_) {
59+
const newX = x - this.ARROW_SIZE;
60+
3361
// Set the scrollbars origin to be the top left of the flyout.
34-
this.scrollbar_.setOrigin(x, y);
62+
this.scrollbar_.setOrigin(newX, y);
3563
this.scrollbar_.resize();
64+
3665
// Set the position again so that if the metrics were the same (and the
3766
// resize failed) our position is still updated.
3867
this.scrollbar_.setPosition_(this.scrollbar_.position_.x, this.scrollbar_.position_.y);

0 commit comments

Comments
 (0)