Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
orbclient
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
8
Issues
8
List
Boards
Labels
Service Desk
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
redox-os
orbclient
Commits
d06563ce
Commit
d06563ce
authored
Feb 02, 2021
by
Florian Blasius
🤘
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add web scroll event
parent
3cce14e4
Pipeline
#9063
passed with stage
in 3 minutes and 3 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
1 deletion
+40
-1
Cargo.toml
Cargo.toml
+20
-1
src/sys/web.rs
src/sys/web.rs
+20
-0
No files found.
Cargo.toml
View file @
d06563ce
...
...
@@ -29,7 +29,26 @@ redox_syscall = { version = "0.2.1" }
[target.'cfg(target_arch
=
"wasm32"
)
'.dependencies]
wasm-bindgen
=
"0.2.69"
# js-sys = "0.3"
web-sys
=
{
version
=
"0.3"
,
features
=
[
"Node"
,
"Element"
,
"console"
,
"CanvasRenderingContext2d"
,
"Document"
,
"Element"
,
"ImageData"
,
"HtmlCanvasElement"
,
"HtmlElement"
,
"Window"
,
"CssStyleDeclaration"
,
"MouseEvent"
,
"KeyboardEvent"
,
"DomRect"
]
}
[target.'cfg(target_arch
=
"wasm32"
)
'.dependencies.web-sys]
version
=
"0.3"
features
=
[
"Node"
,
"Element"
,
"console"
,
"CanvasRenderingContext2d"
,
"Document"
,
"Element"
,
"ImageData"
,
"HtmlCanvasElement"
,
"HtmlElement"
,
"Window"
,
"CssStyleDeclaration"
,
"MouseEvent"
,
"KeyboardEvent"
,
"WheelEvent"
,
"DomRect"
]
[features]
default
=
["bundled"]
...
...
src/sys/web.rs
View file @
d06563ce
...
...
@@ -273,6 +273,26 @@ impl Window {
closure
.forget
();
}
// wheel (scroll)
{
let
events
=
events
.clone
();
let
closure
=
Closure
::
wrap
(
Box
::
new
(
move
|
e
:
web_sys
::
WheelEvent
|
{
events
.borrow_mut
()
.push
(
ScrollEvent
{
x
:
e
.delta_x
()
as
i32
,
y
:
e
.delta_y
()
as
i32
,
}
.to_event
(),
)
})
as
Box
<
dyn
FnMut
(
_
)
>
);
document
()
.unwrap
()
.add_event_listener_with_callback
(
"wheel"
,
closure
.as_ref
()
.unchecked_ref
())
.unwrap
();
closure
.forget
();
}
if
let
Ok
(
context
)
=
context_2d
(
&
canvas
)
{
return
Some
(
Window
{
x
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment