HTML5¼¼Êõ

SVG animation »Ø¹Ë - Chrimisia(2)

×ÖºÅ+ ×÷ÕߣºH5Ö®¼Ò À´Ô´£ºH5Ö®¼Ò 2017-04-07 08:04 ÎÒÒªÆÀÂÛ( )

¢ß "indefinite"¾ÍÊÇÕâ¸ö×Ö·û´®Öµ£¬±íʾ¡°ÎÞÏ޵ȴý¡±¡£¾Ý˵ÐèÒªbeginElement()·½·¨´¥·¢»òÕßÖ¸Ïò¸Ã¶¯»­ÔªËصij¬Á´½Ó(SVGÖеÄaÔªËØ)¡£µã»÷ÎÒÃǵÄsvg, ´¥·¢animateÔªËصÄbeginElement()·½·¨£¬Ç°ÌáÊÇbegin="indefinite"

¢ß "indefinite"¾ÍÊÇÕâ¸ö×Ö·û´®Öµ£¬±íʾ¡°ÎÞÏ޵ȴý¡±¡£¾Ý˵ÐèÒªbeginElement()·½·¨´¥·¢»òÕßÖ¸Ïò¸Ã¶¯»­ÔªËصij¬Á´½Ó(SVGÖеÄaÔªËØ)¡£µã»÷ÎÒÃǵÄsvg, ´¥·¢animateÔªËصÄbeginElement()·½·¨£¬Ç°ÌáÊÇbegin="indefinite".

´¥·¢Ê¼þºóÔ˶¯

var animate = document.getElementsByTagName("animate")[0]; if (animate) { document.getElementById("svg").onclick = function() { animate.beginElement(); }; }

 aÔªËصÄxlink:hrefÖ¸ÏòµÄÎÒÃǵĶ¯»­ÔªËØ

µã»÷ÎÒ

5. dur
ºóÃæÁ½ÖÖ£º³£¹æʱ¼äÖµ | "indefinite".

¡°³£¹æʱ¼äÖµ¡±¾ÍÊÇ3sÖ®ÀàµÄÕý³£Öµ£»"indefinite"ָʼþÎÞÏÞ¡£¶¯»­Ê±¼äÎÞÏÞ£¬Êµ¼ÊÉϾÍÊǶ¯»­Ñ¹¸ù²»Ö´ÐеÄÒâ˼¡£Òò´Ë£¬ÉèÖÃΪ"indefinite"¸úûÓÐdurÊÇÒ»¸öÒâ˼£¬Óëdur½âÎöÒì³£Ò»¸öÒâ˼¡£

6. calcMode, keyTimes, keySplines
Õ⼸¸ö²ÎÊýÊÇ¿ØÖƶ¯»­Ïȿ컹ÊÇÏÈÂýÀàËÆÕâÑù×÷Óõġ£

calcModeÊôÐÔÖ§³Ö4¸öÖµ£ºdiscrete | linear | paced | spline. ÖÐÎÄÒâ˼·Ö±ðÊÇ£º¡°ÀëÉ¢¡±|¡°ÏßÐÔ¡±|¡°Ì¤²½¡±|¡°ÑùÌõ¡±¡£

discretefromÖµÖ±½ÓÌøµ½toÖµ¡£linearanimateMotionÔªËØÒÔÍâÔªËصÄcalcModeĬÈÏÖµ¡£¶¯»­´ÓÍ·µ½Î²µÄËÙÂʶ¼ÊÇÒ»Öµġ£pacedͨ¹ý²åÖµÈö¯»­µÄ±ä»¯²½µ÷ƽÎȾùÔÈ¡£½öÖ§³ÖÏßÐÔÊýÖµÇøÓòÄÚµÄÖµ£¬ÕâÑùµãÖ®¼ä¡°¾àÀ롱µÄ¸ÅÄî²ÅÄܱ»¼ÆË㣨Èçposition, width, heightµÈ£©¡£Èç¹û¡±paced¡°Ö¸¶¨£¬ÈκÎkeyTimes»òkeySplinesÖµ¶¼»á´ò½´ÓÍ¡£spline²åÖµ¶¨Òå±´Èû¶ûÇúÏß¡£splineµãµÄ¶¨ÒåÔÚkeyTimesÊôÐÔÖУ¬Ã¿¸öʱ¼ä¼ä¸ô¿ØÖƵãÓÉkeySplines¶¨Òå¡£

keyTimes = ¡°<list>¡±
¸úÉÏÃæÌáµ½µÄ<list>ÀàËÆ£¬¶¼ÊǷֺŷָôÒ»×éÖµ¡£keyTimes´ÓÃû×ÖÉÏ¿´Êǹؼüʱ¼äµãµÄÒâ˼£¬´óÖ¾ÍÊÇÕâ¸öÒâ˼¡£Ç°ÃæÌáµ½¹ývaluesÒ²ÊǶàÖµ£¬ÕâÀïÓÐһЩԼ¶¨µÄ¹æÔò£º

¡¡¡¡Ò»¡¢keyTimesÖµµÄÊýÄ¿ÒªºÍvaluesÒ»Ö£¬Èç¹ûÊÇfrom/to/by¶¯»­£¬keyTimes¾Í±ØÐëÓÐÁ½¸öÖµ¡£

¡¡¡¡¶þ¡¢¶ÔÓÚlinearºÍspline¶¯»­£¬µÚÒ»¸öÊý×ÖÒªÊÇ0, ×îºóÒ»¸öÊÇ1¡£

¡¡¡¡Èý¡¢Ã¿¸öÁ¬ÐøµÄʱ¼äÖµ±ØÐë±ÈËüÇ°ÃæµÄÖµ´ó»òÕßÏàµÈ¡£

 pacedģʽÏ£¬keyTimes»á±»ºöÂÔ£»keyTimes¶¨Òå´íÎó£¬Ò²»á±»ºöÂÔ£»durΪindefiniteÒ²»á±»ºöÂÔ¡£

keySplines = ¡°<list>¡±
keySplines±íʾµÄÊÇÓëkeyTimesÏà¹ØÁªµÄÒ»×é±´Èû¶û¿ØÖƵ㣨ĬÈÏ0 0 1 1£©¡£Ã¿¸ö¿ØÖƵãʹÓÃ4¸ö¸¡µãÖµ±íʾ£ºx1 y1 x2 y2. Ö»ÓÐģʽÊÇsplineʱºòÕâ¸ö²ÎÊý²ÅÓÐÓã¬Ò²ÊǷֺŷָô£¬Öµ·¶Î§0~1£¬×ÜÊDZÈkeyTimesÉÙÒ»¸öÖµ¡£

Èç¹ûkeySplinesÖµ²»ºÏ·¨»ò¸öÊý²»¶Ô£¬ÊÇûÓж¯»­Ð§¹ûµÄ¡£

ÈçÏÂ4¸öSVG£¬Ö»Õ¹Ê¾ÖØÒª²¿·Ö´úÂ룺

¾ÍÊÇvalues, keyTimes, keySplinesÈý¸öÈËÖ®¼äÊÂÇé¡£valuesÈ·¶¨¶¯»­µÄ¹Ø¼üλÖã¬keyTimesÈ·¶¨µ½Õâ¸ö¹Ø¼üµãÐèÒªµÄʱ¼ä£¬keySplinesÈ·¶¨µÄÊÇÿ¸öʱ¼äµã¶ÎÖ®¼äµÄ±´Èû¶ûÇúÏߣ¬Ò²¾ÍÊǾßÌåµÄ»º¶¯±íÏÖ¡£Æ½Ê±CSS3дµÄtransition¶¯»­Ð§¹û£¬Ò²ÊÇÕâô»ØÊ£¬ÕâÊÇvaluesÖµ¾ÍÁ½¸ö£¬ËùÒÔ£¬keyTimesÖ»ÄÜÊÇ0;1, ±´Èû¶ûÇúÏß¾ÍÖ»ÓÐÒ»¸ö£¬Òª²»ease, Òª²»linearµÈ

7. repeatCount, repeatDur

repeatCount±íʾ¶¯»­Ö´ÐдÎÊý£¬¿ÉÒÔÊǺϷ¨ÊýÖµ»òÕß¡±indefinite¡°£¨¶¯»­Ñ­»·µ½µçÄÔËÀ»ú£©¡£
repeatDur¶¨ÒåÖظ´¶¯»­µÄ×Üʱ¼ä¡£¿ÉÒÔÊÇÆÕͨʱ¼äÖµ»òÕß¡±indefinite£¨¡±¶¯»­Ñ­»·µ½µçÄÔËÀ»ú£©¡£

¶¯»­Ö»ÍæÖ´ÐÐÍêÕû3¸ö + Ò»¸ö1/3¸ö¶¯»­¡£ÒòΪrepeat×Üʱ¼ä¾Í10s¶øÒÑ¡£

8. fill

fill±íʾ¶¯»­¼ä϶µÄÌî³ä·½Ê½¡£Ö§³Ö²ÎÊýÓУºfreeze | remove. ÆäÖÐremoveÊÇĬÈÏÖµ£¬±íʾ¶¯»­½áÊøÖ±½Ó»Øµ½¿ªÊ¼µÄµØ·½¡£freeze¡°¶³½á¡±±íʾ¶¯»­½áÊøºóÏñÊDZ»¶³×¡ÁË£¬ÔªËر£³ÖÁ˶¯»­½áÊøÖ®ºóµÄ״̬¡£

9. accumulate, additive

accumulateÊÇÀÛ»ýµÄÒâ˼¡£Ö§³Ö²ÎÊýÓУºnone | sum. ĬÈÏÖµÊÇnone. Èç¹ûÖµÊÇsum±íʾ¶¯»­½áÊøʱºòµÄλÖÃ×÷ΪÏ´ζ¯»­µÄÆðʼλÖá£
additive¿ØÖƶ¯»­ÊÇ·ñ¸½¼Ó¡£Ö§³Ö²ÎÊýÓУºreplace | sum. ĬÈÏÖµÊÇreplace. Èç¹ûÖµÊÇsum±íʾ¶¯»­µÄ»ù´¡ÖªÊ¶»á¸½¼Óµ½ÆäËûµÍÓÅÏȼ¶µÄ¶¯»­ÉÏ£¬

ÕâÀïÂÖµ½µÚ¶þ¸ö¶¯»­µÄʱºò£¬Â·¾¶ÊÇ´ÓµÚÒ»¸ö¶¯»­Â·¾¶½áÊøµØ·½¿ªÊ¼µÄ£¬ÓÚÊÇ£¬3¸ö¶¯»­ÍêÃÀÎÞ·ìÁ¬½ÓÆðÀ´ÁË¡£

;

Á½¸ö¶¯»­Í¬Ê±¶¼ÊÇtransform£¬¶¼ÒªÊ¹ÓÃÒ»¸ötypeÊôÐÔ£¬ºÃÔÚÕâ¸öÀý×Óadditive="sum"ÊÇÀۼӵĶø²»ÊÇreplaceÌæ»»¡£

ÓÚÊÇ£¬ÎÒÃǾͿÉÒÔÊÇʵÏÖÒ»±ßÐýתһ±ß·Å´óµÄЧ¹û¡£

10. restart

restartÕâ¸öÊôÐÔµ®ÉúµÄ±³¾°ÈçÏ£ººÜ¶à¶¯»­ÄØ£¬Æä´¥·¢¿ÉÄÜÓëʼþÏà¹Ø¡£ÏÖÔÚ£¬´æÔÚÕâÖÖÇé¿ö£¬Ï£Íûµã»÷Ò»´Î·´Ó¦Ò»´Î£¬Ö®ºóÔÙµã»÷¾ÍûÓз´Ó¦¡£ÕâÖÖÐèÇóµÄ³öÏÖÆÈʹrestart²ÎÊýµÄ³öÏÖ¡£Ö§³ÖµÄ²ÎÊýÓУºalways | whenNotActive | never.

alwaysÊÇĬÈÏÖµ£¬±íʾ×ÜÊÇ£¬Ò²¾ÍÊǵãÒ»´Î£¬´¥·¢Ò»´Îʼþ¡£whenNotActive±íʾ¶¯»­ÕýÔÚ½øÐеÄʱºò£¬ÊDz»ÄÜÖØÆô¶¯»­µÄ¡£never±íʾ¶¯»­ÊÇÒ»²¨Á÷¡£

11. min, max

min/max±íʾ¶¯»­Ö´ÐÐ×î¶ÌºÍ×ʱ¼ä¡£Ö§³Ö²ÎÊýΪʱ¼äÖµºÍ"media"£¨Ã½½éÔªËØÓÐЧ£©, max»¹Ö§³Öindefinite.

ËÄ¡¢¶¯»­µÄÔÝÍ£Óë²¥·Å

SVG animationÖÐÊÇÓÐÄÚÖõÄAPI¿ÉÒÔÔÝÍ£ºÍÆô¶¯¶¯»­µÄ

// svgÖ¸µ±Ç°svg DOMÔªËØ // ÔÝÍ£ svg.pauseAnimations(); // ÖØÆô¶¯ svg.unpauseAnimations()

 

¡¡

1.±¾Õ¾×ñÑ­ÐÐÒµ¹æ·¶£¬ÈκÎתÔصĸå¼þ¶¼»áÃ÷È·±ê×¢×÷ÕߺÍÀ´Ô´£»2.±¾Õ¾µÄÔ­´´ÎÄÕ£¬ÇëתÔØʱÎñ±Ø×¢Ã÷ÎÄÕÂ×÷ÕߺÍÀ´Ô´£¬²»×ðÖØÔ­´´µÄÐÐΪÎÒÃǽ«×·¾¿ÔðÈΣ»3.×÷ÕßͶ¸å¿ÉÄܻᾭÎÒÃDZ༭Ð޸Ļò²¹³ä¡£

Ïà¹ØÎÄÕÂ
  • requestAnimationFrame¼ò½é - tonyinsh

    requestAnimationFrame¼ò½é - tonyinsh

    2017-04-05 13:00

  • [C#] C# ֪ʶ»Ø¹Ë - ×°ÏäÓë²ðÏä - ·´¹Ç×У¨¶þÎå×У©

    [C#] C# ֪ʶ»Ø¹Ë - ×°ÏäÓë²ðÏä - ·´¹Ç×У¨¶þÎå×У©

    2017-03-03 08:00

  • »Ø¹Ë×ܽá2016Ä꣬չÍûÐÂÄêµÄСĿ±ê - ÚûÔ½

    »Ø¹Ë×ܽá2016Ä꣬չÍûÐÂÄêµÄСĿ±ê - ÚûÔ½

    2017-02-08 16:00

  • [C#] C# ֪ʶ»Ø¹Ë - Lambda - ·´¹Ç×У¨¶þÎå×У©

    [C#] C# ֪ʶ»Ø¹Ë - Lambda - ·´¹Ç×У¨¶þÎå×У©

    2017-01-16 15:01

ÍøÓѵãÆÀ
Ñ