Skip to content
This repository has been archived by the owner on Oct 1, 2021. It is now read-only.

<virtual-content> #152

Closed
wants to merge 42 commits into from
Closed
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
446db38
Remove `/src/`.
bicknellr Dec 14, 2018
9ef3e90
Initial work on a virtual content element based on searchable invisib…
bicknellr Dec 19, 2018
d4ed72c
Fill in overridden methods in ChildManager; ChildManager#[_spliceChil…
bicknellr Dec 20, 2018
d318ceb
Replace ChildManager mixin with a MutationObserver; use ResizeObserve…
bicknellr Jan 3, 2019
e44239e
Set invisible attribute directly, rather than through a cache.
bicknellr Jan 9, 2019
54b03ae
Perform layout in a single loop with interleaved reads and writes. Re…
bicknellr Jan 9, 2019
1196a6c
Handle removed children.
bicknellr Jan 9, 2019
0f746e9
Respond to `activateinvisible` events.
bicknellr Jan 10, 2019
b2bf914
Use `!important` for styling children. Always update `top` for visibl…
bicknellr Jan 10, 2019
147f88c
Adjust the `scrollTop` of the target of scroll events to account for …
bicknellr Jan 11, 2019
5d9cfe4
Remove MutationRecord coalescing code for now; likely needs to be add…
bicknellr Jan 11, 2019
5be3e82
Merge from upstream.
bicknellr Jan 11, 2019
3ebfab9
Update demo.
bicknellr Jan 14, 2019
bed9d33
Skip updates when the element isn't renderable to prevent elements' h…
bicknellr Jan 14, 2019
291755a
Find the nearest scrolling ancestor by walking the tree rather than u…
bicknellr Jan 14, 2019
43ee876
Use `Element#scrollBy` instead of setting `scrollTop` to prevent smoo…
bicknellr Jan 15, 2019
3a2ad57
Update the scroll position when height estimates are incorrect.
bicknellr Jan 15, 2019
b9f12d4
Group methods responding to events.
bicknellr Jan 15, 2019
f813e20
Rename some variables for clarity.
bicknellr Jan 16, 2019
58866c9
Enable and disable listening for scroll events based on intersection …
bicknellr Jan 16, 2019
3bb6494
Handle resizes of the nearest scroll container by watching for viewpo…
bicknellr Jan 18, 2019
0719f0f
Fix a comment.
bicknellr Jan 18, 2019
9494e27
Reuse existing empty space sentinels.
bicknellr Jan 18, 2019
8a92113
Clean up the intersection observer callback: tracking the virtual-con…
bicknellr Jan 19, 2019
d4131d3
Comment some parts of the empty space sentinel management.
bicknellr Jan 19, 2019
9469205
Make empty space sentinels fill the width of the virtual-content elem…
bicknellr Jan 19, 2019
8f42c8d
Fix the case where resizing the window didn't trigger updates. Replac…
bicknellr Jan 19, 2019
fbf455a
Remove unnecessary update in `connectedCallback`; the IntersectionObs…
bicknellr Jan 22, 2019
448aec5
Remove old 'README.md' and 'DESIGN.md'.
bicknellr Jan 22, 2019
ed9b9a3
Send a fake MutationRecord to process all the current child nodes dur…
bicknellr Jan 22, 2019
be60760
Regroup properties; clean up function binding section.
bicknellr Jan 22, 2019
bad3feb
Remove height fallback for unknown nodes in `_update`. (...)
bicknellr Jan 22, 2019
19af4cb
Merge branch 'virtual-content-2' into virtual-content-2_readme
bicknellr Jan 22, 2019
8a3ee81
Initial work on 'README.md'.
bicknellr Jan 28, 2019
d8fbe09
Changes to README
bicknellr Feb 5, 2019
742d6ea
My own README tweaks
domenic Feb 6, 2019
f60fa05
Cleanups and deletions
domenic Feb 6, 2019
fdaa1d4
Respond to some code review comments
domenic Feb 6, 2019
a9f84c6
More tweaks and fixes
domenic Feb 6, 2019
5f7c57c
Fix let vs const
domenic Feb 6, 2019
5671753
clang format. Add todo.
domenic Feb 6, 2019
4c0a667
Add comments. estimated -> cached
domenic Feb 8, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85,638 changes: 85,638 additions & 0 deletions demo/virtual-content/HTML_Standard.html

Large diffs are not rendered by default.

105 changes: 105 additions & 0 deletions demo/virtual-content/random.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<!DOCTYPE html>
domenic marked this conversation as resolved.
Show resolved Hide resolved
<template id="itemTemplate">
<div class="item">
<span class="index"></span><span class="text"></span>
</div>
</template>
<script type="module">
import '../../src/virtual-content.js';

const info = document.getElementById('info');

function updateInfo() {
info.innerHTML = `
${document.scrollingElement.scrollTop} / ${document.scrollingElement.scrollHeight}
`;
}

window.addEventListener('scroll', updateInfo);

const itemTemplateElement =
document.getElementById('itemTemplate').content.querySelector('.item');
function createItem(index) {
const item = itemTemplateElement.cloneNode(true);

Object.assign(item.style, {
marginTop: `${Math.ceil(16 * Math.random())}px`,
marginBottom: `${Math.ceil(16 * Math.random())}px`,
});

const indexSpan = item.querySelector('.index');
indexSpan.appendChild(new Text(index));

const textSpan = item.querySelector('.text');
let str = '';
const count = 100 + Math.floor(50 * Math.random());
for (let j = 0; j < count; j++) {
str += ' text';
}
textSpan.appendChild(new Text(str));

return item;
}

for (const element of document.querySelectorAll('[item-fill]')) {
const count = window.parseInt(element.getAttribute('item-fill'), 10);
for (let i = 0; i < count; i++) {
element.appendChild(createItem(i));
}
}
</script>
<style>
#vc0 {
background-color: #fdd;
}
#vc1 {
background-color: #dfd;
}
#vc2 {
background-color: #ddf;
}
#vc3 {
background-color: #fdf;
}
#vc4 {
background-color: #ffd;
}
#vc5 {
background-color: #dff;
}

.item {
font-size: 3em;
border: 8px solid black;
padding: 8px;
}
.item:nth-of-type(2n) {
border-style: dashed;
}

.item > .index {
color: #080;
}

.item > .text {
opacity: 0.25;
}

#info {
position: fixed;
top: 4px;
left: 50%;
transform: translateX(-50%);
border: 2px solid red;
padding: 2px;
background-color: white;
}
</style>
<virtual-content id="vc0" item-fill="20"><div style="overflow: auto; height: 400px;">
domenic marked this conversation as resolved.
Show resolved Hide resolved
<virtual-content id="vc1" item-fill="20"><div style="overflow: auto; height: 200px;">
<virtual-content id="vc2" item-fill="20"></virtual-content>
</div></virtual-content>
</div></virtual-content>
<virtual-content id="vc3" item-fill="5"><virtual-content id="vc4" item-fill="5"><virtual-content id="vc5" item-fill="5"></virtual-content></virtual-content></virtual-content>

<div id="info"></div>
79 changes: 79 additions & 0 deletions demo/virtual-content/spec.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
.head .logo img { position: absolute; top: 1em; right: 1em; border: none; }
domenic marked this conversation as resolved.
Show resolved Hide resolved

.toc, .toc li { list-style: none; }

pre > code.idl::before, pre.idl::before { content: 'IDL'; }
pre > code.css::before, pre.highlight.lang-css::before { content: 'CSS'; }

.note::before { content: 'Note'; }
.warning::before { content: '\26A0 Warning!'; }
.example::before { content: 'Example'; }
dl.domintro::before { content: 'For web developers (non-normative)'; }

/* Floating-but-collapsible annoying warning for snapshots */
details.annoying-warning {
background-color: #920800;
background-image: linear-gradient(transparent 40%, rgba(255, 255, 255, 0.2));
border: solid rgba(0, 0, 0, 0.4);
border-radius: 3px;
border-width: 1px 1px 0 1px;
box-shadow: 0 0 0.5em rgba(0, 0, 0, 0.5);
color: rgba(255, 255, 255, 0.95);
opacity: .95;
position: fixed;
left: 5%;
margin: 0 auto;
right: 5%;
z-index: 10;
}

details.annoying-warning[open] {
top: 10%;
top: calc(5vw + 5vh);
max-width: 1024px;
outline: solid 10000px rgba(255, 255, 255, 0.6);
}

details.annoying-warning:not([open]) {
bottom: 0;
left: 0;
right: 0;
border-radius: 0;
}

details.annoying-warning > summary {
display: list-item; /* polyfill */
font-size: 0.875em;
font-weight: bold;
letter-spacing: 0.02em;
padding: 10px 5px;
text-align: center;
text-transform: uppercase;
text-shadow: 0px 1px 2px rgba(0, 0, 0, 0.85);
cursor: default;
}

details.annoying-warning > summary::after {
content: " Expand";
position: absolute;
top: 0;
right: 5px;
font-size: smaller;
font-weight: bold;
}

details.annoying-warning[open] > summary::after {
content: " Collapse";
}

details.annoying-warning p {
padding: 0 7.5% 1em;
line-height: 1.4;
margin: 0;
text-shadow: 0px 1px 1px rgba(0, 0, 0, 0.85);
}

details.annoying-warning a {
color: white;
text-decoration: underline;
}
Loading