【问题标题】:snap svg try to rotate an object with center point but not worksnap svg 尝试用中心点旋转对象但不起作用
【发布时间】:2017-03-28 14:34:47
【问题描述】:

我学习使用 snap svg 这个库并想旋转一个对象。但是,我得到一个奇怪的旋转效果,找不到问题所在。

以下是sn-p的代码,大家可以看看。

var s = Snap("#container"); 

//lets draw 2 rects at position 100,100 and then reposition them

var r = s.rect(100,100,100,100).attr({fill: 'red' });

var g = s.group(r);

var bbox = g.getBBox();


s.text(20, 20, bbox.cx);

s.text(20, 40, bbox.cy);

g.animate({ transform: 'r180,'+ bbox.cx + ',' + bbox.cy }, 1000, mina.bounce );
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/snap.svg/0.5.1/snap.svg-min.js"></script>
</head>
<body>
  
  <div style="width: 335px; height: 600px;">
  
    
    <svg width='100%' height='100%' id='container'></svg>
    
  </div>
    
    </body>
</html>

希望有人能告诉我:)

【问题讨论】:

    标签: svg snap.svg


    【解决方案1】:

    我认为 Snap 0.5/0.5.1 中存在错误,请参阅 here

    我要做的第一件事是尝试 Snap 0.4.1,例如 here,看看是否能解决问题。我认为它已在 0.5.2 中修复,但不确定它是否可用。

    如果没有解决,请更新问题以提及您也尝试过 0.4.1。

    【讨论】:

    • 是的...这是 snap 0.5 中的一个错误。我尝试使用 snap 0.4.1 的 sn-p,它可以工作,哈哈。谢谢!
    猜你喜欢
    • 1970-01-01
    • 2018-02-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多