This afternoon after dinner sitting on the computer next to the whole progress bar animation effect, the effect of the whole is also drunk, although all aspects are considered, but there will be a bit of error, because the progress bar through a point, the front radius changes, but also to consider the length of the small aircraft, can not stay on the dot, Must consider a certain range, just at the beginning did not consider the problem of the diameter of the dot, the error is very large, then the diameter of the problem is also taken into account, but there will be small errors, the size of the design point diameter in the aircraft after the change has occurred.
The first page needs according to the program output number, the total number, the small aircraft to execute the animation distance and two to set the point, calculates their respective percentage, according to the total length, calculates the respective value, then locates;
Before the animation will need to calculate the length of the small aircraft execution, with two fixed points to compare, when the execution animation length is greater than a certain point of the left minus the diameter and the length of the aircraft and less than the point of value, take a fixed value, let the aircraft at the end of the point, when the last point and the previous point, No longer consider the diameter problem, only the aircraft length;
The main implementation of JS code if:
varProstepbox = $ (' Div.prostepbox '), Prostep = $ ('. Prostep ', prostepbox), ALLW = Prostep.width (), Prohasdot = $ (' #proHasDot '), Peralldot = $ (' Div.peralldot '), Perallnum =parseint(Peralldot.text ()), percur =parseint(Prohasdot.find (' span '). Text ())/perallnum, Layl = allw*percur, dot = $ (' Div.stepdot '). Not (' Div.stepDot:last '); Dot.each ( function(){ var_this = $ ( This), perc1=parseint(_this.text ())/perallnum, prodot1l = Allw*perc1; _THIS.CSS (' left ', prodot1l);if(layl>=prodot1l- $- the&&LAYL<PRODOT1L) layl=prodot1l- $- the; });if(layl>=allw- the&&LAYL<ALLW) layl=allw- the-Ten;if(ALLW = = Layl) Layl = layl- the; $( function(){Prohasdot.animate ({' width ': Layl},{Step: function(now, FX) {$(". Stepdot"). each ( function(){ var_this = $ ( This), L =parseint($( This). CSS ("left"). Replace (' px ',"'));if(now >= L) {_this.addclass (' Steppass '); _this.find ("em"). AddClass (' Doty '); }}), Complete: function() { if(layl==allw- the){//When it is absolutely necessary to set the$(". Stepdot:last"). AddClass (' Steppass '); $(". Stepdot:last"). Find ("em"). AddClass (' Doty '); $( This). Find (' I '). CSS (' Display ',' None '); } }},"Slow") });
Although the function realized, but also need to consider a certain error, when the first point from the origin of the distance is less than the width of the small aircraft and, the distance between the two points is less than the width of the aircraft, there will be a variety of problems
Progress bar small airplane moving animation