Skip to content

Commit

Permalink
Use an EVENT for the when changed block
Browse files Browse the repository at this point in the history
  • Loading branch information
GarboMuffin committed Aug 26, 2023
1 parent 7159930 commit 6365c24
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions extensions/veggiecan/browserfullscreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@
"use strict";
const icon =
"data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHdpZHRoPSI2My4yNjc0MiIgaGVpZ2h0PSI2My4xODQ5NSIgdmlld0JveD0iMCwwLDYzLjI2NzQyLDYzLjE4NDk1Ij48ZyB0cmFuc2Zvcm09InRyYW5zbGF0ZSgtMjA4LjM2NjI5LC0xNDguNDA3NTMpIj48ZyBkYXRhLXBhcGVyLWRhdGE9InsmcXVvdDtpc1BhaW50aW5nTGF5ZXImcXVvdDs6dHJ1ZX0iIGZpbGwtcnVsZT0ibm9uemVybyIgc3Ryb2tlLWxpbmVjYXA9ImJ1dHQiIHN0cm9rZS1saW5lam9pbj0ibWl0ZXIiIHN0cm9rZS1taXRlcmxpbWl0PSIxMCIgc3Ryb2tlLWRhc2hhcnJheT0iIiBzdHJva2UtZGFzaG9mZnNldD0iMCIgc3R5bGU9Im1peC1ibGVuZC1tb2RlOiBub3JtYWwiPjxwYXRoIGQ9IiIgZmlsbD0iI2ZmZDI0ZCIgc3Ryb2tlPSJub25lIiBzdHJva2Utd2lkdGg9IjAuNSIvPjxwYXRoIGQ9IiIgZmlsbD0iIzAxMDEwMCIgc3Ryb2tlPSJub25lIiBzdHJva2Utd2lkdGg9IjAuNSIvPjxwYXRoIGQ9IiIgZmlsbD0iIzAxMDEwMCIgc3Ryb2tlPSJub25lIiBzdHJva2Utd2lkdGg9IjAuNSIvPjxwYXRoIGQ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Tg3LDMwLjU0Nzk3eiIvPjxwYXRoIGQ9Ik0yNTguMTI3ODQsMTkyLjk2MTIybC0zNS4yMjk0OSwtMjUuMjk0NjZsMC45NzI4OCwtMS4zNTQ5OWwzNS4yMjk0OSwyNS4yOTQ2NnoiLz48cGF0aCBkPSJNMjI1LjM4ODcsMTYyLjM1NzIxYzAsMCAtMi42NzQ1NCwzLjQzOTM1IC0zLjcxMjYsNC43NzQyNWMtMC43NDk4NywwLjk2NDMgLTEuMjg3MzQsMS4zMDg5MSAtMS4yODczNCwxLjMwODkxbDEuMjA1MjksLTYuOTQ4OTZ6Ii8+PHBhdGggZD0iTTI1Ni4wOTcxMiwxOTUuNDE3NDFjMCwwIDMuMTk3ODMsLTIuOTU5MDkgNC40Mzg5OSwtNC4xMDc1OWMwLjg5NjU5LC0wLjgyOTY1IDEuNDgyOSwtMS4wODIzNSAxLjQ4MjksLTEuMDgyMzVsLTIuMzE4MzQsNi42NjA3OXoiLz48cGF0aCBkPSJNMjI1LjAzMDcxLDE5NS40MTMwN2MwLDAgMy42NDk1NiwyLjM3OTcxIDUuMDY2MDQsMy4zMDMzNGMxLjAyMzI0LDAuNjY3MjEgMS40MTEyOSwxLjE3NDIgMS40MTEyOSwxLjE3NDJsLTcuMDI1MDUsLTAuNjI0MXoiLz48L2c+PC9nPjxwYXRoIGQ9Ik0yMzIuOTYyNDgsMTgxLjk4NjUxbDcuMTQ2NjYsLTEwLjgyODAzbDEwLjY3MzM2LDcuMDQ0NTdsLTcuMTQ2NjYsMTAuODI4MDN6IiBmaWxsPSIjZmZkMjRkIiBzdHJva2U9Im5vbmUiLz48L2c+PC9nPjwvZz48L3N2Zz4=";
class fullscreen {

window.addEventListener("fullscreenchange", () => {
Scratch.vm.runtime.startHats("fullscreen0419_whenfullscreen", {
ENABLED: document.fullscreenElement === null ? 'exited' : 'entered'
});
});

class FullscreenExtension {
getInfo() {
return {
id: "fullscreen0419",
Expand Down Expand Up @@ -37,13 +44,13 @@
},
{
opcode: "whenfullscreen",
blockType: Scratch.BlockType.HAT,
text: "when browser fullscreen [ACTION]",
blockType: Scratch.BlockType.EVENT,
text: "when browser fullscreen [ENABLED]",
isEdgeActivated: false,
arguments: {
ACTION: {
ENABLED: {
type: Scratch.ArgumentType.STRING,
menu: "whenfullscreenMenu",
defaultValue: "entered",
menu: "whenfullscreenMenu"
},
},
},
Expand All @@ -63,7 +70,8 @@
],
},
whenfullscreenMenu: {
acceptReporters: true,
// Used for startHats filtering.
acceptReporters: false,
items: [
{
text: "entered",
Expand All @@ -89,14 +97,7 @@
isInFullscreen() {
return document.fullscreenElement !== null;
}
whenfullscreen(args) {
const action = args.ACTION;
if (action === "entered") {
return document.fullscreenElement !== null;
} else if (action === "exited") {
return document.fullscreenElement == null;
}
}
}
Scratch.extensions.register(new fullscreen());

Scratch.extensions.register(new FullscreenExtension());
})(Scratch);

0 comments on commit 6365c24

Please sign in to comment.