react实现科幻电影中门上锁动画效果代码
代码语言:html
所属分类:动画
代码描述:react实现科幻电影中门上锁动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> body { background-color:#111; overflow: hidden; text-align:center; } body, html { height: 100%; width: 100%; margin: 0; padding: 0; } svg{ width:100%; height:100%; } #app{ width:100%; height:100%; } #hitRing{ cursor:pointer; -webkit-tap-highlight-color:transparent; } .disabled{ pointer-events:none; } .enabled{ pointer-events:auto; } </style> </head> <body > <div id="app"></div> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/react.production.16.13.js"></script> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/react-dom.production.16.13.js"></script> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/TweenMax.min.js"></script> <script > function _defineProperty(obj, key, value) {if (key in obj) {Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true });} else {obj[key] = value;}return obj;}class DoorUI extends React.Component { constructor(props) { super(props);_defineProperty(this, "componentDidUpdate", e => { var tl = new TimelineMax({ onComplete: this.setBtnEnabled, onCompleteParams: [true] }).timeScale(1.8); tl.staggerTo('.radialGroup g', 1, { fill: this.state.open ? '#41E969' : '#F70048' }, 0.2). to('.bar', 0.4, { strokeWidth: this.state.open ? 0 : 4, transformOrigin: '50% 50%', stroke: this.state.open ? '#41E969' : '#F70048', ease: Sine.easeOut }, 0). to('.ring', 0.4, { stroke: this.state.open ? '#41E969' : '#F70048' }, 0). staggerTo('.radialGroup g', 0.3, { cycle: { alpha: [0] }, repeat: 1, ease: Sine.easeOut, yoyoEase: Sine.easeOut }, 0.1, 0). staggerTo('.radialGroup g path', 0.3, { cycle: { scale: [0.95] }, repeat: 1, svgOrigin: '400 300', ease: Sine.easeIn, yoyoEase: Sine.easeOut //Elastic.easeOut.config(0.5,0.75) }, 0.0163, 0.1). to('.radialGroup', 1, { svgOrigin: '400 300', ease: Elastic.easeOut.config(0.5, 0.75), rotation: '+=36' }, 0). to('.icon', 1, { svgOrigin: '400 300', transformOrigin: '50% 50%', ease: Sine.easeOut, //ease:Elastic.easeOut.config(0.5,0.75), rotation: this.state.open ? '+=0' : '-=180' }, 0.1). to('.icon', 0.4, { scale: 0.9, svgOrigin: '400 300', transformOrigin: '50% 50%', ease: Sine.easeOut, yoyoEase: Elastic.easeOut.config(0.5, 0.75), repeat: 1 }, 0); });_defineProperty(this, "setBtnEnabled", e => { this.refs.hitBtn.setAttribute("class", !e ? 'disabled' : 'enabled'); });_defineProperty(this, "toggle", e => { this.setBtnEnabled(false); this.setState({ open: !this.state.open }); });this.state = { open: true };this.tl = new TimelineMax({});}onLoaded() {}componentDidMount() {this.onLoaded();} render() { return ( React.createElement("svg", { viewBox: "200 150 400 300", preserveAspectRatio: "xMidYMid meet" }, React.createElement("title", null, "uiDoorLock"), React.createElement("defs", null, React.createElement("circle", { id: "ring", cx: "400", cy: "300", r: "23", strokeMiterlimit: "10", strokeWidth: "4" }), React.createElement("circle", { id: "hitRing", cx: "400", cy: "300", r: "100", strokeMiterlimit: "10", strokeWidth: "4" }), React.createElement("clipPath", { id: "ringMask" }, React.createElement("use", { xlinkHref: "#ring", fill: "red" }))), React.createElement("g", { className: "radialGroup" }, React.createElement("g", { opacity: "0.6", fill: "#47ac51" }, React.createElement("path", { d: "M405.89,246.78l-1.14,7.2a1,1,0,0,1-1.06.84,45.61,45.61,0,0,0-21.17,3.34,1,1,0,0,1-1.27-.47l-3.32-6.5a1,1,0,0,1,.5-1.38A54.84,54.84,0,0,1,405,245.62,1,1,0,0,1,405.89,246.78Z" }), React.createElement("path", { d: "M376.79,260a1,1,0,0,1-.38,1.3,45.81,45.81,0,0,0-8.48,6.68,45.34,45.34,0,0,0-6.67,8.48,1,1,0,0,1-1.31.38l-6.49-3.32a1,1,0,0,1-.42-1.4,54.33,54.33,0,0,1,19-19,1,1,0,0,1,1.4.42Z" }), React.createElement("path", { d: "M452.45,289.17l-7.22,1.14a1,1,0,0,1-1.12-.77,45,45,0,0,0-9.71-19.09,1,1,0,0,1,.05-1.36l5.16-5.17a1,1,0,0,1,1.46,0,54.39,54.39,0,0,1,12.21,24A1,1,0,0,1,452.45,289.17Z" }), React.createElement("path", { d: "M390.3,345.23l-1.13,7.22a1,1,0,0,1-1.21.83,54.39,54.39,0,0,1-24-12.21,1,1,0,0,1,0-1.46l5.17-5.16a1,1,0,0,1,1.36-.05,45,45,0,0,0,19.09,9.71A1,1,0,0,1,390.3,345.23Z" }), React.createElement("path", { d: "M448.81,322.07l-6.5-3.32a1,1,0,0,1-.47-1.27,45.61,45.61,0,0,0,3.34-21.17,1,1,0,0,1,.84-1.06l7.2-1.14a1,1,0,0,1,1.16.89,54.84,54.84,0,0,1-4.19,26.57A1,1,0,0,1,448.81,322.07Z" }), React.createElement("path", { d: "M446.54,326.52a1,1,0,0,1,.42,1.4,54.25,54.25,0,0,1-19,19,1,1,0,0,1-1.4-.42l-3.31-6.49a1,1,0,0,1,.38-1.3,45.78,45.78,0,0,0,15.16-15.16,1,1,0,0,1,1.3-.38Z" }), React.createElement("path", { d: "M421.57,350.19A54.84,54.84,0,0,1,395,354.38a1,1,0,0,1-.89-1.16l1.14-7.2a1,1,0,0,1,1.06-.84,45.61,45.61,0,0,0,21.17-3.34,1,1,0,0,1,1.27.47l3.32,6.5A1,1,0,0,1,421.57,350.19Z" }), React.createElement("path", { d: "M365.55,330.91l-5.16,5.17a1,1,0,0,1-1.46,0,54.39,54.39,0,0,1-12.21-24,1,1,0,0,1,.83-1.21l7.22-1.13a1,1,0,0,1,1.12.76,45,45,0,0,0,9.71,19.09A1,1,0,0,1,365.55,330.91Z" }), React.createElement("path", { d: "M354,304.75l-7.2,1.14a1,1,0,0,1-1.16-.89,54.84,54.84,0,0,1,4.19-26.57,1,1,0,0,1,1.38-.5l6.5,3.32a1,1,0,0,1,.47,1.27,45.61,45.61,0,0,0-3.34,21.17A1,1,0,0,1,354,304.75Z" }), React.createElement("path", { d: "M436.08,260.39l-5.17,5.16a1,1,0,0,1-1.36.05,45,45,0,0,0-19.09-9.71,1,1,0,0,1-.76-1.12l1.13-7.22a1,1,0,0,1,1.21-.83,54.39,54.39,0,0,1,24,12.21A1,1,0,0,1,436.08,260.39Z" })), React.createElement("g", { opacity: "0.4", fill: "#47ac51" }, React.createElement("path", { d: "M466.58,286.92l-7.21,1.14a1,1,0,0,1-1.12-.77,59.37,59.37,0,0,0-13.72-27,1,1,0,0,1,0-1.37l5.15-5.15a1,1,0,0,1,1.45,0,68.56,68.56,0,0,1,16.24,31.88A1,1,0,0,1,466.58,286.92Z" }), React.createElement("path", { d: "M388.06,359.37l-1.14,7.21a1,1,0,0,1-1.19.83,68.56,68.56,0,0,1-31.88-16.24,1,1,0,0,1,0-1.45l5.15-5.15a1,1,0,0,1,1.37,0,59.37,59.37,0,0,0,27,13.72A1,1,0,0,1,388.06,359.37Z" }), React.createElement("path", {.........完整代码请登录后点击上方下载按钮下载查看
网友评论0