首页 > 其他分享 >CSS animation (animation-timing-function) 测试脚本

CSS animation (animation-timing-function) 测试脚本

时间:2023-04-28 15:55:51浏览次数:46  
标签:function style ball ease animation timing starter 255

代码:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>测试 css animation 函数</title>
  <style>
    .animation-corridor {
      position: relative;
      height: 100px;
    }

    .animation-ball {
      position: absolute;
      top: 25px;
      width: 50px;
      height: 50px;
      background-color: blue;
      background-image: radial-gradient(
        circle at 10px 10px,
        rgba(25, 255, 255, 0.8),
        rgba(25, 255, 255, 0.4)
      );
      border-radius: 50%;
      animation: 1.5s infinite alternate;
    }

    @keyframes move-right {
      from {
        left: 10%;
      }
      to {
        left: 90%;
      }
    }

    li {
      display: flex;
      align-items: center;
      justify-content: center;
      margin-bottom: 20px;
    }
  </style>
</head>
<body>
  <div class="animation-corridor">
    <div class="animation-ball" id="ball"></div>
  </div>
  <ul>
    <li>
      <button class="animation-button" id="starter">Start animation</button>
    </li>
    <li>
      <label for="easing-select">Choose an easing function:</label>
      <select id="easing-select">
        <option selected>linear</option>
        <option>linear(0, 0.5 50%, 1)</option>
        <option>ease</option>
        <option>ease-in</option>
        <option>ease-in-out</option>
        <option>ease-out</option>
        <option>cubic-bezier(0.1, -0.6, 0.2, 0)</option>
        <option>cubic-bezier(0, 1.1, 0.8, 4)</option>
        <option>steps(5, end)</option>
        <option>steps(3, start)</option>
        <option>steps(4)</option>
      </select>
    </li>
  </ul>
  <script>
    const selectionElement = document.querySelector('#easing-select');
    const starter = document.querySelector('#starter');
    const ball = document.querySelector('#ball');

    starter.addEventListener('click', () => {
      if (starter.textContent === 'Start animation') {
        ball.style.animationName = 'move-right';
        ball.style.animationTimingFunction = selectionElement.value;
        starter.textContent = 'Stop animation';
      } else {
        ball.style.animationName = 'unset';
        starter.textContent = 'Start animation';
      }
    });

    selectionElement.addEventListener('change', () => {
      ball.style.animationTimingFunction = selectionElement.value;
    });
  </script>  
</body>
</html>

 

标签:function,style,ball,ease,animation,timing,starter,255
From: https://www.cnblogs.com/fanqshun/p/17362416.html

相关文章

  • Timeline的Animation Track详解
    你好,我是跟着大智学Unity的萌新,我叫小新,这是我本周的学习总结报告哦。在Timeline中,AnimationTrack可能是我们用的最多的一个轨道了,而且功能也相对比较多,今天小新就来总结一下AnimationTrack经常用到的那些功能。在Timeline中录制基本动画你可以直接在Timeline的Animation轨道上录......
  • Day 27 27.1 JS进阶-Function对象之prototype对象
    JS-Function对象之prorotype原型对象案例1://创建方式1varfoo=newFunction("console.log('helloworld!')")foo()//创建方式2functionPerson(){console.log("helloperson")}varp1=Person()console.log(p1)varp2=newPers......
  • [未解决] Internal server error: loadModule is not a function
    [vite]Internalservererror:loadModuleisnotafunctionPlugin:commonjsFile:E:/project/xxxx/knockout-es5/knockout-es5.min.jsatanalyzeRequiredModule(E:\project\xxxx\node_modules\@rollup\plugin-commonjs\dist\cjs\index.js:680:13)......
  • uniapp脚手架项目抖音小程序中使用了uView框架中的IndexList 索引列表组件报错uni.req
    解决办法如果您是vue-cli模式的项目,还需要在项目根目录的vue.config.js文件中进行如下配置://vue.config.js,如没有此文件则手动创建module.exports={transpileDependencies:['uview-ui']}......
  • JavaScript把数字转为汉字数字的function
    functionnumberToChinese(num){vardigits=["","一","二","三","四","五","六","七","八","九"];varunits=["","十",&quo......
  • rempe-2023-Trace and Pace: Controllable Pedestrian Animation via Guided Trajecto
    #TraceandPace:ControllablePedestrianAnimationviaGuidedTrajectoryDiffusion#paper1.paper-info1.1MetadataAuthor::[[DavisRempe]],[[ZhengyiLuo]],[[XueBinPeng]],[[YeYuan]],[[KrisKitani]],[[KarstenKreis]],[[SanjaFidler]],[[OrLi......
  • Function-advanced
    函数进阶1.函数防抖在频率触发的情况下只有等待一定的时间才会触发执行一次代码特点执行之前先清除之前的即将执行操作保证只有最后一次生效优化高频执行JS代码操作提高性能防抖代码实现//使用setTimeout实现函数防抖vart=null;document.onmous......
  • TypeError: _vm.searchList.slice is not a function
     调用slice()的时候报错这个是因为属性只有集合里面有应该是你定义成对象了把a.slice()这个a改成数组a:[]如果a是对象a:{}就会报这个错......
  • jQuery的$(document).ready(function(){ })的疑惑的解答
    最早接触的时候也说$(document).ready(function(){})这个函数是用来取代页面中的window.onload;但是今天发现好像不是这样回事!是在做一个页面载入效果时发现的!functionwinready(){document.getElementById("loading").style.display="none";}window.onload=winready;以......
  • Meerkat 2021 pulsar timing workshop 学习笔记(一)
    Thejoyofpulsars,byProfMatthewBaile,SwinburneUniversityofTechnologyhttps://www.youtube.com/watch?v=qG_hMzTCEX4&t=988s笔记不保证正确性(英语不行),最好观看原视频 1.引力天才们伽利略,第一个把望远镜指向天空的人,发现了木星有卫星开普勒,为行星绕太阳绕选给出了严......