Code Monkey home page Code Monkey logo

Comments (4)

xrkffgg avatar xrkffgg commented on September 22, 2024

I think this maybe because https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-linecap

from progress.

xrkffgg avatar xrkffgg commented on September 22, 2024

Different strokeLinecap has a different start point and end point.

from progress.

preper avatar preper commented on September 22, 2024

Yes, different strokeLinecap has a different start point and end point. And it leads to incorrect calculation of the progress bar length. This is the rendering result in the browser of my example above:

<svg class="rc-progress-line" viewBox="0 0 100 10" preserveAspectRatio="none">
    <path class="rc-progress-line-trail"
        d="M 5,5  L 95,5" stroke-linecap="round"
        stroke="rgba(255,255,255, .4)" stroke-width="10" fill-opacity="0"></path>
    <path class="rc-progress-line-path"
        d="M 5,5  L 95,5" stroke-linecap="round"
        stroke="#FFE68D" stroke-width="10" fill-opacity="0" style="stroke-dasharray: 90px, 100px; stroke-dashoffset: 0px; transition: stroke-dashoffset 0.3s ease 0s, stroke-dasharray 0.3s ease 0s, stroke 0.3s linear 0s, 0.06s;"></path>
</svg>

The length of rc-progress-line-path is 90(d="M 5,5 L 95,5", 95 - 5), so it will reach full state at stroke-dasharray: 90px, 100px;.

This bug can fix in two ways:

  1. svg viewBox="0 0 ${100 + strokeWidth} 10", path d="M ${strokeWidth / 2},5 L ${100 + strokeWidth / 2},5", in this way, path's length is corrected to 100;
  2. Recalculate the length of rc-progress-line-path, It should be equal to stroke-dasharray: ${percent * (100 - strokeWidth) / 100 }px, 100px;

from progress.

xrkffgg avatar xrkffgg commented on September 22, 2024

PR welcome~

from progress.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.