Skip to content

Commit 1e0e78f

Browse files
committed
Docs: update page position example
1 parent eb99e0e commit 1e0e78f

File tree

3 files changed

+44
-17
lines changed

3 files changed

+44
-17
lines changed
Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,55 @@
11
.container {
22
position: relative;
33
height: 200px;
4-
margin: 20px 0;
5-
background: var(--standard-10);
6-
border: var(--border);
4+
margin: var(--vertically-spaced) 0;
5+
background: var(--angled-gradient) var(--yellow-background-color);
6+
border: 2px solid var(--yellow-border-color);
77
border-radius: var(--border-radius);
88
}
99

1010
.box {
1111
position: absolute;
1212
width: 180px;
1313
height: 60px;
14-
padding: 10px;
14+
padding: var(--padding);
1515
top: 10px;
1616
left: 10px;
17-
background: var(--standard-10);
17+
background: var(--angled-gradient) var(--blue-background-color);
18+
border: 2px solid var(--blue-border-color);
1819
border-radius: var(--border-radius);
1920
text-align: center;
2021
align-content: center;
22+
font-weight: bold;
23+
color: var(--blue-text-color);
2124
}
2225

26+
.measurements {
27+
margin: var(--vertically-spaced);
28+
background: var(--standard-5);
29+
border: var(--border);
30+
padding: var(--padding);
31+
border-radius: var(--border-radius);
32+
font-weight: bold;
33+
font-size: var(--large);
2334

24-
p {
25-
margin: 8px 0;
26-
font-family: monospace;
27-
span {
28-
font-weight: bold;
35+
.parts {
36+
font-size: var(--medium);
37+
margin-top: var(--margin);
38+
color: var(--standard-40);
39+
border-top: var(--border);
40+
padding-top: var(--padding);
2941
}
30-
b {
31-
font-weight: bold;
32-
color: var(--primary-text-color);
42+
43+
p {
44+
margin: 3px 0;
45+
font-family: Monospace;
46+
span {
47+
font-weight: bold;
48+
color: var(--primary-text-color);
49+
}
50+
b {
51+
font-weight: bold;
52+
color: var(--primary-text-color);
53+
}
3354
}
3455
}
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
<p>Get and set element position relative to document</p>
2-
31
<div class="container">
42
<div class="box">Movable box</div>
53
</div>
64

7-
<p>Position relative to page: <span class="position"></span></p>
5+
<div class="measurements">
6+
<p>Page Position: top: <span class="page-top">-</span><b>px</b>, left: <span class="page-left">-</span><b>px</b></p>
7+
<div class="parts">
8+
<p>Includes scroll offset from document origin</p>
9+
</div>
10+
</div>
811

912
<ui-button class="move">Move to global (100, 50)</ui-button>
1013
<ui-button class="reset">Move to global (0, 0)</ui-button>

docs/src/examples/query/dimensions/query-pageposition/page.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import { $ } from '@semantic-ui/query';
22

33
function updatePosition() {
4+
// pagePosition() returns position relative to document including scroll
45
const pos = $('.box').pagePosition();
5-
$('.position').text(`top: ${Math.round(pos.top)}px, left: ${Math.round(pos.left)}px`);
6+
7+
$('.page-top').text(Math.round(pos.top));
8+
$('.page-left').text(Math.round(pos.left));
69
}
710

811
// Show initial position

0 commit comments

Comments
 (0)