mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
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
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.
53 lines
1.5 KiB
HTML
53 lines
1.5 KiB
HTML
<!DOCTYPE html>
|
|
<link rel="match" href="reference/position-sticky-bottom-ref.html" />
|
|
<style>
|
|
.scrollable-container {
|
|
width: 300px;
|
|
height: 300px;
|
|
overflow-y: scroll;
|
|
border: 5px solid red;
|
|
}
|
|
|
|
.sticky-box {
|
|
position: sticky;
|
|
bottom: 50px;
|
|
width: 240px;
|
|
height: 80px;
|
|
background: #3498db;
|
|
color: white;
|
|
}
|
|
|
|
.box {
|
|
height: 500px;
|
|
background-color: orange;
|
|
}
|
|
</style>
|
|
|
|
<div class="scrollable-container" id="sticky-is-below-scrollport">
|
|
<div class="box"></div>
|
|
<div class="sticky-box">I stick within this scrollable box!</div>
|
|
<div class="box"></div>
|
|
</div>
|
|
|
|
<div class="scrollable-container" id="sticky-is-inside-scrollport">
|
|
<div class="box"></div>
|
|
<div class="sticky-box">I stick within this scrollable box!</div>
|
|
<div class="box"></div>
|
|
</div>
|
|
|
|
<div class="scrollable-container" id="sticky-is-above-scrollport">
|
|
<div class="box"></div>
|
|
<div class="sticky-box">I stick within this scrollable box!</div>
|
|
<div class="box"></div>
|
|
</div>
|
|
|
|
<script>
|
|
const stickyIsBelowScrollport = document.getElementById("sticky-is-below-scrollport");
|
|
stickyIsBelowScrollport.scrollTop = 0;
|
|
|
|
const stickyIsInsideScrollport = document.getElementById("sticky-is-inside-scrollport");
|
|
stickyIsInsideScrollport.scrollTop = 390;
|
|
|
|
const stickyIsAboveScrollport = document.getElementById("sticky-is-above-scrollport");
|
|
stickyIsAboveScrollport.scrollTop = 780;
|
|
</script>
|