为了账号安全,请及时绑定邮箱和手机立即绑定

如何通过按下按钮使不透明度停止褪色?

如何通过按下按钮使不透明度停止褪色?

料青山看我应如是 2021-09-04 17:31:23
目前,我的线条不透明度每 400 毫秒降低 3%。我希望这个功能继续,但我也想创建一个按钮按下功能,一旦用户按下按钮,淡入淡出停止,并且可以记录淡入淡出停止的不透明度。非常感谢!const step = 0.03// Helper function to extract the stimulus elementsconst getLines = () =>   ['one', 'two', 'five', 'fourteen', 'fifteen']    .map(id => document.getElementById(id))getLines().forEach(line => line.style.opacity = 1);// Setup event handlervar timer = undefined;function decreaseOpacity() {  getLines().forEach(line => {        line.style.opacity -= step        console.log(line.style.opacity);  });  timer = setTimeout(() => {    decreaseOpacity();  }, 400);}decreaseOpacity();
查看完整描述

3 回答

  • 3 回答
  • 0 关注
  • 150 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信