Skip to content

Commit

Permalink
Add a test case that the snap target element is transformed.
Browse files Browse the repository at this point in the history
Depends on D21629

Differential Revision: https://phabricator.services.mozilla.com/D21630

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1373835
gecko-commit: d4682a804eba019aac23fecce0079768a3c6e5cb
gecko-integration-branch: central
gecko-reviewers: botond
  • Loading branch information
Hiroyuki Ikezoe authored and jgraham committed Apr 25, 2019
1 parent c7e1d09 commit e8623ce
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions css/css-scroll-snap/snap-to-transformed-target.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<!DOCTYPE html>
<link rel="help" href="https://drafts.csswg.org/css-scroll-snap-1" />
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
div {
position: absolute;
}
#scroller {
overflow: hidden; /* TODO: Use scrollbar-width: none */
scroll-snap-type: x mandatory;
width: 500px;
height: 500px;
}
.space {
width: 2000px;
height: 2000px;
}
#target {
height: 200px;
width: 200px;
left: 50px;
background-color: blue;
}
</style>
<div id="scroller">
<div class="space"></div>
<div id="target"></div>
</div>
<script>
test(() => {
target.style.scrollSnapAlign = "start";
target.style.transform = "translateX(300px)";
scroller.scrollTo(10, 0);
assert_equals(scroller.scrollLeft, 350 /* left + translateX(300px) */);
assert_equals(scroller.scrollTop, 0);
}, "Snaps to the transformed snap start position");

test(() => {
target.style.scrollSnapAlign = "end";
target.style.transform = "translateX(300px)";
scroller.scrollTo(10, 0);
assert_equals(scroller.scrollLeft,
50 /* left + width + translateX(300px) - scroller.width */);
assert_equals(scroller.scrollTop, 0);
}, "Snaps to the transformed snap end position");

test(() => {
target.style.scrollSnapAlign = "start";
target.style.transform = "translateX(-100px)";
scroller.scrollTo(10, 0);
assert_equals(scroller.scrollLeft, 0);
assert_equals(scroller.scrollTop, 0);
}, "Snaps to visible top left position of the transformed box");

</script>

0 comments on commit e8623ce

Please sign in to comment.