Skip to content

Commit

Permalink
Merge pull request #51 from bramus/fix-css-polyfill-load
Browse files Browse the repository at this point in the history
Fix loading of CSS Polyfill - fix #50
  • Loading branch information
kevers-google authored Apr 22, 2022
2 parents ad29e62 + 0950b17 commit 3233112
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 2 deletions.
49 changes: 49 additions & 0 deletions demo/basic/css.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!DOCTYPE html>
<style>
body {
height: 2000px;
padding-top: 200px;
}

#test {
display: block;
width: 100px;
height: 100px;
background: green;
position: fixed;
top: 0;
}

#container {
position: absolute;
top: 400px;
height: 200px;
width: 200px;
background: blue;
}

@scroll-timeline scroll-in-document {
}

@keyframes move {
from {
transform: translateY(0);
}

to {
transform: translateY(1000px);
}
}

#test {
animation: 1s linear move forwards;
animation-timeline: scroll-in-document;
}
</style>
<body>
<h1>ScrollTimeline polyfill</h1>
<p>A <a href="../parallax/">more advanced demo based on element intersection</a>.</p>
<div id="test"></div>
<div id="container"></div>
<script src="../../dist/scroll-timeline.js"></script>
</body>
2 changes: 1 addition & 1 deletion dist/scroll-timeline.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/scroll-timeline.js.map

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
<li>
<a href="demo/basic/">demo/basic</a>
</li>
<li>
<a href="demo/basic/css.html">demo/basic/css</a>
</li>
<li>
<a href="demo/parallax/">demo/parallax</a>
</li>
Expand Down
5 changes: 5 additions & 0 deletions src/scroll-timeline-css.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ function createScrollTimeline(name) {
}

export function initCSSPolyfill() {
// Don't load if browser claims support
if (CSS.supports("animation-timeline: works")) {
return;
}

initMutationObserver();

// We are not wrapping capturing 'animationstart' by a 'load' event,
Expand Down

0 comments on commit 3233112

Please sign in to comment.