Download ant-design/components/float-button/util.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 349 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/f5071caa249115f3b590492f1c8eb471e02aae4b/ant-design/components/float-button/util.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@f5071caa249115f3b590492f1c8eb471e02aae4b/ant-design/components/float-button/util.ts
-
curl -L -o util.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/f5071caa249115f3b590492f1c8eb471e02aae4b/ant-design/components/float-button/util.ts
349 Bytes
| const getOffset = (radius: number): number => { | |
| if (radius === 0) { | |
| return 0; | |
| } | |
| // 如果要考虑通用性,这里应该用三角函数 Math.sin(45) | |
| // 但是这个场景比较特殊,始终是等腰直角三角形,所以直接用 Math.sqrt() 开方即可 | |
| return radius - Math.sqrt(radius ** 2 / 2); | |
| }; | |
| export default getOffset; | |