forked from ant-design/ant-design
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
site: use vanilla-tilt.js for banner motion
- Loading branch information
Showing
5 changed files
with
51 additions
and
83 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React, { useEffect, useRef } from 'react'; | ||
import VanillaTilt, { type TiltOptions } from 'vanilla-tilt'; | ||
|
||
interface TiltProps extends React.HTMLAttributes<HTMLDivElement> { | ||
options?: TiltOptions; | ||
} | ||
|
||
// https://micku7zu.github.io/vanilla-tilt.js/index.html | ||
const defaultTiltOptions = { | ||
scale: 1.02, | ||
max: 8, | ||
speed: 1500, | ||
glare: true, | ||
'max-glare': 0.8, | ||
}; | ||
|
||
const Tilt: React.FC<TiltProps> = ({ options, ...props }) => { | ||
const node = useRef<HTMLDivElement>(null); | ||
useEffect(() => { | ||
if (node.current) { | ||
VanillaTilt.init(node.current, { | ||
...defaultTiltOptions, | ||
...options, | ||
}); | ||
} | ||
return () => { | ||
(node.current as any)?.vanillaTilt.destroy(); | ||
}; | ||
}, []); | ||
return <div ref={node} {...props} />; | ||
}; | ||
|
||
export default Tilt; |
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
73 changes: 0 additions & 73 deletions
73
.dumi/pages/index/components/PreviewBanner/useMouseTransform.tsx
This file was deleted.
Oops, something went wrong.
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