Skip to content

Commit f93800f

Browse files
committed
Docs: Minor changes to ex
1 parent a774165 commit f93800f

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
2-
title: 'Query .offsetParent()'
3-
shortTitle: '.offsetParent()'
2+
title: 'Query .positioningParent()'
3+
shortTitle: '.positioningParent()'
44
id: 'query-positioningparent'
55
exampleType: 'component'
66
category: 'Query'
77
subcategory: 'Visibility'
88
tags: ['query', 'offset', 'parent', 'position', 'fixed', 'absolute']
99
description: 'Finds the actual positioning context for positioned elements'
10-
tip: 'Unlike offsetParent, correctly handles fixed elements and modern CSS positioning contexts'
10+
tip: 'Unlike positioningParent, correctly handles fixed elements and modern CSS positioning contexts'
1111
selectedFile: 'page.js'
1212
---

docs/src/examples/query/dom-traversal/query-offsetparent/page.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
}
1717

1818
.target {
19-
position: absolute;
19+
position: fixed;
2020
top: 20px;
2121
left: 20px;
2222
padding: var(--padding);
@@ -41,4 +41,4 @@ ui-button {
4141
.highlight {
4242
outline: 3px solid var(--red-40);
4343
outline-offset: -3px;
44-
}
44+
}

docs/src/examples/query/dom-traversal/query-offsetparent/page.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div class="container">
22
<div class="box">
33
<div class="target">
4-
position: absolute
4+
position: fixed
55
<br>top: 20px
66
</div>
77
</div>

docs/src/examples/query/dom-traversal/query-offsetparent/page.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ $('.find').on('click', () => {
5151
$('.highlight').removeClass('highlight');
5252

5353
const $offsetParent = $('.target').offsetParent();
54+
console.log($offsetParent.el());
5455
$offsetParent.addClass('highlight');
5556

5657
if ($offsetParent.is('.container')) {
@@ -60,9 +61,9 @@ $('.find').on('click', () => {
6061
log('Containing parent: .box (due to transform/filter!)');
6162
}
6263

63-
// Compare with browser's offsetParent
64-
const $offsetParent = $('.target').offsetParent({ calculate: false });
65-
if (!$offsetParent.is($offsetParent)) {
64+
// Compare with positioning parent (which will handle filter);
65+
const $positioningParent = $('.target').positioningParent();
66+
if (!$offsetParent.is($positioningParent)) {
6667
$log.append('<br>Note: Browser offsetParent is different!');
6768
}
6869
});

0 commit comments

Comments
 (0)