Commit 1235c1e8 authored by Neil Fraser's avatar Neil Fraser

Fade out trashcan when closed.

parent cefb9385
This diff is collapsed.
......@@ -28,13 +28,13 @@ goog.addDependency("../../../" + dir + "/core/block.js", ['Blockly.Block'], ['Bl
goog.addDependency("../../../" + dir + "/core/block_svg.js", ['Blockly.BlockSvg'], ['goog.userAgent']);
goog.addDependency("../../../" + dir + "/core/blockly.js", ['Blockly'], ['Blockly.Block', 'Blockly.Connection', 'Blockly.FieldAngle', 'Blockly.FieldCheckbox', 'Blockly.FieldColour', 'Blockly.FieldDropdown', 'Blockly.FieldImage', 'Blockly.FieldTextInput', 'Blockly.FieldVariable', 'Blockly.Generator', 'Blockly.Msg', 'Blockly.Procedures', 'Blockly.Realtime', 'Blockly.Toolbox', 'Blockly.WidgetDiv', 'Blockly.Workspace', 'Blockly.inject', 'Blockly.utils', 'goog.color', 'goog.dom', 'goog.events', 'goog.string', 'goog.ui.ColorPicker', 'goog.ui.tree.TreeControl', 'goog.userAgent']);
goog.addDependency("../../../" + dir + "/core/blocks.js", ['Blockly.Blocks'], ['goog.asserts']);
goog.addDependency("../../../" + dir + "/core/bubble.js", ['Blockly.Bubble'], ['Blockly.Workspace']);
goog.addDependency("../../../" + dir + "/core/bubble.js", ['Blockly.Bubble'], ['Blockly.Workspace', 'goog.math']);
goog.addDependency("../../../" + dir + "/core/comment.js", ['Blockly.Comment'], ['Blockly.Bubble', 'Blockly.Icon', 'goog.userAgent']);
goog.addDependency("../../../" + dir + "/core/connection.js", ['Blockly.Connection', 'Blockly.ConnectionDB'], ['Blockly.Workspace']);
goog.addDependency("../../../" + dir + "/core/contextmenu.js", ['Blockly.ContextMenu'], ['goog.dom', 'goog.style', 'goog.ui.Menu', 'goog.ui.MenuItem']);
goog.addDependency("../../../" + dir + "/core/css.js", ['Blockly.Css'], ['goog.cssom']);
goog.addDependency("../../../" + dir + "/core/field.js", ['Blockly.Field'], ['Blockly.BlockSvg', 'goog.asserts', 'goog.userAgent']);
goog.addDependency("../../../" + dir + "/core/field_angle.js", ['Blockly.FieldAngle'], ['Blockly.FieldTextInput']);
goog.addDependency("../../../" + dir + "/core/field_angle.js", ['Blockly.FieldAngle'], ['Blockly.FieldTextInput', 'goog.math']);
goog.addDependency("../../../" + dir + "/core/field_checkbox.js", ['Blockly.FieldCheckbox'], ['Blockly.Field']);
goog.addDependency("../../../" + dir + "/core/field_colour.js", ['Blockly.FieldColour'], ['Blockly.Field', 'goog.ui.ColorPicker']);
goog.addDependency("../../../" + dir + "/core/field_dropdown.js", ['Blockly.FieldDropdown'], ['Blockly.Field', 'goog.dom', 'goog.style', 'goog.ui.Menu', 'goog.ui.MenuItem', 'goog.userAgent']);
......@@ -56,12 +56,12 @@ goog.addDependency("../../../" + dir + "/core/realtime.js", ['Blockly.Realtime']
goog.addDependency("../../../" + dir + "/core/scrollbar.js", ['Blockly.Scrollbar', 'Blockly.ScrollbarPair'], ['goog.userAgent']);
goog.addDependency("../../../" + dir + "/core/toolbox.js", ['Blockly.Toolbox'], ['Blockly.Flyout', 'goog.events.BrowserFeature', 'goog.html.SafeHtml', 'goog.style', 'goog.ui.tree.TreeControl', 'goog.ui.tree.TreeNode']);
goog.addDependency("../../../" + dir + "/core/tooltip.js", ['Blockly.Tooltip'], []);
goog.addDependency("../../../" + dir + "/core/trashcan.js", ['Blockly.Trashcan'], ['goog.Timer']);
goog.addDependency("../../../" + dir + "/core/trashcan.js", ['Blockly.Trashcan'], ['goog.math', 'goog.Timer']);
goog.addDependency("../../../" + dir + "/core/utils.js", ['Blockly.utils'], []);
goog.addDependency("../../../" + dir + "/core/variables.js", ['Blockly.Variables'], ['Blockly.Toolbox', 'Blockly.Workspace']);
goog.addDependency("../../../" + dir + "/core/warning.js", ['Blockly.Warning'], ['Blockly.Bubble', 'Blockly.Icon']);
goog.addDependency("../../../" + dir + "/core/widgetdiv.js", ['Blockly.WidgetDiv'], ['Blockly.Css', 'goog.dom']);
goog.addDependency("../../../" + dir + "/core/workspace.js", ['Blockly.Workspace'], ['Blockly.ScrollbarPair', 'Blockly.Trashcan', 'Blockly.Xml']);
goog.addDependency("../../../" + dir + "/core/workspace.js", ['Blockly.Workspace'], ['Blockly.ScrollbarPair', 'Blockly.Trashcan', 'Blockly.Xml', 'goog.math']);
goog.addDependency("../../../" + dir + "/core/xml.js", ['Blockly.Xml'], []);
goog.addDependency("../../alltests.js", [], []);
goog.addDependency("base.js", [], []);
......
......@@ -27,6 +27,7 @@
goog.provide('Blockly.Bubble');
goog.require('Blockly.Workspace');
goog.require('goog.math');
/**
......@@ -48,7 +49,7 @@ Blockly.Bubble = function(workspace, content, shape,
if (Blockly.RTL) {
angle = -angle;
}
this.arrow_radians_ = angle / 360 * Math.PI * 2;
this.arrow_radians_ = goog.math.toRadians(angle);
this.workspace_ = workspace;
this.content_ = content;
......
......@@ -27,6 +27,7 @@
goog.provide('Blockly.FieldAngle');
goog.require('Blockly.FieldTextInput');
goog.require('goog.math');
/**
......@@ -182,7 +183,7 @@ Blockly.FieldAngle.prototype.onMouseMove = function(e) {
// This shouldn't happen, but let's not let this error propogate further.
return;
}
angle = angle / Math.PI * 180;
angle = goog.math.toDegrees(angle);
// 0: East, 90: North, 180: West, 270: South.
if (dx < 0) {
angle += 180;
......@@ -227,7 +228,7 @@ Blockly.FieldAngle.prototype.updateGraph_ = function() {
if (!this.gauge_) {
return;
}
var angleRadians = Number(this.getText()) / 180 * Math.PI;
var angleRadians = goog.math.toRadians(Number(this.getText()));
if (isNaN(angleRadians)) {
this.gauge_.setAttribute('d',
'M ' + Blockly.FieldAngle.HALF + ', ' + Blockly.FieldAngle.HALF);
......
......@@ -26,6 +26,7 @@
goog.provide('Blockly.Trashcan');
goog.require('goog.math');
goog.require('goog.Timer');
......@@ -122,11 +123,11 @@ Blockly.Trashcan.prototype.svgLid_ = null;
Blockly.Trashcan.prototype.lidTask_ = 0;
/**
* Current angle of the lid.
* Current state of lid opening (0.0 = closed, 1.0 = open).
* @type {number}
* @private
*/
Blockly.Trashcan.prototype.lidAngle_ = 0;
Blockly.Trashcan.prototype.lidOpen_ = 0;
/**
* Left coordinate of the trash can.
......@@ -186,6 +187,7 @@ Blockly.Trashcan.prototype.createDom = function() {
this.svgLid_.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href',
Blockly.pathToMedia + Blockly.SPRITE.url);
this.animateLid_();
return this.svgGroup_;
};
......@@ -283,14 +285,17 @@ Blockly.Trashcan.prototype.setOpen_ = function(state) {
* @private
*/
Blockly.Trashcan.prototype.animateLid_ = function() {
this.lidAngle_ += this.isOpen ? 10 : -10;
this.lidAngle_ = Math.max(0, this.lidAngle_);
this.lidOpen_ += this.isOpen ? 0.2 : -0.2;
this.lidOpen_ = goog.math.clamp(this.lidOpen_, 0, 1);
var lidAngle = this.lidOpen_ * 45;
this.svgLid_.setAttribute('transform', 'rotate(' +
(Blockly.RTL ? -this.lidAngle_ : this.lidAngle_) + ', ' +
(Blockly.RTL ? -lidAngle : lidAngle) + ', ' +
(Blockly.RTL ? 4 : this.WIDTH_ - 4) + ', ' +
(this.LID_HEIGHT_ - 2) + ')');
if (this.isOpen ? (this.lidAngle_ < 45) : (this.lidAngle_ > 0)) {
this.lidTask_ = goog.Timer.callOnce(this.animateLid_, 5, this);
var opacity = goog.math.lerp(0.2, 0.4, this.lidOpen_);
this.svgGroup_.style.opacity = opacity;
if (this.lidOpen_ > 0 || this.lidOpen_ < 1) {
this.lidTask_ = goog.Timer.callOnce(this.animateLid_, 20, this);
}
};
......
......@@ -31,6 +31,7 @@ goog.provide('Blockly.Workspace');
goog.require('Blockly.ScrollbarPair');
goog.require('Blockly.Trashcan');
goog.require('Blockly.Xml');
goog.require('goog.math');
/**
......@@ -211,7 +212,7 @@ Blockly.Workspace.prototype.getTopBlocks = function(ordered) {
// Copy the topBlocks_ list.
var blocks = [].concat(this.topBlocks_);
if (ordered && blocks.length > 1) {
var offset = Math.sin(Blockly.Workspace.SCAN_ANGLE / 180 * Math.PI);
var offset = Math.sin(goog.math.toRadians(Blockly.Workspace.SCAN_ANGLE));
if (Blockly.RTL) {
offset *= -1;
}
......
media/sprites.png

2.37 KB | W: | H:

media/sprites.png

1.02 KB | W: | H:

media/sprites.png
media/sprites.png
media/sprites.png
media/sprites.png
  • 2-up
  • Swipe
  • Onion skin
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment