Created
March 21, 2020 15:16
-
-
Save askcompany-kr/73dddaf4f4c5e4b2f2cc37f1901175c1 to your computer and use it in GitHub Desktop.
Framer X 샘플 컴포넌트. 클릭할 때마다 45%회전하여 scale이 변경하며, 이미지까지 변경됩니다.
This file contains hidden or 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
| import * as React from "react" | |
| import { Frame, addPropertyControls, ControlType, useCycle } from "framer" | |
| // Open Preview: Command + P | |
| // Learn more: https://framer.com/api | |
| const imageUrls = [ | |
| "https://images.unsplash.com/photo-1526047932273-341f2a7631f9?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1400&q=80", | |
| "https://images.unsplash.com/photo-1533907650686-70576141c030?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1500&q=80", | |
| ] | |
| export function Quote(props) { | |
| const [backgroundImageUrl, cycle] = useCycle(...imageUrls) | |
| const [rotate, setRotate] = React.useState(0) | |
| const [scale, setScale] = React.useState(1) | |
| const onClick = () => { | |
| cycle() | |
| setRotate(prev => prev + 45) | |
| setScale(prev => (prev === 1 ? 0.4 : 1)) | |
| } | |
| return ( | |
| <Frame | |
| onClick={onClick} | |
| animate={{ rotate, scale }} | |
| center={true} | |
| background={{ | |
| src: backgroundImageUrl, | |
| }} | |
| ></Frame> | |
| ) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment