diff --git a/demo_markdown/docs/drawer/mod.md b/demo_markdown/docs/drawer/mod.md
index 3594d798..234fd4e9 100644
--- a/demo_markdown/docs/drawer/mod.md
+++ b/demo_markdown/docs/drawer/mod.md
@@ -39,12 +39,27 @@ view! {
}
```
+### Scroll content
+
+```rust demo
+let show = create_rw_signal(false);
+
+view! {
+
+
+ r#"This being said, the world is moving in the direction opposite to Clarke's predictions. In 2001: A Space Odyssey, in the year of 2001, which has already passed, human beings have built magnificent cities in space, and established permanent colonies on the moon, and huge nuclear-powered spacecraft have sailed to Saturn. However, today, in 2018, the walk on the moon has become a distant memory.And the farthest reach of our manned space flights is just as long as the two-hour mileage of a high-speed train passing through my city. At the same time, information technology is developing at an unimaginable speed. With the entire world covered by the Internet, people have gradually lost their interest in space, as they find themselves increasingly comfortable in the space created by IT. Instead of an exploration of the real space, which is full of real difficulties, people now just prefer to experience virtual space through VR. Just like someone said, "You promised me an ocean of stars, but you actually gave me Facebook.""#
+
+}
+```
+
### Drawer Props
| Name | Type | Default | Desciption |
| --- | --- | --- | --- |
| class | `OptionalProp>` | `Default::default()` | Addtional classes for the drawer element. |
| show | `Model` | | Whether to show drawer. |
+| mask_closeable | `MaybeSignal` | `true` | Whether to emit hide event when click mask. |
+| close_on_esc | `bool` | `true` | Whether to close drawer on Esc is pressed. |
| title | `OptionalProp>` | `Default::default()` | Drawer title. |
| placement | `MaybeSignal` | `DrawerPlacement::Right` | Drawer placement. |
| width | `MaybeSignal` | `520px` | Drawer width. |
diff --git a/thaw/src/drawer/drawer.css b/thaw/src/drawer/drawer.css
index a1403e5c..e3fb15ea 100644
--- a/thaw/src/drawer/drawer.css
+++ b/thaw/src/drawer/drawer.css
@@ -37,7 +37,8 @@
.thaw-drawer > .thaw-card > .thaw-card__content {
flex: 1;
- padding: 20px 28px;
+ padding: 0;
+ overflow: hidden;
}
.thaw-drawer--placement-top {
diff --git a/thaw/src/drawer/mod.rs b/thaw/src/drawer/mod.rs
index dcc4c7f3..fa33ebea 100644
--- a/thaw/src/drawer/mod.rs
+++ b/thaw/src/drawer/mod.rs
@@ -1,11 +1,13 @@
-use crate::Card;
+use crate::{Card, Scrollbar};
use leptos::*;
-use thaw_components::{CSSTransition, Teleport};
+use thaw_components::{CSSTransition, FocusTrap, Teleport};
use thaw_utils::{class_list, mount_style, use_lock_html_scroll, Model, OptionalProp};
#[component]
pub fn Drawer(
#[prop(into)] show: Model,
+ #[prop(default = true.into(), into)] mask_closeable: MaybeSignal,
+ #[prop(default = true, into)] close_on_esc: bool,
#[prop(optional, into)] title: OptionalProp>,
#[prop(optional, into)] placement: MaybeSignal,
#[prop(default = MaybeSignal::Static("520px".to_string()), into)] width: MaybeSignal,
@@ -29,6 +31,8 @@ pub fn Drawer(
#[component]
fn DrawerInnr(
show: Model,
+ mask_closeable: MaybeSignal,
+ close_on_esc: bool,
title: OptionalProp>,
placement: MaybeSignal,
class: OptionalProp>,
@@ -57,7 +61,8 @@ pub fn Drawer(
let is_lock = RwSignal::new(show.get_untracked());
Effect::new(move |_| {
- if show.get() {
+ let is_show = show.get();
+ if is_show {
is_lock.set(true);
is_css_transition.set(true);
}
@@ -68,55 +73,72 @@ pub fn Drawer(
is_css_transition.set(false);
};
+ let on_mask_click = move |_| {
+ if mask_closeable.get_untracked() {
+ show.set(false);
+ }
+ };
+ let on_esc = Callback::new(move |_: ev::KeyboardEvent| {
+ show.set(false);
+ });
+
view! {
-