Skip to content

Commit e450a81

Browse files
committed
Attach styles to component
1 parent 4d35133 commit e450a81

File tree

4 files changed

+21
-17
lines changed

4 files changed

+21
-17
lines changed

src/CustomCursor.css

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
removeHoverEvent, removeWindowEvent,
88
} from './utils';
99

10-
import './CustomCursor.css';
10+
import styles from './styles.module.css';
1111

1212
const CustomCursor = ({
1313
targets,
@@ -45,7 +45,7 @@ const CustomCursor = ({
4545
}, [opacity, ref, smoothness, targetOpacity, targetScale, targets]);
4646

4747
return (
48-
<div className='cursor'>
48+
<div className={styles.cursor}>
4949
<svg
5050
ref={ref}
5151
className={customClass}

src/styles.module.css

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.cursor {
2+
display: none;
3+
}
4+
5+
@media (any-pointer: fine) {
6+
.cursor {
7+
position: fixed;
8+
top: 0;
9+
left: 0;
10+
display: block;
11+
pointer-events: none;
12+
opacity: 0;
13+
z-index: 100000;
14+
}
15+
}

src/utils/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ const addHoverEvent = (cursor, targets) => {
44

55
if (Array.isArray(targets)) {
66
targets.forEach((target) => {
7-
[...document.querySelectorAll(target)].forEach((el) => {
7+
[].forEach.call(document.querySelectorAll(target), (el) => {
88
el.addEventListener('mouseenter', cursor.enter);
99
el.addEventListener('mouseleave', cursor.leave);
1010
});
1111
});
1212
} else {
13-
[...document.querySelectorAll(targets)].forEach((el) => {
13+
[].forEach.call(document.querySelectorAll(targets), (el) => {
1414
el.addEventListener('mouseenter', cursor.enter);
1515
el.addEventListener('mouseleave', cursor.leave);
1616
});
@@ -22,13 +22,13 @@ const removeHoverEvent = (cursor, targets) => {
2222

2323
if (Array.isArray(targets)) {
2424
targets.forEach((target) => {
25-
[...document.querySelectorAll(target)].forEach((el) => {
25+
[].forEach.call(document.querySelectorAll(target), (el) => {
2626
el.removeEventListener('mouseenter', cursor.enter);
2727
el.removeEventListener('mouseleave', cursor.leave);
2828
});
2929
});
3030
} else {
31-
[...document.querySelectorAll(targets)].forEach((el) => {
31+
[].forEach.call(document.querySelectorAll(targets), (el) => {
3232
el.removeEventListener('mouseenter', cursor.enter);
3333
el.removeEventListener('mouseleave', cursor.leave);
3434
});

0 commit comments

Comments
 (0)