-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Single auto-scrolling flyout containing all of the blocks #1059
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Single auto-scrolling flyout containing all of the blocks #1059
Conversation
4293316
to
e3123af
Compare
core/flyout_base.js
Outdated
// Handle dynamic categories, represented by a name instead of a list of XML. | ||
// Look up the correct category generation function and call that to get a | ||
// valid XML list. | ||
if (typeof xmlList[i] === 'string') { |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
core/flyout_base.js
Outdated
}; | ||
|
||
/** | ||
* Store an array of with category names and scrollbar positions. |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
core/flyout_base.js
Outdated
Blockly.Flyout.prototype.recordCategoryScrollPositions_ = function() { | ||
this.categoryScrollPositions = []; | ||
for (var i = 0; i < this.buttons_.length; i++) { | ||
if (this.buttons_[i].isCategoryLabel_) { |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
core/flyout_base.js
Outdated
|
||
/** | ||
* Select a category using the scroll position. | ||
* @param {number} pos The scroll position. |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
@@ -155,13 +155,14 @@ Blockly.FlyoutButton.prototype.createDom = function() { | |||
this.svgGroup_); | |||
svgText.textContent = this.text_; | |||
|
|||
this.width = svgText.getComputedTextLength() + | |||
2 * Blockly.FlyoutButton.MARGIN; | |||
this.width = svgText.getComputedTextLength(); |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
var metrics = this.workspace_.getMetrics(); | ||
var contentWidth = metrics.contentWidth; | ||
var viewWidth = metrics.viewWidth; | ||
this.scrollTarget = Math.min(this.scrollTarget, contentWidth - viewWidth); |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
core/flyout_horizontal.js
Outdated
@@ -245,16 +245,46 @@ Blockly.HorizontalFlyout.prototype.scrollToStart = function() { | |||
}; | |||
|
|||
/** | |||
* Scroll the flyout to a position. | |||
* @param {number} pos The targeted scroll position. | |||
*/ |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
core/flyout_vertical.js
Outdated
@@ -37,6 +37,7 @@ goog.require('goog.dom'); | |||
goog.require('goog.events'); | |||
goog.require('goog.math.Rect'); | |||
goog.require('goog.userAgent'); | |||
goog.require('goog.dom.animationFrame.polyfill'); |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
core/toolbox.js
Outdated
@@ -273,7 +296,10 @@ Blockly.Toolbox.prototype.getClientRect = function() { | |||
var x = toolboxRect.left; | |||
var y = toolboxRect.top; | |||
var width = this.getWidth(); | |||
var height = toolboxRect.height; | |||
// The height here is the combined height of the category menu and flyout. |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
core/toolbox.js
Outdated
@@ -286,7 +312,7 @@ Blockly.Toolbox.prototype.getClientRect = function() { | |||
return new goog.math.Rect(-BIG_NUM, -BIG_NUM, 2 * BIG_NUM, | |||
BIG_NUM + y + height); | |||
} else { // Bottom | |||
return new goog.math.Rect(0, y, 2 * BIG_NUM, BIG_NUM + width); | |||
return new goog.math.Rect(0, y - height, 2 * BIG_NUM, BIG_NUM); |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Three nits and you're good to go. I don't need to do another review--it's just a few missing annotations.
@@ -223,6 +223,31 @@ Blockly.FlyoutButton.prototype.getTargetWorkspace = function() { | |||
}; | |||
|
|||
/** | |||
* Get whether this button is a label at the top of a category. | |||
* @return {boolean} True if it is a category label. |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
core/flyout_button.js
Outdated
* Get the text of this button. | ||
* @return {string} The text on the button. | ||
*/ | ||
Blockly.FlyoutButton.prototype.getText = function() { |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
core/flyout_button.js
Outdated
|
||
/** | ||
* Get the position of this button. | ||
* @return {!goog.math.Coordinate} The button position. |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
Resolves
Resolves part of #1040
Proposed Changes
Concatenate all the blocks into a single flyout, with category labels, so that you can scroll continuously through them. When you select a category in the category menu, auto-scroll to that category.