-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a test case that the snap target element is transformed.
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
Showing
1 changed file
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |