From 65aceaa1dcd75a474937ac40ea3f7f886a5249dc Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Fri, 13 May 2016 15:30:47 -0700 Subject: [PATCH] Fix docstrings and add horizontal scrolling. --- core/flyout.js | 48 ++++++++++++++++++++++++++++++------------------ core/toolbox.js | 12 ++++++------ 2 files changed, 36 insertions(+), 24 deletions(-) diff --git a/core/flyout.js b/core/flyout.js index f980ce197..dbd629514 100644 --- a/core/flyout.js +++ b/core/flyout.js @@ -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(); }; /** diff --git a/core/toolbox.js b/core/toolbox.js index 129ca73f1..d89d06fde 100644 --- a/core/toolbox.js +++ b/core/toolbox.js @@ -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); } };