Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't animate lines with x/y as percentage #9

Closed
donaldallen opened this issue Nov 12, 2014 · 1 comment
Closed

Can't animate lines with x/y as percentage #9

donaldallen opened this issue Nov 12, 2014 · 1 comment

Comments

@donaldallen
Copy link

<svg id="square" x="0px" y="0px" width="100%" height="100%">
    <line fill="#FFFFFF" stroke="#000000" stroke-width="20" x1="0" y1="0" x2="100%" y2="0"/>
    <line fill="#FFFFFF" stroke="#000000" stroke-width="20" x1="100%" y1="0" x2="100%" y2="100%"/>
    <line fill="#FFFFFF" stroke="#000000" stroke-width="20" x1="100%" y1="100%" x2="0" y2="100%"/>
    <line fill="#FFFFFF" stroke="#000000" stroke-width="20" x1="0" y1="100%" x2="0" y2="0"/>
</svg>

Returns the following error in the console:

[Error] Error: Problem parsing d="M0,0L100%,0"
    pathMaker (app.min.js, line 1)
    scan (app.min.js, line 1)
    t (app.min.js, line 1)
    e (app.min.js, line 1)
    (anonymous function) (app.min.js, line 1)
    j (jquery-1.11.1.min.js, line 2)
    fireWith (jquery-1.11.1.min.js, line 2)
    ready (jquery-1.11.1.min.js, line 2)
    J (jquery-1.11.1.min.js, line 2)
[Error] Error: Problem parsing d="M100%,0L100%,100%"
    pathMaker (app.min.js, line 1)
    scan (app.min.js, line 1)
    t (app.min.js, line 1)
    e (app.min.js, line 1)
    (anonymous function) (app.min.js, line 1)
    j (jquery-1.11.1.min.js, line 2)
    fireWith (jquery-1.11.1.min.js, line 2)
    ready (jquery-1.11.1.min.js, line 2)
    J (jquery-1.11.1.min.js, line 2)
[Error] Error: Problem parsing d="M100%,100%L0,100%"
    pathMaker (app.min.js, line 1)
    scan (app.min.js, line 1)
    t (app.min.js, line 1)
    e (app.min.js, line 1)
    (anonymous function) (app.min.js, line 1)
    j (jquery-1.11.1.min.js, line 2)
    fireWith (jquery-1.11.1.min.js, line 2)
    ready (jquery-1.11.1.min.js, line 2)
    J (jquery-1.11.1.min.js, line 2)
[Error] Error: Problem parsing d="M0,100%L0,0"
    pathMaker (app.min.js, line 1)
    scan (app.min.js, line 1)
    t (app.min.js, line 1)
    e (app.min.js, line 1)
    (anonymous function) (app.min.js, line 1)
    j (jquery-1.11.1.min.js, line 2)
    fireWith (jquery-1.11.1.min.js, line 2)
    ready (jquery-1.11.1.min.js, line 2)
    J (jquery-1.11.1.min.js, line 2)

Is this not possible with percentages?

@maxwellito
Copy link
Owner

I didn't even though about this case. Unfortunately, it won't work. Let me explain.

To use the animation, the SVG must only contain path elements. But we cannot use percentages in path elements. The only workaround is to use viewBox.

Your SVG would look like this:

<svg id="square" x="0px" y="0px" width="100%" height="100%" viewBox="0 0 100 100">
  <line fill="#FFFFFF" stroke="#000000" stroke-width="20" x1="0" y1="0" x2="100" y2="0"/>
  <line fill="#FFFFFF" stroke="#000000" stroke-width="20" x1="100" y1="0" x2="100" y2="100"/>
  <line fill="#FFFFFF" stroke="#000000" stroke-width="20" x1="100" y1="100" x2="0" y2="100"/>
  <line fill="#FFFFFF" stroke="#000000" stroke-width="20" x1="0" y1="100" x2="0" y2="0"/>
</svg>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants