LEFT | RIGHT |
(no file at all) | |
| 1 <!DOCTYPE html> |
| 2 <script src="/resources/testharness.js"></script> |
| 3 <script src="/resources/testharnessreport.js"></script> |
| 4 <script src="./resources/intersection-observer-test-utils.js"></script> |
| 5 |
| 6 <style> |
| 7 pre, #log { |
| 8 position: absolute; |
| 9 top: 0; |
| 10 left: 200px; |
| 11 } |
| 12 #root { |
| 13 overflow: visible; |
| 14 height: 200px; |
| 15 width: 160px; |
| 16 border: 7px solid black; |
| 17 } |
| 18 #target { |
| 19 margin: 10px; |
| 20 width: 100px; |
| 21 height: 100px; |
| 22 padding: 10px; |
| 23 background-color: green; |
| 24 } |
| 25 </style> |
| 26 |
| 27 <div id="root"> |
| 28 <div id="target" style="transform: translateY(300px)"></div> |
| 29 </div> |
| 30 |
| 31 <script> |
| 32 var entries = []; |
| 33 var target; |
| 34 |
| 35 runTestCycle(function() { |
| 36 target = document.getElementById("target"); |
| 37 assert_true(!!target, "target exists"); |
| 38 var root = document.getElementById("root"); |
| 39 assert_true(!!root, "root exists"); |
| 40 var observer = new IntersectionObserver(function(changes) { |
| 41 entries = entries.concat(changes) |
| 42 }, {root: root}); |
| 43 observer.observe(target); |
| 44 entries = entries.concat(observer.takeRecords()); |
| 45 assert_equals(entries.length, 0, "No initial notifications."); |
| 46 runTestCycle(step0, "First rAF."); |
| 47 }, "Test that the target's border bounding box is used to calculate intersection
."); |
| 48 |
| 49 function step0() { |
| 50 var targetBounds = clientBounds(target); |
| 51 target.style.transform = "translateY(195px)"; |
| 52 runTestCycle(step1, "target.style.transform = 'translateY(195px)'"); |
| 53 checkLastEntry(entries, 0, targetBounds.concat(0, 0, 0, 0, 8, 182, 8, 222, fal
se)); |
| 54 } |
| 55 |
| 56 function step1() { |
| 57 var targetBounds = clientBounds(target); |
| 58 target.style.transform = ""; |
| 59 checkLastEntry(entries, 1, targetBounds.concat(25, 145, 220, 222, 8, 182, 8, 2
22, true)); |
| 60 } |
| 61 </script> |
LEFT | RIGHT |