Skip to content
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

Added empty trashcan function. #3675

Merged
merged 3 commits into from
Feb 10, 2020

Conversation

BeksOmega
Copy link
Collaborator

The basics

  • I branched from develop
  • My pull request is against develop
  • My code follows the style guide

The details

Resolves

Closes #3666

Proposed Changes

First commit adds constants to the trashcan's animation. I've been wanting to do this for a while so I just tacked it onto this PR. If you guys don't like it I'm totally cool with removing it.

Second commit adds an emptyContents function and a contentsIsOpen function.

  • emptyContents: Clears the trashcan's contents. Sets the lid's minOpenness to 0. And hides the flyout.
  • contentsIsOpen: returns if the trashcan flyout is currently open.

I figured people might want to check if the flyout is open before emptying it.

Reason for Changes

  1. I like constants.
  2. Might be useful when you're creating an application that uses levels? And it adds a harmless bit of flexibility for developers.

Test Coverage

  1. Imported the following xml to the playground:
<xml xmlns="https://developers.google.com/blockly/xml">
  <block type="controls_if"></block>
  <block type="controls_if">
    <statement name="DO0">
      <block type="controls_if"></block>
    </statement>
  </block>
  <block type="controls_if">
    <statement name="DO0">
      <block type="controls_if">
        <statement name="DO0">
          <block type="controls_if"></block>
        </statement>
      </block>
    </statement>
  </block>
</xml>
  1. Deleted all of the blocks.
  2. Opened the trashcan.
  3. Ran the following code in the console:
Blockly.mainWorkspace.trashcan.emptyContents()
  1. Observed how the flyout and lid closed.
  2. Attempted to open the trashcan, and observed how it was not possible.
  3. Imported the following xml:
<xml xmlns="https://developers.google.com/blockly/xml">
  <block type="controls_repeat_ext">
    <value name="TIMES">
      <shadow type="math_number">
        <field name="NUM">0</field>
      </shadow>
    </value>
  </block>
</xml>
  1. Deleted the block.
  2. Opened the trashcan.
  3. Observed how the trashcan did not contain any of the blocks from before it was emptied.

And the lid animation is exactly the same.
Develop:
OldAnim

This branch:
NewAnim

Tested on:

  • Desktop Chrome

Documentation

Noupers

Additional Information

N/A

@rachel-fenichel
Copy link
Collaborator

Sorry for the delay!

This looks good and I like the constants. However, I'd like them to be private, and then reassess if we're getting requests to be able to change them.

@rachel-fenichel rachel-fenichel merged commit d2ef7f1 into google:develop Feb 10, 2020
@BeksOmega BeksOmega deleted the feat/empty-trashcan branch May 13, 2021 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants