【问题标题】:SVG fill page load animationSVG填充页面加载动画
【发布时间】:2018-09-30 22:03:09
【问题描述】:

我正在尝试创建一个页面加载动画,其中出现带有绘图效果的 SVG 线条,之后线条应该一直扩展到左上角,这样屏幕就会被填满,我可以将内容放在填充的屏幕顶部,我遇到了anime.js,我得到了第一部分的工作,

<div class="line">
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1173.98 1399.25">
        <g id="line">
            <path class="cls-1" d="M1168.8,89.74a259.34,259.34,0,0,0-25-21c-40.32-29.78-78.88-40.21-105-47-27.1-7-84.53-21.37-159-10-14.65,2.24-80.68,13.21-152,59-34.75,22.31-55.62,43.17-93,81-52.81,53.45-61.88,72.92-125,147-52.64,61.79-84.15,98.76-133,142-19.42,17.19-56.54,44.69-130,99-113.65,84-125,89.77-149,117-24.89,28.2-63.75,73.27-81,144-5.72,23.48-20.52,87.83,6,159,9.42,25.27,20.56,42,34,62,24.8,36.81,51.52,66,124,130,98.55,87.06,147.82,130.59,156,136,10.78,7.12,38,24.52,58,58a166.3,166.3,0,0,1,20,52" />
        </g>
    </svg>
</div>

.cls-1 {
  fill: none;
  stroke: #000;
  stroke-miterlimit: 10;
  stroke-width: 15px;
}

var lineDrawing = anime({
    targets: '.line #line path',
    strokeDashoffset: [anime.setDashoffset, 0],
    easing: 'easeInOutSine',
    duration: 2000,
    delay: function (el, i) { return i * 250 },
    direction: 'alternate',
    loop: false
});

为了获得填充效果,我在网上环顾四周,发现我可以使用变形效果来实现我想要的效果,但是我的 SVG 线没有任何&lt;polygon points,我该怎么做才能得到效果?

【问题讨论】:

    标签: svg anime.js


    【解决方案1】:

    我不确定是否真正理解您的问题。您是否要求以下内容:

    function ldraw() {
       var lineDrawing = anime({
          targets: '.line #line path',
          strokeDashoffset: [anime.setDashoffset, 0],
          easing: 'easeInOutSine',
          duration: 2000,
          delay: function (el, i) { return i * 250 },
          direction: 'alternate',
          loop: false
       });
       window.setTimeout(lgrow,2000);
    }
    
    function lgrow() {
       var lineGrowing = anime({
          targets: '#line .cls-1',
          easing: 'easeInOutSine',
          duration: 2000,
          strokeWidth: ['15px','200%'],
          loop: false
       });
    }
    
    window.onload=function() {
      window.setTimeout(ldraw,1000);
    };
    .cls-1 {
      fill: none;
      stroke: #000;
      stroke-miterlimit: 0;
      stroke-width: 15px;
      stroke-linecap:round;
      stroke-linejoin:round;
    }
    <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/2.2.0/anime.min.js"></script>
    <div class="line">
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1173.98 1399.25">
            <g id="line">
                <path class="cls-1" d="M1168.8,89.74a259.34,259.34,0,0,0-25-21c-40.32-29.78-78.88-40.21-105-47-27.1-7-84.53-21.37-159-10-14.65,2.24-80.68,13.21-152,59-34.75,22.31-55.62,43.17-93,81-52.81,53.45-61.88,72.92-125,147-52.64,61.79-84.15,98.76-133,142-19.42,17.19-56.54,44.69-130,99-113.65,84-125,89.77-149,117-24.89,28.2-63.75,73.27-81,144-5.72,23.48-20.52,87.83,6,159,9.42,25.27,20.56,42,34,62,24.8,36.81,51.52,66,124,130,98.55,87.06,147.82,130.59,156,136,10.78,7.12,38,24.52,58,58a166.3,166.3,0,0,1,20,52" />
            </g>
        </svg>
    </div>

    【讨论】:

    • 是这样的!但是它应该只在外部扩展,所以行内的空白应该保留,这可能吗?
    • ?? “外层” ??只有一行!
    • 我的意思是空白应该留在右下角,所以应该只填充页面的左侧
    猜你喜欢
    • 2019-06-26
    • 2017-08-30
    • 2015-03-11
    • 1970-01-01
    • 2020-03-14
    • 1970-01-01
    • 2019-11-10
    • 2018-07-30
    • 2017-08-14
    相关资源
    最近更新 更多