RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-280567

Arthur's questions

Martin Hope
Arthur
Asked: 2020-12-12 21:58:32 +0000 UTC

制作麦克风图标的反向 SVG 动画

  • 3

单击元素时会出现动画,但是再次单击时是否可以将元素返回到其原始状态。(制作反向动画)

const btn = document.querySelector('div[role="button"]');
const micro = document.querySelectorAll('.micro');
btn.onclick = () => {
  micro.forEach((e) => {
    e.beginElement();
  });
}
div[role="button"] {
  border: 0.0625rem solid;
  width: 68px;
  font-size: 0;
}
<div role="button">
  <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="68" height="68" viewBox="0 0 24 24">
    <g>
    <rect id="top-part" x="9" y="3.5" width="6" height="12" rx="3" fill="#5A8CF6"/>
      <animate class="micro" xlink:href="#top-part" attributeName="height" from="12" to="6" dur="400ms" begin="indefinite" fill="freeze" />
      <animate class="micro" id="drill" xlink:href="#top-part" attributeName="y" from="3.5" to="9" begin="indefinite" dur="400ms" fill="freeze" />
    </g>
    <g stroke="#5A8CF6" fill="none">
      <g>
        <circle id="baloon" cx="12" cy="12" r="6" stroke-width="1.5" stroke-dasharray="37.7" stroke-dashoffset="18.8"/>
        <animate xlink:href="#baloon" attributeName="stroke-dashoffset" from="18.8" to="0" dur="300ms" begin="drill.end" fill="freeze"/>
      </g>
      <g>
        <rect id="leg" x="11" y="18" width="2" height="4" fill="#5A8CF6" stroke="none" transform-origin="top"/>
        <animate class="micro" xlink:href="#leg" attributeName="height" from="4" to="0" dur="400ms" begin="indefinite"  fill="freeze" />
      </g>
    </g>
  </svg>
</div>

javascript
  • 2 个回答
  • 10 Views
Martin Hope
Arthur
Asked: 2020-12-03 04:41:09 +0000 UTC

将对象返回到其先前位置 SVG

  • 4

我有一个我正在制作动画的对象animateMotion。单击动画停止按钮后,stop对象应该返回到之前没有相同动画时会渲染的位置,在这种情况下x& y= 0,但是当动画停止时,对象会保留它的位置,这实际上不该是。也许我试图错误地关闭动画,我正在更改xlink:href接受沿路径移动的对象的属性 ( ),即下例中的正方形。也许有一些内置函数SVG,我非常怀疑,我想听听关于这个的易懂的答案。

最小的例子:

document.querySelector('button').onclick = () => {
  document.querySelector('#AM').setAttribute('xlink:href', '  ');
};
<div class="wrapper">
  <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="border: 0.0625rem solid">
    <g class="main-area">
      <path d="M0 75L300 75" fill="none" stroke="red" id="AMP"/>
      <rect x="0" y="0" width="50" height="50" id="TrO" transform="translate(0 -25)"/>
      <animateMotion id="AM" xlink:href="#TrO" begin="0s" dur="3s" repeatCount="indefinite">
        <mpath xlink:href="#AMP"/>
      </animateMotion>
    </g>
  </svg>
  <button>Stop</button>
</div>

javascript
  • 2 个回答
  • 10 Views
Martin Hope
Arthur
Asked: 2020-11-12 16:35:34 +0000 UTC

ReactCSSTransitionGroup:为什么transitionAppear 不起作用?

  • 4

我正在尝试使通知淡入/淡出,但它不起作用transitionAppear。我正在向事件添加一个元素(通知弹出窗口)onBlur(在我单击输入外部之后)。动画leave在此期间运行顺利,但在此期间它appear只是突然出现而没有transition. 最近在 React 中,不要发誓太多 :D

代码沙盒: https ://codesandbox.io/s/l26j10613q

PS
如果我添加-它有效ReactCSSTransitionGroup,但没有。alert.jsappearleave

alert.js:

export default class Alert extends Component {
  render() {
    const { icon, text } = this.props;
    let classNames = "cards-wrapper-alert";
    return (
     <div className={classNames}>
       <Card zIndex="2">
         <Icon icon={icon} eClass="alert-message-icon"/>
         <Label text={text} fw="fw-medium" fs="fs-14" fc="c-dark"/>
       </Card>
     </div>
    );
  }
}

alert.css:

.alert-appear {
  max-height: 0;
  overflow: hidden;
}

.alert-appear.alert-appear-active {
  max-height: 80px;
  transition: max-height 300ms ease-in-out;
}

.alert-leave {
  max-height: 80px;
}

.alert-leave.alert-leave-active {
  max-height: 0;
  overflow: hidden;
  transition: max-height 300ms ease-in-out;
}

input.js:

<ReactCSSTransitionGroup
  component={this.prepareComponentForAnimation}
  transitionName="alert"
  transitionEnter={false}
  transitionAppear={true}
  transitionAppearTimeout={400}
  transitionLeaveTimeout={400}>
  {this.state.alert ?
    React.cloneElement(this.props.children, {
      icon: this.state.icon,
      text: this.state.text
    })
  : null}
</ReactCSSTransitionGroup>

例子:

在此处输入图像描述

javascript
  • 1 个回答
  • 10 Views
Martin Hope
Arthur
Asked: 2020-11-08 22:44:21 +0000 UTC

确定父级中的子级数

  • 1

有一个您想要应用样式的按钮。

应用于button缩进文本和图标的样式:

display: flex;
justify-content: space-between;

目标:

  • 如果块有 2 个子元素,则对其应用样式。

  • 如果块有 1 个子元素或根本没有子元素,
    请不要相应地应用这些样式

我想做这样一个小小的“手术” CSS。

我的尝试:

* {
  margin: 0;
  padding: 0;
}

html {
  font-size: 62.5%;
}

.button {
  width: auto;
  display: inline-block;
  padding: 1.35rem 1.6rem;
  background-color: hsl(214, 100%, 50%);
  border-radius: 0.3rem;
  white-space: nowrap;
  text-align: center;
  font-size: initial;
  font-family: "RobotoMedium";
  user-select: none;
  cursor: pointer;
  color: #fff;
}

.medium-btn {
  width: 13rem;
}
<div class="button medium-btn" role="button">
  <span class="fw-medium fs-16 c-white">Continue</span>
  <div class="icon button-arrow">
    <svg width="36" height="20" viewBox="0 0 36 20" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" fill="none">
    <line x1="4" y1="10" x2="31" y2="10"/>
    <polyline points="26,7 31,10 26,13"/>
  </svg>
  </div>
</div>

javascript
  • 1 个回答
  • 10 Views
Martin Hope
Arthur
Asked: 2020-07-08 23:44:36 +0000 UTC

将 Paper.js 转换为纯 JS 代码

  • 3

有一个代码paper.js:

#canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height 100%;
  border: 1px solid red;
}
<script src="https://cdn.jsdelivr.net/npm/paper@0.11.5/dist/paper-full.min.js"></script>
<canvas id="canvas" resize></canvas>
<script type="text/paperscript" canvas="canvas">
   
  var points = 10;
  var length = 15;

  var path = new Path({
    strokeColor: '#E4141B',
    strokeWidth: 2,
    strokeCap: 'round'
  });

  var start = view.center / [10, 1];
  for (var i = 0; i < points; i++)
    path.add(start + new Point(i * length, 0));

  function onMouseMove(event) {
    path.firstSegment.point = event.point;
    for (var i = 0; i < points - 1; i++) {
      var segment = path.segments[i];
      var nextSegment = segment.next;
      var vector = segment.point - nextSegment.point;
      vector.length = length;
      nextSegment.point = segment.point - vector;
    }
    path.smooth();
  }
</script>

原来的“链子”

无法将其转换为正常的JS. 困难在于它本身path。无法创建它并将其划分为段(部分),然后在事件中对其进行动画处理mousemove。

javascript
  • 1 个回答
  • 10 Views
Martin Hope
Arthur
Asked: 2020-06-07 02:56:11 +0000 UTC

每个元素上的事件

  • 7

我决定制作这样的效果(“现场”示例):

在此处输入图像描述

目标:我有三个元素,我希望这个事件(如上所示)在每个元素上触发。尝试了一个循环,但都是徒劳的。

var el = document.querySelector('.magnetic-button');

var options = {
  ease: 0.1,
  magneticForce: 0.6
};

var mouse = {
  x: 0,
  y: 0
};

var pos = {
  cx: 0,
  cy: 0,
  tx: 0,
  ty: 0,
  x: 0,
  y: 0
};

var sizes = el.getBoundingClientRect();

observe();
update();

function observe() {
  window.addEventListener('resize', resizeHandler, false);
  el.addEventListener('mousemove', mouseMoveHandler, false);
  el.addEventListener('mouseleave', mouseLeaveHandler, false);
}

function resizeHandler() {
  sizes = el.getBoundingClientRect();
}

function mouseMoveHandler(e) {
  //sizes

  mouse.x = e.pageX;
  mouse.y = e.pageY;

  // center

  pos.cx = sizes.left + sizes.width / 2;
  pos.cy = sizes.top + sizes.height / 2;

  // dist

  var distX = mouse.x - sizes.left - sizes.width / 2;
  var distY = mouse.y - sizes.top - sizes.height / 2;

  pos.tx = distX - distX * (1 - options.magneticForce);
  pos.ty = distY - distY * (1 - options.magneticForce);
}

function mouseLeaveHandler(e) {
  pos.tx = 0;
  pos.ty = 0;
}

function render() {

  pos.x += (pos.tx - pos.x) * options.ease;
  pos.y += (pos.ty - pos.y) * options.ease;

  var transform2 = 'translateX(' + pos.x + 'px) translateY(' + pos.y + 'px)';

  el.style.webkitTransform = transform2;
  el.style.MozTransform = transform2;
  el.style.msTransform = transform2;
  el.style.OTransform = transform2;
  el.style.transform = transform2;
}

function update() {
  render();
  window.requestAnimationFrame(update);
}
.social-nets {
  display: flex;
}

.magnetic-button {
  margin-left: 1rem;
  position: relative;
  width: 3.3333333333rem;
  height: 3.3333333333rem;
  background-color: #b3b3b3;
  color: rgba(0, 0, 0, 0.8);
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
}

.magnetic-button::before,
.magnetic-button:after {
  content: "";
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  transition: transform 800ms cubic-bezier(0.19, 1, 0.22, 1) 0ms;
  will-change: transform;
  z-index: -1;
}

.magnetic-button::before {
  background-color: red;
}

.magnetic-button:hover::before {
  transform: scale(0.95);
}

.magnetic-button:hover::after {
  transform: scale(0.85);
}
<div class="social-nets">
  <div class="magnetic-button"></div>
  <div class="magnetic-button"></div>
  <div class="magnetic-button"></div>
</div>

javascript
  • 1 个回答
  • 10 Views
Martin Hope
Arthur
Asked: 2020-04-02 02:52:11 +0000 UTC

如何制作文字破解效果

  • 19

此 QA 是过去的延续(文本样式SVG)。

在这个 QA (Question-Answer) 中,我们将看到Crack effect,下面将给出这种效果的示例,总共有 3 个。

第一个例子(沿着文本出现裂缝并进一步转换):

在此处输入图像描述

第二个例子(文字的上半部分在挥剑后折断并平滑滑出,尽管文字本身的角度应该在 10 左右1-2deg):

在此处输入图像描述

第三个例子(与第二个类似,但有区别,有两个笔划沿和横跨文本):

在此处输入图像描述

文本将在 上实现SVG,放置通过clipPath,动画通过@keyframes。

PS点击后所有示例都可以使用。

html
  • 3 个回答
  • 10 Views
Martin Hope
Arthur
Asked: 2020-03-24 04:47:12 +0000 UTC

样式化和动画 SVG 文本

  • 13

我想看一些文本样式的示例以及如何将pattern&mask与一些效果结合使用。

1. “爬虫”笔画(linearGradient& animate):

在此处输入图像描述

2.
用对角线(pattern& mask)从自身投射阴影的文本:

在此处输入图像描述

3.用水填充文本(SVG( pattern& mask) & CSS( @keyframes)):

在此处输入图像描述

PS在这个问题中,有一些来自开放访问(2和3)的例子。创建这个问题是为了吸引SVG和展示它的能力。

html
  • 2 个回答
  • 10 Views
Martin Hope
Arthur
Asked: 2020-03-11 22:11:51 +0000 UTC

带有 SVG 滤镜的菜单(Goo 效果)

  • 11

有一个在HTML/上实现的菜单CSS。我想出了将它与过滤器一起制作的想法,特别是每个菜单项SVG的“粘度”(Goo )效果。

1.好例子:

在此处输入图像描述

2.使用此效果制作的菜单:

在此处输入图像描述

问题:如何正确应用此菜单的过滤器?

html
  • 1 个回答
  • 10 Views
Martin Hope
Arthur
Asked: 2020-02-22 21:41:44 +0000 UTC

使用 SVG 进行火车运动

  • 8

我有一张照片,显示火车在铁轨上行驶。
我想用SVG.
随着这一切,烟雾从烟囱的蒸汽机车中冒出来。
如何使用 制作类似的动画SVG?

在此处输入图像描述

html
  • 1 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5