• react抛物线小球实现


                .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;
    
        100vw;
    
        line-height:100px;
    
        text-align:center;
    
        background:pink;
    
    
    
    `
    
    const Ball = styled.div`
    
        height:20px;
    
        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;
    
    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,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);
    

      

  • 相关阅读:
    C#之线程基础
    C#之Stream和IO
    一图搞懂各种开源协议(转载)
    Qt杂谈4.浅谈事件传递的那些事
    Qt小技巧14.Qt5.12.x编译Mysql插件驱动
    Qt定制开发3.飞机飞行状态综合显示控件
    Qt实战14.告警信息滚动轮播控件
    Qt小技巧13.如何为程序设置环境变量?
    local variable 'xxx' referenced before assignment
    python 中字典(dict)合并:两个双层嵌套字典的合并
  • 原文地址:https://www.cnblogs.com/dongkx/p/10254120.html
Copyright © 2020-2023  润新知