加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

react抛物线小球实现

发布时间:2020-12-15 20:36:25 所属栏目:百科 来源:网络整理
导读:.ballFather { position : absolute ; width : 15px ; height : 15px ; border-radius : 50% ; transition : all 0.5s cubic-bezier(0.52,-0.3,0.93,0.54) ; z-index : 999 ; } .ballSon { width : 15px ; height : 15px ; background : #3190e8 ; border-ra
            .ballFather{

                position: absolute;

                width: 15px;

                height: 15px;

                border-radius: 50%;

                transition: all  0.5s cubic-bezier(0.52,-0.3,0.93,0.54);

                z-index: 999;

            }

            .ballSon{

                width: 15px;

                height: 15px;

                background: #3190e8;

                border-radius: 50%;

                transition:all 0.5s linear;

            }
import React,{ Component } from "react";

import { connect } from "isomorphism-sdk";

import styled,{ keyframes,css } from "styled-components";



import {Track,Button} from ‘@components‘

const Wrap = styled.div`

    text-align:center;

    color:green;

`;



const Btn = styled.div`

    position:fixed;

    bottom:0;

    left:0;

    height:100px;

    width:100vw;

    line-height:100px;

    text-align:center;

    background:pink;



`

const Ball = styled.div`

    height:20px;

    width:20px;

    background:red;

`

const BigBox= styled.div`

height:68px;

border:1px solid blue;

margin-bottom:40px;

text-align:left;

`

const SmallBox = styled.span`

display:inline-block;

height:50px;

width:160px;

background:grey;

`







const  TheBall={

	newBall(event,target){

		let div=document.createElement(‘div‘);

		div.className=‘ballFather‘;

		document.body.appendChild(div);

		let sonDiv=document.createElement(‘div‘);

		sonDiv.className=‘ballSon‘

		div.appendChild(sonDiv);

		let top=event.target.getBoundingClientRect().top;

		let left=event.target.getBoundingClientRect().left;

		div.style.left=left+‘px‘;

		div.style.top=top+‘px‘;

		let y = (document.documentElement.clientHeight - top +100);//加100是为了防止掉不下去

        let x = (document.documentElement.clientWidth+7.5-left)

        // debugger

		div.style.display =‘‘;

        const clientWidth = document.documentElement.clientWidth;

        const clientHeight = document.documentElement.clientHeight;

		div.style.transform = `translate3d(0,${y}px,0)`;

		sonDiv.style.transform = `translate3d(${x/2}px,0)`;

		setTimeout(()=>{

			document.body.removeChild(div);

		},500)

	}

}





class App extends Component {

    constructor(props) {

        super(props);

        this.state = {

            aaa:false

        };

    }



    aaa = (event) =>{

        TheBall.newBall(event,target)

        console.log(123)

    }



    render() {

        const { activity } = this.props;



        return (

          <Wrap>

                  <BigBox>

                      <SmallBox onClick={this.aaa.bind(this,{x:375,y:-50})}> 123</SmallBox>

                  </BigBox>

                  <BigBox>

                      <SmallBox onClick={this.aaa.bind(this)}>0</SmallBox>

                  </BigBox>

                  <BigBox></BigBox>

                  {         /**

                      <Track type=‘click‘ id=‘12671‘>

                          <Button onClick={this.aaa.bind(this)}>我是一号</Button>

                      </Track>

                      <Track>

                          <Button onClick={this.aaa}>我是二号</Button>

                      </Track>

                      <Track>

                          <Button>我是三号</Button>

                      </Track>

                       <Button>我是死号</Button>

                       **/

                  }





              <Btn className=‘abs‘>O</Btn>

          </Wrap>

        );

    }

}



export default connect(({ location,activity },tasks) => {

    return {

        location,activity

    };

})(App);

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读