encre_css/plugins/layout/overscroll_behavior/
mod.rs1#![doc = include_str!("README.md")]
2#![doc(alias = "layout")]
3use crate::prelude::build_plugin::*;
4
5#[derive(Debug)]
6pub(crate) struct PluginDefinition;
7
8impl Plugin for PluginDefinition {
9 fn can_handle(&self, context: ContextCanHandle) -> bool {
10 matches!(
11 context.modifier,
12 Modifier::Builtin {
13 value: "auto"
14 | "x-auto"
15 | "y-auto"
16 | "contain"
17 | "x-contain"
18 | "y-contain"
19 | "none"
20 | "x-none"
21 | "y-none",
22 ..
23 }
24 )
25 }
26
27 fn handle(&self, context: &mut ContextHandle) {
28 match context.modifier {
29 Modifier::Builtin { value, .. } => match *value {
30 "auto" => context.buffer.line("overscroll-behavior: auto;"),
31 "x-auto" => context.buffer.line("overscroll-behavior-x: auto;"),
32 "y-auto" => context.buffer.line("overscroll-behavior-y: auto;"),
33 "contain" => context.buffer.line("overscroll-behavior: contain;"),
34 "x-contain" => context.buffer.line("overscroll-behavior-x: contain;"),
35 "y-contain" => context.buffer.line("overscroll-behavior-y: contain;"),
36 "none" => context.buffer.line("overscroll-behavior: none;"),
37 "x-none" => context.buffer.line("overscroll-behavior-x: none;"),
38 "y-none" => context.buffer.line("overscroll-behavior-y: none;"),
39 _ => unreachable!(),
40 },
41 Modifier::Arbitrary { .. } => unreachable!(),
42 }
43 }
44}