center-center 0.0.32 → 0.0.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.mts +2 -2
- package/index.mjs +15 -8
- package/package.json +3 -3
package/index.d.mts
CHANGED
|
@@ -21,10 +21,10 @@ export interface ScrollingElement {
|
|
|
21
21
|
* A Center Center `Rect`
|
|
22
22
|
*/
|
|
23
23
|
export interface CenterCenterRect {
|
|
24
|
-
width: number
|
|
25
|
-
height: number
|
|
26
24
|
left: number
|
|
27
25
|
top: number
|
|
26
|
+
width: number
|
|
27
|
+
height: number
|
|
28
28
|
right: number
|
|
29
29
|
bottom: number
|
|
30
30
|
}
|
package/index.mjs
CHANGED
|
@@ -129,10 +129,10 @@ export function getViewportRect () {
|
|
|
129
129
|
} = getScrollingElement()
|
|
130
130
|
|
|
131
131
|
return {
|
|
132
|
-
width,
|
|
133
|
-
height,
|
|
134
132
|
left,
|
|
135
133
|
top,
|
|
134
|
+
width,
|
|
135
|
+
height,
|
|
136
136
|
right: (left + width),
|
|
137
137
|
bottom: (top + height)
|
|
138
138
|
}
|
|
@@ -146,18 +146,25 @@ export function getViewportRect () {
|
|
|
146
146
|
*/
|
|
147
147
|
export function getElementRect (element) {
|
|
148
148
|
const {
|
|
149
|
+
scrollLeft: l,
|
|
150
|
+
scrollTop: t
|
|
151
|
+
} = getScrollingElement()
|
|
152
|
+
|
|
153
|
+
const {
|
|
154
|
+
x,
|
|
155
|
+
y,
|
|
149
156
|
width,
|
|
150
157
|
height
|
|
151
158
|
} = element.getBoundingClientRect()
|
|
152
159
|
|
|
153
|
-
const left =
|
|
154
|
-
const top =
|
|
160
|
+
const left = l + x
|
|
161
|
+
const top = t + y
|
|
155
162
|
|
|
156
163
|
return {
|
|
157
|
-
width,
|
|
158
|
-
height,
|
|
159
164
|
left,
|
|
160
165
|
top,
|
|
166
|
+
width,
|
|
167
|
+
height,
|
|
161
168
|
right: (left + width),
|
|
162
169
|
bottom: (top + height)
|
|
163
170
|
}
|
|
@@ -190,8 +197,8 @@ export function calculateLeft ({
|
|
|
190
197
|
right: viewportR
|
|
191
198
|
},
|
|
192
199
|
container: {
|
|
193
|
-
width: containerW,
|
|
194
200
|
left: containerL,
|
|
201
|
+
width: containerW,
|
|
195
202
|
right: containerR
|
|
196
203
|
},
|
|
197
204
|
target: {
|
|
@@ -221,8 +228,8 @@ export function calculateTop ({
|
|
|
221
228
|
bottom: viewportB
|
|
222
229
|
},
|
|
223
230
|
container: {
|
|
224
|
-
height: containerH,
|
|
225
231
|
top: containerT,
|
|
232
|
+
height: containerH,
|
|
226
233
|
bottom: containerB
|
|
227
234
|
},
|
|
228
235
|
target: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "center-center",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.35",
|
|
4
4
|
"description": "Position an element at the center center of a container",
|
|
5
5
|
"main": "./index.mjs",
|
|
6
6
|
"type": "module",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@babel/core": "^7.24.0",
|
|
36
36
|
"@babel/eslint-parser": "^7.23.10",
|
|
37
37
|
"@babel/preset-env": "^7.24.0",
|
|
38
|
-
"@sequencemedia/hooks": "^1.0.
|
|
38
|
+
"@sequencemedia/hooks": "^1.0.483",
|
|
39
39
|
"@typescript-eslint/eslint-plugin": "^7.1.0",
|
|
40
40
|
"@typescript-eslint/parser": "^7.1.0",
|
|
41
41
|
"chai": "^5.1.0",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"eslint": "^8.57.0",
|
|
45
45
|
"eslint-config-standard": "^17.1.0",
|
|
46
46
|
"eslint-config-standard-with-typescript": "^43.0.1",
|
|
47
|
-
"express": "^4.18.
|
|
47
|
+
"express": "^4.18.3",
|
|
48
48
|
"husky": "^9.0.11",
|
|
49
49
|
"mocha": "^10.3.0",
|
|
50
50
|
"nodemon": "^3.1.0",
|