Skip to content

Commit b13298d

Browse files
committed
Change arrow functions to named functions
1 parent bccfd01 commit b13298d

File tree

1 file changed

+31
-29
lines changed

1 file changed

+31
-29
lines changed

src/index.js

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,32 @@
1-
const getRect = (element) => element.getBoundingClientRect();
1+
function getRect(element) {
2+
return element.getBoundingClientRect();
3+
}
24

3-
const detectElementOverflow = (element, container) => ({
4-
get collidedTop() {
5-
return getRect(element).top < getRect(container).top;
6-
},
7-
get collidedBottom() {
8-
return getRect(element).bottom > getRect(container).bottom;
9-
},
10-
get collidedLeft() {
11-
return getRect(element).left < getRect(container).left;
12-
},
13-
get collidedRight() {
14-
return getRect(element).right > getRect(container).right;
15-
},
16-
get overflowTop() {
17-
return getRect(container).top - getRect(element).top;
18-
},
19-
get overflowBottom() {
20-
return getRect(element).bottom - getRect(container).bottom;
21-
},
22-
get overflowLeft() {
23-
return getRect(container).left - getRect(element).left;
24-
},
25-
get overflowRight() {
26-
return getRect(element).right - getRect(container).right;
27-
},
28-
});
29-
30-
export default detectElementOverflow;
5+
export default function detectElementOverflow(element, container) {
6+
return {
7+
get collidedTop() {
8+
return getRect(element).top < getRect(container).top;
9+
},
10+
get collidedBottom() {
11+
return getRect(element).bottom > getRect(container).bottom;
12+
},
13+
get collidedLeft() {
14+
return getRect(element).left < getRect(container).left;
15+
},
16+
get collidedRight() {
17+
return getRect(element).right > getRect(container).right;
18+
},
19+
get overflowTop() {
20+
return getRect(container).top - getRect(element).top;
21+
},
22+
get overflowBottom() {
23+
return getRect(element).bottom - getRect(container).bottom;
24+
},
25+
get overflowLeft() {
26+
return getRect(container).left - getRect(element).left;
27+
},
28+
get overflowRight() {
29+
return getRect(element).right - getRect(container).right;
30+
},
31+
};
32+
}

0 commit comments

Comments
 (0)