Fix docstrings and add horizontal scrolling.

This commit is contained in:
Rachel Fenichel 2016-05-13 15:30:47 -07:00
parent cb4e9cd737
commit 65aceaa1dc
2 changed files with 36 additions and 24 deletions

View file

@ -216,7 +216,7 @@ Blockly.Flyout.prototype.dispose = function() {
/**
* Get the width of the flyout.
* @return {number} the width of the flyout.
* @return {number} The width of the flyout.
*/
Blockly.Flyout.prototype.getWidth = function() {
return this.width_;
@ -224,7 +224,7 @@ Blockly.Flyout.prototype.getWidth = function() {
/**
* Get the height of the flyout.
* @return {number} the width of the flyout.
* @return {number} The width of the flyout.
*/
Blockly.Flyout.prototype.getHeight = function() {
return this.height_;
@ -475,24 +475,36 @@ Blockly.Flyout.prototype.scrollToStart = function() {
Blockly.Flyout.prototype.wheel_ = function(e) {
// Don't scroll sideways.
if (this.horizontalLayout_) {
return;
}
var delta = e.deltaY;
if (delta) {
if (goog.userAgent.GECKO) {
// Firefox's deltas are a tenth that of Chrome/Safari.
delta *= 10;
var delta = e.deltaX;
if (delta) {
if (goog.userAgent.GECKO) {
// Firefox's deltas are a tenth that of Chrome/Safari.
delta *= 10;
}
var metrics = this.getMetrics_();
var x = metrics.viewLeft + delta;
x = Math.min(x, metrics.contentWidth - metrics.viewWidth);
x = Math.max(x, 0);
this.scrollbar_.set(x);
}
} else {
var delta = e.deltaY;
if (delta) {
if (goog.userAgent.GECKO) {
// Firefox's deltas are a tenth that of Chrome/Safari.
delta *= 10;
}
var metrics = this.getMetrics_();
var y = metrics.viewTop + delta;
y = Math.min(y, metrics.contentHeight - metrics.viewHeight);
y = Math.max(y, 0);
this.scrollbar_.set(y);
}
var metrics = this.getMetrics_();
var y = metrics.viewTop + delta;
y = Math.min(y, metrics.contentHeight - metrics.viewHeight);
y = Math.max(y, 0);
this.scrollbar_.set(y);
// Don't scroll the page.
e.preventDefault();
// Don't propagate mousewheel event (zooming).
e.stopPropagation();
}
// Don't scroll the page.
e.preventDefault();
// Don't propagate mousewheel event (zooming).
e.stopPropagation();
};
/**

View file

@ -106,9 +106,9 @@ Blockly.Toolbox = function(workspace) {
' blocklyHorizontalTreeRtl' : ' blocklyHorizontalTree');
this.treeSeparatorConfig_['cssTreeRow'] =
'blocklyTreeSeparatorHorizontal' +
'blocklyTreeSeparatorHorizontal ' +
(workspace.RTL ?
' blocklyHorizontalTreeRtl' : ' blocklyHorizontalTree');
'blocklyHorizontalTreeRtl' : 'blocklyHorizontalTree');
this.config_['cssTreeIcon'] = '';
}
};
@ -204,7 +204,7 @@ Blockly.Toolbox.prototype.dispose = function() {
/**
* Get the width of the toolbox.
* @return {number} the width of the toolbox.
* @return {number} The width of the toolbox.
*/
Blockly.Toolbox.prototype.getWidth = function() {
return this.width;
@ -212,7 +212,7 @@ Blockly.Toolbox.prototype.getWidth = function() {
/**
* Get the height of the toolbox.
* @return {number} the width of the toolbox.
* @return {number} The width of the toolbox.
*/
Blockly.Toolbox.prototype.getHeight = function() {
return this.height;
@ -245,7 +245,7 @@ Blockly.Toolbox.prototype.position = function() {
if (this.toolboxPosition == Blockly.TOOLBOX_AT_RIGHT) { // Right
treeDiv.style.left =
(svgPosition.x + svgSize.width - treeDiv.offsetWidth) + 'px';
} else { // Left
} else { // Left
treeDiv.style.left = svgPosition.x + 'px';
}
treeDiv.style.height = svgSize.height + 'px';
@ -411,7 +411,7 @@ Blockly.Toolbox.prototype.getClientRect = function() {
} else if (this.toolboxPosition == Blockly.TOOLBOX_AT_TOP) {
return new goog.math.Rect(-BIG_NUM, -BIG_NUM, 2 * BIG_NUM,
BIG_NUM + y + height);
} else { // Bottom
} else { // Bottom
return new goog.math.Rect(0, y, 2 * BIG_NUM, BIG_NUM + width);
}
};