首页 \ 问答 \ 绘制SVG路径的最简单方法(Simplest way to draw an SVG path)

绘制SVG路径的最简单方法(Simplest way to draw an SVG path)

我从这里尝试了以下的tutiroal: http ://jakearchibald.com/2013/animated-line-drawing-svg/

var path = document.querySelector(".svg1");
var length = path.getTotalLength();
path.style.transition = path.style.WebkitTransition = "none";
path.style.strokeDasharray = length;
path.style.strokeDashoffset = length;
path.getBoundingClientRect();
path.style.transition = path.style.WebkitTransition = "stroke-dashoffset 1s ease-out";
path.style.strokeDashoffset = 0;

HTML如下:

<path class="svg1" 
style="fill: none; stroke: #3498db; stroke-width: 7; stroke-linecap: round; stroke-linejoin:  miter; stroke-miterlimit: 4;"
d="M247 103 A130 130 0 1 1 247 363 A130 130 0 1 1 247 103"
/>

问题是当我在Firefox中使用它时,它可以工作。 但是,如果我选择使用Chrome,那么动画会以75%的速度冻结,并在30秒内立即跳至100%。 我注意到,动画在一种情况下不会冻结 - 如果我使用stroke-dashoffset 530ms ease-out ,即530ms或更少。

有人可以建议一个解决方案或建议一个很好的方法来动画svg路径没有大量无用的代码?


I tried the following tutiroal from here: http://jakearchibald.com/2013/animated-line-drawing-svg/

var path = document.querySelector(".svg1");
var length = path.getTotalLength();
path.style.transition = path.style.WebkitTransition = "none";
path.style.strokeDasharray = length;
path.style.strokeDashoffset = length;
path.getBoundingClientRect();
path.style.transition = path.style.WebkitTransition = "stroke-dashoffset 1s ease-out";
path.style.strokeDashoffset = 0;

HTML is as following:

<path class="svg1" 
style="fill: none; stroke: #3498db; stroke-width: 7; stroke-linecap: round; stroke-linejoin:  miter; stroke-miterlimit: 4;"
d="M247 103 A130 130 0 1 1 247 363 A130 130 0 1 1 247 103"
/>

The thing is when I use it in Firefox, it works. But if I go for Chrome, the animation freezes at something like 75% and instantly jumps to 100% in like 30s. I've noticed, that the animation doesn't freeze only in one case - if I use stroke-dashoffset 530ms ease-out, i.e. 530ms or less.

Could someone suggest a solution for that or recommend a good way to animate an svg path without tons of useless code?


原文:https://stackoverflow.com/questions/26640478
更新时间:2022-03-05 15:03

最满意答案

既然您正在寻找最佳实践,我相信为每个用户(开发人员?)提供单独的分支永远都不是好事,而在这种意义上,“CI”根本不是CI - 它更像是个人构建而不是其他任何东西。

对于TeamCity中的分支,您可以在Project中添加特定于分支的构建配置。 例如,如果存在“构建”构建配置,则可以为发布分支等添加“构建发布”。


Since you are looking for best practices, I believe it is never good to have individual branches for each user ( developer? ) and "CI" in this sense is not CI at all - it is more a personal build than anything else.

For branches in TeamCity, you can add branch specific build configuration within the Project. For example if there is a "build" build configuration, you can add "build-release" for the release branch etc.

相关问答

更多
  • 首先,确保您的VCS根目录是您管理面板中SVN存储库的根目录,而不是指向中继目录。 然后,对于每个构建配置,编辑VCS配置中的结帐规则。 添加您所需的结帐规则。 例如,对于您的'trunk'构建配置,您将拥有一个结账规则: +:trunk => . 。 如果您想要构建标签或分支,只需使用相应的结帐规则创建新的构建配置即可。 'release-1.1'的标签的结账规则为: +:tags/release-1.1 => . 这里是关于结帐规则的文档: http : //confluence.jetbrains.n ...
  • 如果这是您所说的不可销售的话,Team City有一个开源许可选项。 如果没有,请看哈德森 。 编辑: 这里是在Windows上运行从站的说明。 Team City has an Open Source licensing option if that is what you mean by non-sellable. If not, look at Hudson. EDIT: Here are the instructions for running a slave on Windows.
  • 根据Teamcity,截至今天(2012年11月28日)尚未支持。 我找到了一个替代方案。你可以做的是创建像Bugzilla或Redmine这样的bug跟踪器的多个实例。 使用正则表达式来跟踪错误号,但该模式应该是唯一的。 要记住的是,要将项目名称添加为带有错误编号的前缀,它将起作用。 As per Teamcity this is not yet supported as of today (28th Nov,2012). I have found an alternate .What you can d ...
  • 如果我理解正确,听起来你想要使用VCS结帐规则 (TeamCity v9链接)。 而且我假设您有一个特定于您的存储库中每个project_x的构建配置。 在构建配置中的VCS根目录上,单击“查看结帐规则”并输入以下内容: +:relative/path/to/project_x 如果配置了VCS触发器,则触发器将仅检测作用于结帐规则定义的位置的更改。 If I understand correctly, it sounds like you want to make use of VCS checkout ...
  • 嗯,显然这都归功于VCS root设置。 基本上最好的选择是将根设置为main,然后编辑结帐规则: VCS root: http://my.svn.root/main checkout rules: +:Project1=>. 这似乎更稳定,并且在构建触发方面也更具响应性。 Hmmm, apparently it's all due to the VCS root settings. Basically the best option would be to have a root set up to ...
  • 使用Team City REST API。 鉴于您的Team City已部署在http://dummyhost.com,并且您启用了具有系统管理员角色的访客访问权限(否则只需从URL中的guestAuth切换到httpAuth ,并在请求中指定具有密码的用户,详细信息在文档中)您可以执行下一步操作: 获取所有构建配置GET http://dummyhost.com/guestAuth/app/rest/buildTypes/ 对于每个构建配置获取所有触发器GET http://dummyhost.com/g ...
  • 只需创建一个构建参数: system.branch_name = %teamcity.build.vcs.branch.Your_Project% 项目名称中的任何非字母数字字符都应替换为“_”。 在你的msbuild中使用$(branch_name)来引用参数。 像魅力一样工作:-) Just create a build parameter: system.branch_name = %teamcity.build.vcs.branch.Your_Project% Any non-alpha-num ...
  • 既然您正在寻找最佳实践,我相信为每个用户(开发人员?)提供单独的分支永远都不是好事,而在这种意义上,“CI”根本不是CI - 它更像是个人构建而不是其他任何东西。 对于TeamCity中的分支,您可以在Project中添加特定于分支的构建配置。 例如,如果存在“构建”构建配置,则可以为发布分支等添加“构建发布”。 Since you are looking for best practices, I believe it is never good to have individual branches f ...
  • 每种模式都有其优点和缺点: 对于两个分支具有不同VCS根的第一种方法,每个分支都指向分支的完整TFS路径,这使得事情简单易懂。 但是,每次创建构建配置时,都需要添加新的VCS根并在清除构建配置后删除它,因为在删除构建配置时没有选项可以自动执行该VCS根删除。 拥有共享VCS根目录和参数化一些路径的第二种方法是使事情变得复杂,如果团队中有多个人负责构建配置维护,那么所有人都应该知道这些参数是哪些设置,可能你可能需要记录相同的。 对于团队中的新手来说,这将是一个完全未知的,这些是这些参数。 我每次都不会这样做。 ...
  • 您应该从配置中创建一个构建配置模板,然后从它继承两次,而不是复制,每个存储库根目录一次。 这样,您可以在一个位置维护配置,从而影响两种配置。 但是,是的,我认为这是唯一的方法。 至少据我所知。 然后在将多个VCS根添加到一个配置中的意义是,如果您的软件被分成多个存储库,例如每个模块一个,则可以将它们全部拉入构建。 Instead of copying you should create a build configuration template out of your configuration and ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)