ladybird/Tests/LibWeb/Ref/position-sticky-right.html
Aliaksandr Kalenik 30b636e90b
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-22.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-22.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-22.04, Linux, Linux-x86_64) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
LibWeb: Add "position: sticky" support
Sticky positioning is implemented by modifying the algorithm for
assigning and refreshing scroll frames. Now, elements with
"position: sticky" are assigned their own scroll frame, and their
position is refreshed independently from regular scroll boxes.
Refreshing the scroll offsets for sticky boxes does not require display
list invalidation.

A separate hash map is used for the scroll frames of sticky boxes. This
is necessary because a single paintable box can have two scroll frames
if it 1) has "position: sticky" and 2) contains scrollable overflow.
2024-08-30 19:03:06 +02:00

57 lines
1.3 KiB
HTML

<!DOCTYPE html>
<link rel="match" href="reference/position-sticky-right-ref.html" />
<style>
* {
scrollbar-width: none;
}
.scroll-container {
width: 500px;
overflow-x: scroll;
white-space: nowrap;
background-color: #f0f0f0;
display: grid;
grid-template-columns: 1000px 300px 1000px;
border: 5px solid yellowgreen;
}
.section {
height: 200px;
background-color: orangered;
}
.sticky-element {
position: sticky;
right: 0;
background-color: blueviolet;
height: 200px;
line-height: 200px;
color: white;
}
</style>
<div class="scroll-container" id="a">
<div class="section"></div>
<div class="sticky-element"></div>
<div class="section"></div>
</div>
<div class="scroll-container" id="b">
<div class="section"></div>
<div class="sticky-element"></div>
<div class="section"></div>
</div>
<div class="scroll-container" id="c">
<div class="section"></div>
<div class="sticky-element"></div>
<div class="section"></div>
</div>
<script>
const a = document.getElementById("a");
a.scrollLeft = 0;
const b = document.getElementById("b");
b.scrollLeft = 900;
const c = document.getElementById("c");
c.scrollLeft = 1400;
</script>