-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d5b8ed9
commit 3cbeae3
Showing
5 changed files
with
105 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import React from 'react'; | ||
|
||
export const useRipples = () => { | ||
const during = 1000; | ||
const color = 'rgba(255, 255, 255, 0.5)'; | ||
const [rippleStyle, setRippleStyle] = React.useState({ | ||
backgroundColor: color, | ||
position: 'absolute', | ||
borderRadius: '50%', | ||
opacity: 0, | ||
width: 35, | ||
height: 35, | ||
transform: 'translate(-50%, -50%)', | ||
pointerEvents: 'none', | ||
top: 0, | ||
left: 0, | ||
transition: 'initial', | ||
}); | ||
|
||
const onClick = (ev: React.MouseEvent<HTMLButtonElement>) => { | ||
ev.stopPropagation(); | ||
const { pageX, pageY, currentTarget } = ev; | ||
const rect = currentTarget.getBoundingClientRect(); | ||
const left = pageX - (rect.left + window.scrollX); | ||
const top = pageY - (rect.top + window.scrollY); | ||
const size = Math.max(rect.width, rect.height); | ||
|
||
setRippleStyle({ | ||
...rippleStyle, | ||
left, | ||
top, | ||
opacity: 1, | ||
transform: 'translate(-50%, -50%)', | ||
transition: 'initial', | ||
}); | ||
|
||
setTimeout(() => { | ||
setRippleStyle({ | ||
...rippleStyle, | ||
opacity: 0, | ||
transform: `scale(${size / 9})`, | ||
transition: `all ${during}ms`, | ||
}); | ||
}, 50); | ||
}; | ||
|
||
return { | ||
rippleStyle, | ||
onClickRipple: onClick, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3cbeae3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: