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

New extension: Wheel Scroll #1122

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
e118966
Add files via upload
DDen4ik-12 Oct 31, 2023
a874feb
Update and rename extensions/WheelScroll.js to extensions/Den4ik-12/W…
DDen4ik-12 Oct 31, 2023
d108219
Add files via upload
DDen4ik-12 Oct 31, 2023
bce99a3
Rename images/WheelScroll.svg to images/Den4ik-12/WheelScroll.svg
DDen4ik-12 Oct 31, 2023
6060528
Update README.md
DDen4ik-12 Oct 31, 2023
8140831
Update README.md
DDen4ik-12 Oct 31, 2023
d3ca196
Update extensions.json
DDen4ik-12 Oct 31, 2023
5e9cfea
Update extensions.json
DDen4ik-12 Oct 31, 2023
d7af452
Update WheelScroll.js
DDen4ik-12 Nov 1, 2023
766d45c
Update WheelScroll.js
DDen4ik-12 Nov 1, 2023
21b83db
Update WheelScroll.js
DDen4ik-12 Nov 1, 2023
00ac744
Update WheelScroll.js to attempt to fix a problem in job "format"
DDen4ik-12 Nov 1, 2023
2279f37
Update WheelScroll.js with changing the wrong "whell" to the correct …
DDen4ik-12 Nov 1, 2023
bf3f1c8
Update WheelScroll.js
DDen4ik-12 Nov 1, 2023
ebbf918
Update extensions.json to resolve the conflict
DDen4ik-12 Nov 13, 2023
2d27cf3
Merge branch 'master' into master
DDen4ik-12 Nov 14, 2023
8c7620d
Deleting unnecessary comments
DDen4ik-12 Nov 19, 2023
2f50eac
Fix "lint" errors | Attempt 1
DDen4ik-12 Nov 19, 2023
b74cc68
Fix errors | Attempt 2
DDen4ik-12 Nov 19, 2023
3e3d803
Fix errors | Attempt 3
DDen4ik-12 Nov 19, 2023
6d2a51c
Merge branch 'TurboWarp:master' into master
DDen4ik-12 Dec 8, 2023
6abaadf
Update WheelScroll.js
DDen4ik-12 Dec 8, 2023
380e47c
Merge branch 'TurboWarp:master' into master
DDen4ik-12 Feb 24, 2024
97a7947
Merge branch 'TurboWarp:master' into master
DDen4ik-12 Feb 25, 2024
0e4c8b7
Extension Update 1.1!
DDen4ik-12 Jul 14, 2024
40a0968
Merge branch 'master' into master
DDen4ik-12 Jul 14, 2024
6eef9cb
Fix errors | Attempt 1
DDen4ik-12 Jul 14, 2024
a8e67b2
Small update
DDen4ik-12 Jul 14, 2024
b2b7314
Merge branch 'master' into pr/DDen4ik-12/1122
CubesterYT Jul 16, 2024
281a368
Fixes and Translation Functions
CubesterYT Jul 16, 2024
1ade5f9
Added license
DDen4ik-12 Jul 16, 2024
501b791
Update WheelScroll.js
DDen4ik-12 Jul 18, 2024
316c1a1
Merge branch 'TurboWarp:master' into master
DDen4ik-12 Jul 19, 2024
d0a66d7
Scratch account link change
DDen4ik-12 Jul 19, 2024
9b41f52
Update 1.2
DDen4ik-12 Jul 26, 2024
129ffeb
Merge branch 'TurboWarp:master' into master
DDen4ik-12 Jul 26, 2024
89f465b
Merge branch 'TurboWarp:master' into master
DDen4ik-12 Aug 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
245 changes: 245 additions & 0 deletions extensions/Den4ik-12/WheelScroll.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
// Name: Wheel Scroll
// ID: Den4ik12WheelScroll
// Description: Blocks for detecting mouse wheel scrolling.
// By: Den4ik-12 <https://scratch.mit.edu/users/Den4ik-12-Eng/>
// License: MPL-2.0

(function (Scratch) {
"use strict";

if (!Scratch.extensions.unsandboxed) {
throw new Error(
'Wheel Scroll:\nExtension "Wheel Scroll" must run unsandboxed!\nPlease enable the unsandboxed mode when loading the extension.'
);
}

const extIcon =
"data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5z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.vm;
const runtime = vm.runtime;
let isScrolled = false;
let deltaX = "";
let deltaY = "";
let deltaZ = "";
let deltaMode = "";

class WheelScroll {
constructor() {
runtime.on("AFTER_EXECUTE", () => {
isScrolled = false;
deltaX = "";
deltaY = "";
deltaZ = "";
deltaMode = "";
});

const startWhenScrollEvent = (dir, e) => {
let threads;
if (dir === "") {
threads = runtime.startHats("Den4ik12WheelScroll_whenScroll");
} else {
threads = runtime.startHats("Den4ik12WheelScroll_whenScrollDir", {
SCROLL_TYPE: dir,
});
}
threads.forEach((thread) => {
thread.Den4ik12WheelScroll.deltaX = e.deltaX;
thread.Den4ik12WheelScroll.deltaY = e.deltaY;
thread.Den4ik12WheelScroll.deltaZ = e.deltaZ;
switch (e.deltaMode) {
case 0: {
thread.Den4ik12WheelScroll.deltaMode = "px";
break;
}
case 1: {
thread.Den4ik12WheelScroll.deltaMode = "lines";
break;
}
case 2: {
thread.Den4ik12WheelScroll.deltaMode = "pages";
break;
}
}
});
};

document.body.addEventListener(
"wheel",
(e) => {
isScrolled = true;
deltaX = e.deltaX;
deltaY = e.deltaY;
deltaZ = e.deltaZ;
switch (e.deltaMode) {
case 0: {
deltaMode = "px";
break;
}
case 1: {
deltaMode = "lines";
break;
}
case 2: {
deltaMode = "pages";
break;
}
}

startWhenScrollEvent("", e);
if (e.deltaZ != 0) startWhenScrollEvent("az", e);
if (e.deltaY != 0) startWhenScrollEvent("ay", e);
if (e.deltaX != 0) startWhenScrollEvent("ax", e);
if (e.deltaZ > 0) startWhenScrollEvent("i", e);
if (e.deltaZ < 0) startWhenScrollEvent("o", e);
if (e.deltaY > 0) startWhenScrollEvent("d", e);
if (e.deltaY < 0) startWhenScrollEvent("u", e);
if (e.deltaX > 0) startWhenScrollEvent("r", e);
if (e.deltaX < 0) startWhenScrollEvent("l", e);
},
{ passive: true }
);
}
getInfo() {
return {
id: "Den4ik12WheelScroll",
name: Scratch.translate("Wheel Scroll"),
color1: "#E74C3C",
color2: "#CB4335",
color3: "#B03A2E",
menuIconURI: extIcon,
blockIconURI: blockIcon,
blocks: [
{
blockType: Scratch.BlockType.XML,
xml: "<sep gap='6'/><label text='Note: Most computer mouses do not'/><sep gap='-12'/><label text='have the ability to scroll along the x'/><sep gap='-12'/><label text='and z axes.'/><sep gap='24'/>",
},
{
opcode: "whenScrollDir",
text: Scratch.translate("when mouse wheel scrolled [SCROLL_TYPE]"),
blockType: Scratch.BlockType.EVENT,
isEdgeActivated: false,
arguments: {
SCROLL_TYPE: {
menu: "SCROLL_TYPE",
defaultValue: "u",
},
},
},
{
opcode: "whenScroll",
text: Scratch.translate("when mouse wheel scrolled"),
blockType: Scratch.BlockType.EVENT,
isEdgeActivated: false,
},
{
opcode: "isScrolled",
text: Scratch.translate("mouse wheel scrolled?"),
blockType: Scratch.BlockType.BOOLEAN,
},
{
opcode: "getDelta",
text: Scratch.translate("scroll delta [DELTA_TYPE]"),
blockType: Scratch.BlockType.REPORTER,
disableMonitor: true,
arguments: {
DELTA_TYPE: {
menu: "DELTA_TYPE",
defaultValue: "y",
},
},
},
],
menus: {
SCROLL_TYPE: {
items: [
{
text: Scratch.translate("up"),
value: "u",
},
{
text: Scratch.translate("down"),
value: "d",
},
{
text: Scratch.translate("to the left"),
value: "l",
},
{
text: Scratch.translate("to the right"),
value: "r",
},
{
text: Scratch.translate("out"),
value: "o",
},
{
text: Scratch.translate("in"),
value: "i",
},
{
text: Scratch.translate("along the x-axis"),
value: "ax",
},
{
text: Scratch.translate("along the y-axis"),
value: "ay",
},
{
text: Scratch.translate("along the z-axis"),
value: "az",
},
],
},
DELTA_TYPE: {
acceptReporters: true,
items: [
"x",
"y",
"z",
{ text: Scratch.translate("mode"), value: "mode" },
],
},
},
};
}
isScrolled() {
return isScrolled;
}
getDelta(args, util) {
let result;
switch (args.DELTA_TYPE) {
case "x": {
result = util.thread?.Den4ik12WheelScroll?.deltaX
? util.thread.Den4ik12WheelScroll.deltaX
: deltaX;
break;
}
case "y": {
result = util.thread?.Den4ik12WheelScroll?.deltaY
? util.thread.Den4ik12WheelScroll.deltaY
: deltaY;
break;
}
case "z": {
result = util.thread?.Den4ik12WheelScroll?.deltaZ
? util.thread.Den4ik12WheelScroll.deltaZ
: deltaZ;
break;
}
case "mode": {
result = util.thread?.Den4ik12WheelScroll?.deltaMode
? util.thread.Den4ik12WheelScroll.deltaMode
: deltaMode;
break;
}
default: {
return "";
}
}
return result ? result : "";
}
}
Scratch.extensions.register(new WheelScroll());
})(Scratch);
1 change: 1 addition & 0 deletions extensions/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
"vercte/dictionaries",
"godslayerakp/http",
"godslayerakp/ws",
"Den4ik-12/WheelScroll",
"Lily/CommentBlocks",
"veggiecan/LongmanDictionary",
"CubesterYT/TurboHook",
Expand Down
Loading