{"id":32700,"date":"2024-11-25T11:04:44","date_gmt":"2024-11-25T03:04:44","guid":{"rendered":"https:\/\/fwq.ai\/blog\/32700\/"},"modified":"2024-11-25T11:04:44","modified_gmt":"2024-11-25T03:04:44","slug":"%e4%bb%8e-mojs-%e5%8a%a8%e7%94%bb%e5%ba%93%e5%bc%80%e5%a7%8b%ef%bc%9a%e6%8e%a2%e7%b4%a2%e5%bd%a2%e7%8a%b6%e6%a8%a1%e5%9d%97","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/32700\/","title":{"rendered":"\u4ece Mojs \u52a8\u753b\u5e93\u5f00\u59cb\uff1a\u63a2\u7d22\u5f62\u72b6\u6a21\u5757"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/465\/014\/169383006991076.jpg\" class=\"aligncenter\" title=\"\u4ece Mojs \u52a8\u753b\u5e93\u5f00\u59cb\uff1a\u63a2\u7d22\u5f62\u72b6\u6a21\u5757\u63d2\u56fe\" alt=\"\u4ece Mojs \u52a8\u753b\u5e93\u5f00\u59cb\uff1a\u63a2\u7d22\u5f62\u72b6\u6a21\u5757\u63d2\u56fe\" \/><\/p>\n<p>\u5728\u4e0a\u4e00\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528 mojs \u4e3a\u7f51\u9875\u4e0a\u7684\u4e0d\u540c HTML \u5143\u7d20\u6dfb\u52a0\u52a8\u753b\u6548\u679c\u3002\u6211\u4eec\u4f7f\u7528\u8be5\u5e93\u4e3b\u8981\u5bf9\u770b\u8d77\u6765\u50cf\u6b63\u65b9\u5f62\u6216\u5706\u5f62\u7684 div \u5143\u7d20\u8fdb\u884c\u52a8\u753b\u5904\u7406\u3002\u4f46\u662f\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 Html \u6a21\u5757\u6765\u4e3a\u56fe\u50cf\u6216\u6807\u9898\u7b49\u5404\u79cd\u5143\u7d20\u8bbe\u7f6e\u52a8\u753b\u3002\u5982\u679c\u60a8\u786e\u5b9e\u6253\u7b97\u4f7f\u7528 mojs \u5bf9\u57fa\u672c\u5f62\u72b6\u8fdb\u884c\u52a8\u753b\u5904\u7406\uff0c\u90a3\u4e48\u60a8\u53ef\u80fd\u5e94\u8be5\u4f7f\u7528\u5e93\u4e2d\u7684 Shape \u6a21\u5757\u3002<\/p>\n<p>Shape \u6a21\u5757\u5141\u8bb8\u60a8\u4f7f\u7528 SVG \u5728 DOM \u4e2d\u521b\u5efa\u57fa\u672c\u5f62\u72b6\u3002\u60a8\u6240\u8981\u505a\u7684\u5c31\u662f\u6307\u5b9a\u8981\u521b\u5efa\u7684\u5f62\u72b6\u7c7b\u578b\uff0cmojs \u4f1a\u5904\u7406\u5269\u4e0b\u7684\u4e8b\u60c5\u3002\u8be5\u6a21\u5757\u8fd8\u5141\u8bb8\u60a8\u4e3a\u60a8\u521b\u5efa\u7684\u4e0d\u540c\u5f62\u72b6\u8bbe\u7f6e\u52a8\u753b\u3002 <\/p>\n<p>\u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u5c06\u4ecb\u7ecd Shape \u6a21\u5757\u7684\u57fa\u7840\u77e5\u8bc6\uff0c\u4ee5\u53ca\u5982\u4f55\u4f7f\u7528\u5b83\u6765\u521b\u5efa\u4e0d\u540c\u7684\u5f62\u72b6\u5e76\u4e3a\u5176\u8bbe\u7f6e\u52a8\u753b\u3002<\/p>\n<h2>\u5728 Mojs \u4e2d\u521b\u5efa\u5f62\u72b6<\/h2>\n<p>\u60a8\u9700\u8981\u5b9e\u4f8b\u5316 mojs Shape \u5bf9\u8c61\u624d\u80fd\u521b\u5efa\u4e0d\u540c\u7684\u5f62\u72b6\u3002\u8be5\u5bf9\u8c61\u5c06\u63a5\u53d7\u4e0d\u540c\u7684\u53c2\u6570\uff0c\u8fd9\u4e9b\u53c2\u6570\u53ef\u7528\u4e8e\u63a7\u5236\u60a8\u521b\u5efa\u7684\u5f62\u72b6\u7684\u989c\u8272\u3001\u5927\u5c0f\u3001\u89d2\u5ea6\u7b49\u3002<\/p>\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u60a8\u521b\u5efa\u7684\u4efb\u4f55\u5f62\u72b6\u90fd\u5c06\u4f7f\u7528\u6587\u6863\u6b63\u6587\u4f5c\u4e3a\u5176\u7236\u7ea7\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528 parent \u5c5e\u6027\u5c06\u4efb\u4f55\u5176\u4ed6\u5143\u7d20\u6307\u5b9a\u4e3a\u5176\u7236\u5143\u7d20\u3002\u60a8\u8fd8\u53ef\u4ee5\u501f\u52a9 className \u5c5e\u6027\u4e3a\u60a8\u521b\u5efa\u7684\u4efb\u4f55\u5f62\u72b6\u5206\u914d\u4e00\u4e2a\u7c7b\u3002\u5982\u679c\u60a8\u8df3\u8fc7\u6b64\u5c5e\u6027\uff0c\u5e93\u5c06\u4e0d\u4f1a\u5206\u914d\u4efb\u4f55\u9ed8\u8ba4\u7c7b\u3002<\/p>\n<p>Mojs \u5185\u7f6e\u4e86\u516b\u79cd\u4e0d\u540c\u7684\u5f62\u72b6\uff0c\u56e0\u6b64\u60a8\u53ef\u4ee5\u901a\u8fc7\u4e3a shape \u5c5e\u6027\u8bbe\u7f6e\u503c\u6765\u76f4\u63a5\u521b\u5efa\u5b83\u4eec\u3002\u60a8\u53ef\u4ee5\u5c06\u5176\u503c\u8bbe\u7f6e\u4e3a circle \u521b\u5efa\u5706\u5f62\uff0crect \u521b\u5efa\u77e9\u5f62\uff0cpolygon \u521b\u5efa\u591a\u8fb9\u5f62\u3002\u60a8\u8fd8\u53ef\u4ee5\u901a\u8fc7\u5c06 shape \u7684\u503c\u8bbe\u7f6e\u4e3a lines \u6765\u7ed8\u5236\u76f4\u7ebf\u3002\u5982\u679c shape \u503c\u4e3a cross\uff0c\u5219\u5e93\u5c06\u7ed8\u5236\u4e24\u6761\u5782\u76f4\u7ebf\uff1b\u5982\u679c shape \u503c\u4e3a equal\u3002\u540c\u6837\uff0c\u53ef\u4ee5\u901a\u8fc7\u5c06\u5c5e\u6027\u503c\u8bbe\u7f6e\u4e3a zigzag \u6765\u521b\u5efa\u952f\u9f7f\u7ebf\u3002<\/p>\n<p>\u5f62\u72b6\u5bf9\u8c61\u8fd8\u6709\u4e00\u4e2a points \u5c5e\u6027\uff0c\u8be5\u5c5e\u6027\u5bf9\u4e8e\u4e0d\u540c\u7684\u5f62\u72b6\u5177\u6709\u4e0d\u540c\u7684\u542b\u4e49\u3002\u5b83\u786e\u5b9a polygon \u5f62\u72b6\u4e2d\u7684\u603b\u8fb9\u6570\u548c equal \u5f62\u72b6\u4e2d\u7684\u5e73\u884c\u7ebf\u603b\u6570\u3002 points \u5c5e\u6027\u4e5f\u53ef\u7528\u4e8e\u8bbe\u7f6e zigzag \u7ebf\u7684\u5f2f\u66f2\u6570\u91cf\u3002<\/p>\n<p>\u6b63\u5982\u6211\u4e4b\u524d\u63d0\u5230\u7684\uff0cmojs \u4f7f\u7528 SVG \u521b\u5efa\u6240\u6709\u8fd9\u4e9b\u5f62\u72b6\u3002\u8fd9\u610f\u5473\u7740 Shape \u5bf9\u8c61\u8fd8\u5c06\u5177\u6709\u4e00\u4e9b SVG \u7279\u5b9a\u5c5e\u6027\u6765\u63a7\u5236\u8fd9\u4e9b\u5f62\u72b6\u7684\u5916\u89c2\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528 fill \u5c5e\u6027\u8bbe\u7f6e mojs \u5f62\u72b6\u7684\u586b\u5145\u989c\u8272\u3002\u5f53\u672a\u6307\u5b9a\u989c\u8272\u65f6\uff0c\u5e93\u5c06\u4f7f\u7528 deepink \u989c\u8272\u6765\u586b\u5145\u5f62\u72b6\u3002\u540c\u6837\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 Stroke \u5c5e\u6027\u6307\u5b9a\u5f62\u72b6\u7684\u63cf\u8fb9\u989c\u8272\u3002\u5f53\u672a\u6307\u5b9a\u63cf\u8fb9\u989c\u8272\u65f6\uff0cmojs \u4f1a\u4fdd\u6301\u63cf\u8fb9\u900f\u660e\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528 fillOpacity \u548c StrokeOpacity \u5c5e\u6027\u63a7\u5236\u5f62\u72b6\u7684\u586b\u5145\u548c\u63cf\u8fb9\u4e0d\u900f\u660e\u5ea6\u3002\u5b83\u4eec\u53ef\u4ee5\u662f 0 \u5230 1 \u4e4b\u95f4\u7684\u4efb\u4f55\u503c\u3002<\/p>\n<p>Mojs \u8fd8\u5141\u8bb8\u60a8\u63a7\u5236\u5f62\u72b6\u7684\u5176\u4ed6\u4e0e\u63cf\u8fb9\u76f8\u5173\u7684\u5c5e\u6027\u3002\u4f8b\u5982\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 StrokeDasharray \u5c5e\u6027\u6307\u5b9a\u7b14\u5212\u8def\u5f84\u4e2d\u7684\u7834\u6298\u53f7\u548c\u95f4\u9699\u7684\u6a21\u5f0f\u3002\u6b64\u5c5e\u6027\u63a5\u53d7\u5b57\u7b26\u4e32\u548c\u6570\u5b57\u4f5c\u4e3a\u6709\u6548\u503c\u3002\u5b83\u7684\u9ed8\u8ba4\u503c\u4e3a\u96f6\uff0c\u8fd9\u610f\u5473\u7740\u7b14\u5212\u5c06\u662f\u5b9e\u7ebf\u3002\u53ef\u4ee5\u4f7f\u7528 StrokeWidth \u5c5e\u6027\u6307\u5b9a\u7b14\u753b\u7684\u5bbd\u5ea6\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u6240\u6709\u7b14\u753b\u7684\u5bbd\u5ea6\u5747\u4e3a 2px\u3002\u53ef\u4ee5\u4f7f\u7528 StrokeLinecap \u5c5e\u6027\u6307\u5b9a\u4e0d\u540c\u7ebf\u6761\u7aef\u70b9\u5904\u7684\u5f62\u72b6\u3002 StrokeLinecap \u7684\u6709\u6548\u503c\u4e3a butt\u3001round \u548c square\u3002<\/p>\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u60a8\u521b\u5efa\u7684\u4efb\u4f55\u5f62\u72b6\u90fd\u4f1a\u653e\u7f6e\u5728\u5176\u7236\u5143\u7d20\u7684\u4e2d\u5fc3\u3002\u8fd9\u662f\u56e0\u4e3a\u5f62\u72b6\u7684 left \u548c right \u5c5e\u6027\u5747\u8bbe\u7f6e\u4e3a 50%\u3002\u60a8\u53ef\u4ee5\u66f4\u6539\u8fd9\u4e9b\u5c5e\u6027\u7684\u503c\u4ee5\u5c06\u5143\u7d20\u653e\u7f6e\u5728\u4e0d\u540c\u7684\u4f4d\u7f6e\u3002\u63a7\u5236\u5f62\u72b6\u4f4d\u7f6e\u7684\u53e6\u4e00\u79cd\u65b9\u6cd5\u662f\u501f\u52a9 x \u548c y \u5c5e\u6027\u3002\u5b83\u4eec\u5206\u522b\u786e\u5b9a\u5f62\u72b6\u5e94\u5728\u6c34\u5e73\u548c\u5782\u76f4\u65b9\u5411\u4e0a\u79fb\u52a8\u591a\u5c11\u3002<\/p>\n<p>\u60a8\u53ef\u4ee5\u4f7f\u7528 radius \u5c5e\u6027\u6307\u5b9a\u5f62\u72b6\u7684\u534a\u5f84\u3002\u8be5\u503c\u7528\u4e8e\u786e\u5b9a\u7279\u5b9a\u5f62\u72b6\u7684\u5927\u5c0f\u3002\u60a8\u8fd8\u53ef\u4ee5\u4f7f\u7528 radiusX \u548c radiusY \u6307\u5b9a\u5f62\u72b6\u5728\u7279\u5b9a\u65b9\u5411\u4e0a\u7684\u5927\u5c0f\u3002\u63a7\u5236\u5f62\u72b6\u5927\u5c0f\u7684\u53e6\u4e00\u79cd\u65b9\u6cd5\u662f\u501f\u52a9 scale \u5c5e\u6027\u3002 scale \u7684\u9ed8\u8ba4\u503c\u4e3a 1\uff0c\u4f46\u60a8\u53ef\u4ee5\u5c06\u5176\u8bbe\u7f6e\u4e3a\u60a8\u559c\u6b22\u7684\u4efb\u4f55\u5176\u4ed6\u6570\u5b57\u3002\u60a8\u8fd8\u53ef\u4ee5\u4f7f\u7528 scaleX \u548c scaleY \u5c5e\u6027\u5728\u7279\u5b9a\u65b9\u5411\u4e0a\u7f29\u653e\u5f62\u72b6\u3002<\/p>\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5f62\u72b6\u7684\u6240\u6709\u8fd9\u4e9b\u53d8\u6362\u7684\u539f\u70b9\u90fd\u662f\u5176\u4e2d\u5fc3\u3002\u4f8b\u5982\uff0c\u5982\u679c\u901a\u8fc7\u6307\u5b9a angle \u5c5e\u6027\u7684\u503c\u6765\u65cb\u8f6c\u4efb\u4f55\u5f62\u72b6\uff0c\u5219\u8be5\u5f62\u72b6\u5c06\u7ed5\u5176\u4e2d\u5fc3\u65cb\u8f6c\u3002\u5982\u679c\u8981\u56f4\u7ed5\u5176\u4ed6\u70b9\u65cb\u8f6c\u5f62\u72b6\uff0c\u53ef\u4ee5\u4f7f\u7528 origin \u5c5e\u6027\u6307\u5b9a\u5b83\u3002\u6b64\u5c5e\u6027\u63a5\u53d7\u5b57\u7b26\u4e32\u4f5c\u4e3a\u5176\u503c\u3002\u5c06\u5176\u8bbe\u7f6e\u4e3a &#8216;0% 0%&#8217; \u5c06\u56f4\u7ed5\u5176\u5de6\u4e0a\u89d2\u65cb\u8f6c\u3001\u7f29\u653e\u6216\u5e73\u79fb\u5f62\u72b6\u3002\u540c\u6837\uff0c\u5c06\u5176\u8bbe\u7f6e\u4e3a &#8216;50% 0%&#8217; \u5c06\u56f4\u7ed5\u5176\u9876\u90e8\u8fb9\u7f18\u7684\u4e2d\u5fc3\u65cb\u8f6c\u3001\u7f29\u653e\u6216\u5e73\u79fb\u5f62\u72b6\u3002<\/p>\n<p>\u60a8\u53ef\u4ee5\u4f7f\u7528\u6211\u4eec\u521a\u521a\u8ba8\u8bba\u7684\u6240\u6709\u8fd9\u4e9b\u5c5e\u6027\u6765\u521b\u5efa\u5404\u79cd\u5f62\u72b6\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u793a\u4f8b\uff1a<\/p>\n<pre>var circleA = new mojs.Shape({\n  parent: \".container\",\n  shape: \"circle\",\n  left: 0,\n  fill: \"orange\",\n  stroke: \"black\",\n  strokeWidth: 5,\n  isShowStart: true\n});\n\nvar circleB = new mojs.Shape({\n  parent: \".container\",\n  shape: \"circle\",\n  left: 175,\n  fill: \"orange\",\n  stroke: \"red\",\n  radiusX: 80,\n  strokeWidth: 25,\n  strokeDasharray: 2,\n  isShowStart: true\n});\n\nvar rectA = new mojs.Shape({\n  parent: \".container\",\n  shape: \"rect\",\n  left: 350,\n  fill: \"red\",\n  stroke: \"black\",\n  strokeWidth: 5,\n  isShowStart: true\n});\n\nvar rectB = new mojs.Shape({\n  parent: \".container\",\n  shape: \"rect\",\n  left: 500,\n  fill: \"blue\",\n  stroke: \"blue\",\n  radiusX: 40,\n  radiusY: 100,\n  strokeWidth: 25,\n  strokeDasharray: 20,\n  isShowStart: true\n});\n\nvar polyA = new mojs.Shape({\n  parent: \".container\",\n  shape: \"polygon\",\n  top: 300,\n  left: 0,\n  fill: \"yellow\",\n  stroke: \"black\",\n  strokeWidth: 10,\n  points: 8,\n  isShowStart: true\n});\n\nvar polyB = new mojs.Shape({\n  parent: \".container\",\n  shape: \"polygon\",\n  top: 350,\n  left: 175,\n  radiusX: 100,\n  radiusY: 100,\n  fill: \"violet\",\n  stroke: \"black\",\n  strokeWidth: 6,\n  strokeDasharray: \"15, 10, 5, 10\",\n  strokeLinecap: \"round\",\n  points: 3,\n  isShowStart: true\n});\n\nvar lineA = new mojs.Shape({\n  parent: \".container\",\n  shape: \"cross\",\n  top: 350,\n  left: 375,\n  stroke: \"red\",\n  strokeWidth: 40,\n  isShowStart: true\n});\n\nvar zigzagA = new mojs.Shape({\n  parent: \".container\",\n  shape: \"zigzag\",\n  top: 500,\n  left: 50,\n  fill: \"transparent\",\n  stroke: \"black\",\n  strokeWidth: 4,\n  radiusX: 100,\n  points: 10,\n  isShowStart: true\n});\n\nvar zigzagB = new mojs.Shape({\n  parent: \".container\",\n  shape: \"zigzag\",\n  top: 500,\n  left: 350,\n  fill: \"blue\",\n  stroke: \"transparent\",\n  radiusX: 100,\n  points: 50,\n  isShowStart: true\n});\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4e0a\u9762\u4ee3\u7801\u521b\u5efa\u7684\u5f62\u72b6\u5982\u4e0b\u9762\u7684 CodePen \u6f14\u793a\u6240\u793a\uff1a<\/p>\n<\/p>\n<h2>\u5728 Mojs \u4e2d\u5bf9\u5f62\u72b6\u8fdb\u884c\u52a8\u753b\u5904\u7406<\/h2>\n<p>\u60a8\u53ef\u4ee5\u4e3a\u6211\u4eec\u5728\u4e0a\u4e00\u8282\u4e2d\u8ba8\u8bba\u7684\u5f62\u72b6\u7684\u51e0\u4e4e\u6240\u6709\u5c5e\u6027\u8bbe\u7f6e\u52a8\u753b\u3002\u4f8b\u5982\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u6307\u5b9a\u4e0d\u540c\u7684\u521d\u59cb\u503c\u548c\u6700\u7ec8\u503c\u6765\u5bf9\u591a\u8fb9\u5f62\u4e2d\u7684\u70b9\u6570\u8fdb\u884c\u52a8\u753b\u5904\u7406\u3002\u60a8\u8fd8\u53ef\u4ee5\u5c06\u5f62\u72b6\u7684\u539f\u70b9\u4ece &#8216;50% 50%&#8217; \u66f4\u6539\u4e3a\u4efb\u4f55\u5176\u4ed6\u503c\uff0c\u4f8b\u5982 &#8216;75% 75%&#8217;\u3002 angle \u548c scale \u7b49\u5176\u4ed6\u5c5e\u6027\u7684\u884c\u4e3a\u4e0e Html \u6a21\u5757\u4e2d\u7684\u884c\u4e3a\u76f8\u540c\u3002 <\/p>\n<p>\u4e0d\u540c\u52a8\u753b\u7684\u6301\u7eed\u65f6\u95f4\u3001\u5ef6\u8fdf\u548c\u901f\u5ea6\u53ef\u4ee5\u5206\u522b\u4f7f\u7528 duration\u3001delay \u548c speed \u5c5e\u6027\u6765\u63a7\u5236\u3002 Repeat \u5c5e\u6027\u7684\u5de5\u4f5c\u65b9\u5f0f\u4e5f\u4e0e Html \u6a21\u5757\u4e2d\u7684\u5de5\u4f5c\u65b9\u5f0f\u76f8\u540c\u3002\u5982\u679c\u53ea\u60f3\u64ad\u653e\u4e00\u6b21\u52a8\u753b\uff0c\u53ef\u4ee5\u5c06\u5176\u8bbe\u7f6e\u4e3a 0\u3002\u540c\u6837\uff0c\u60a8\u53ef\u4ee5\u5c06\u5176\u8bbe\u7f6e\u4e3a3\u4ee5\u64ad\u653e\u52a8\u753b4\u6b21\u3002\u5bf9 Html \u6a21\u5757\u6709\u6548\u7684\u6240\u6709\u7f13\u52a8\u503c\u4e5f\u5bf9 Shape \u6a21\u5757\u6709\u6548\u3002<\/p>\n<p>\u8fd9\u4e24\u4e2a\u6a21\u5757\u7684\u52a8\u753b\u529f\u80fd\u4e4b\u95f4\u7684\u552f\u4e00\u533a\u522b\u662f\uff0c\u60a8\u65e0\u6cd5\u4e3a Shape \u6a21\u5757\u4e2d\u7684\u5c5e\u6027\u5355\u72ec\u6307\u5b9a\u52a8\u753b\u53c2\u6570\u3002\u60a8\u8bbe\u7f6e\u52a8\u753b\u7684\u6240\u6709\u5c5e\u6027\u90fd\u5c06\u5177\u6709\u76f8\u540c\u7684\u6301\u7eed\u65f6\u95f4\u3001\u5ef6\u8fdf\u3001\u91cd\u590d\u6b21\u6570\u7b49\u3002<\/p>\n<p>\u4e0b\u9762\u662f\u6211\u4eec\u5bf9\u5706\u7684 x \u4f4d\u7f6e\u3001\u6bd4\u4f8b\u548c\u89d2\u5ea6\u8fdb\u884c\u52a8\u753b\u5904\u7406\u7684\u793a\u4f8b\uff1a<\/p>\n<pre>var circleA = new mojs.Shape({\n  parent: \".container\",\n  shape: \"circle\",\n  left: 175,\n  fill: \"red\",\n  stroke: \"black\",\n  strokeWidth: 100,\n  strokeDasharray: 18,\n  isShowStart: true,\n  x: {\n    0: 300\n  },\n  angle: {\n    0: 360\n  },\n  scale: {\n    0.5: 1.5\n  },\n  duration: 1000,\n  repeat: 10,\n  isYoyo: true,\n  easing: \"quad.in\"\n});\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u63a7\u5236\u4e0d\u540c\u52a8\u753b\u64ad\u653e\u7684\u4e00\u79cd\u65b9\u6cd5\u662f\u4f7f\u7528 .then() \u65b9\u6cd5\u6765\u6307\u5b9a\u5728\u7b2c\u4e00\u4e2a\u52a8\u753b\u5e8f\u5217\u5b8c\u5168\u5b8c\u6210\u540e\u8981\u8bbe\u7f6e\u52a8\u753b\u7684\u4e00\u7ec4\u65b0\u5c5e\u6027\u3002\u60a8\u53ef\u4ee5\u5728 .then() \u4e2d\u4e3a\u6240\u6709\u52a8\u753b\u5c5e\u6027\u6307\u5b9a\u65b0\u7684\u521d\u59cb\u503c\u548c\u6700\u7ec8\u503c\u3002\u8fd9\u662f\u4e00\u4e2a\u4f8b\u5b50\uff1a<\/p>\n<pre>var polyA = new mojs.Shape({\n  parent: \".container\",\n  shape: \"polygon\",\n  fill: \"red\",\n  stroke: \"black\",\n  isShowStart: true,\n  points: 4,\n  left: 100,\n  x: {\n    0: 500\n  },\n  strokeWidth: {\n    5: 2\n  },\n  duration: 2000,\n  easing: 'elastic.in'\n}).then({\n  strokeWidth: 5,\n  points: {\n    4: 3\n  },\n  angle: {\n    0: 720\n  },\n  scale: {\n    1: 2\n  },\n  fill: {\n    'red': 'yellow'\n  },\n  duration: 1000,\n  delay: 200,\n  easing: 'elastic.out'\n});\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<h2>\u6700\u7ec8\u60f3\u6cd5<\/h2>\n<p>\u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u5b66\u4e60\u4e86\u5982\u4f55\u4f7f\u7528 mojs \u521b\u5efa\u4e0d\u540c\u7684\u5f62\u72b6\u4ee5\u53ca\u5982\u4f55\u4e3a\u8fd9\u4e9b\u5f62\u72b6\u7684\u5c5e\u6027\u8bbe\u7f6e\u52a8\u753b\u3002 <\/p>\n<p>Shape \u6a21\u5757\u5177\u6709 Html \u6a21\u5757\u7684\u6240\u6709\u52a8\u753b\u529f\u80fd\u3002\u552f\u4e00\u7684\u533a\u522b\u662f\u5c5e\u6027\u4e0d\u80fd\u5355\u72ec\u8bbe\u7f6e\u52a8\u753b\u3002\u5b83\u4eec\u53ea\u80fd\u4f5c\u4e3a\u4e00\u4e2a\u7ec4\u8fdb\u884c\u52a8\u753b\u5904\u7406\u3002\u60a8\u8fd8\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528\u4e0d\u540c\u7684\u65b9\u6cd5\u968f\u65f6\u64ad\u653e\u3001\u6682\u505c\u3001\u505c\u6b62\u548c\u6062\u590d\u52a8\u753b\u6765\u63a7\u5236\u52a8\u753b\u64ad\u653e\u3002\u6211\u5728\u672c\u7cfb\u5217\u7684\u7b2c\u4e00\u7bc7\u6559\u7a0b\u4e2d\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u8fd9\u4e9b\u65b9\u6cd5\u3002<\/p>\n<p>\u5982\u679c\u60a8\u5bf9\u672c\u6559\u7a0b\u6709\u4efb\u4f55\u7591\u95ee\uff0c\u8bf7\u968f\u65f6\u53d1\u8868\u8bc4\u8bba\u3002\u5728\u4e0b\u4e00\u4e2a\u6559\u7a0b\u4e2d\uff0c\u60a8\u5c06\u4e86\u89e3 mojs \u4e2d\u7684 ShapeSwirl \u548c stagger \u6a21\u5757\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u4ece Mojs \u52a8\u753b\u5e93\u5f00\u59cb\uff1a\u63a2\u7d22\u5f62\u72b6\u6a21\u5757\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u4e0a\u4e00\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528 mojs \u4e3a\u7f51\u9875\u4e0a\u7684\u4e0d\u540c HTML \u5143\u7d20\u6dfb\u52a0\u52a8\u753b\u6548\u679c\u3002\u6211\u4eec\u4f7f\u7528\u8be5\u5e93\u4e3b\u8981\u5bf9\u770b\u8d77\u6765\u50cf\u6b63\u65b9\u5f62\u6216\u5706\u5f62\u7684 div \u5143\u7d20\u8fdb\u884c\u52a8\u753b\u5904\u7406\u3002\u4f46\u662f\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 Html \u6a21\u5757\u6765\u4e3a\u56fe\u50cf\u6216\u6807\u9898\u7b49\u5404\u79cd\u5143\u7d20\u8bbe\u7f6e\u52a8\u753b\u3002\u5982\u679c\u60a8\u786e\u5b9e\u6253\u7b97\u4f7f\u7528 mojs \u5bf9\u57fa\u672c\u5f62\u72b6\u8fdb\u884c\u52a8\u753b\u5904\u7406\uff0c\u90a3\u4e48\u60a8\u53ef\u80fd\u5e94\u8be5\u4f7f\u7528\u5e93\u4e2d\u7684 Shape \u6a21\u5757\u3002 Shape \u6a21\u5757\u5141\u8bb8\u60a8\u4f7f\u7528 SVG \u5728 DOM \u4e2d\u521b\u5efa\u57fa\u672c\u5f62\u72b6\u3002\u60a8\u6240\u8981\u505a\u7684\u5c31\u662f\u6307\u5b9a\u8981\u521b\u5efa\u7684\u5f62\u72b6\u7c7b\u578b\uff0cmojs \u4f1a\u5904\u7406\u5269\u4e0b\u7684\u4e8b\u60c5\u3002\u8be5\u6a21\u5757\u8fd8\u5141\u8bb8\u60a8\u4e3a\u60a8\u521b\u5efa\u7684\u4e0d\u540c\u5f62\u72b6\u8bbe\u7f6e\u52a8\u753b\u3002 \u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u5c06\u4ecb\u7ecd Shape \u6a21\u5757\u7684\u57fa\u7840\u77e5\u8bc6\uff0c\u4ee5\u53ca\u5982\u4f55\u4f7f\u7528\u5b83\u6765\u521b\u5efa\u4e0d\u540c\u7684\u5f62\u72b6\u5e76\u4e3a\u5176\u8bbe\u7f6e\u52a8\u753b\u3002 \u5728 Mojs \u4e2d\u521b\u5efa\u5f62\u72b6 \u60a8\u9700\u8981\u5b9e\u4f8b\u5316 mojs Shape \u5bf9\u8c61\u624d\u80fd\u521b\u5efa\u4e0d\u540c\u7684\u5f62\u72b6\u3002\u8be5\u5bf9\u8c61\u5c06\u63a5\u53d7\u4e0d\u540c\u7684\u53c2\u6570\uff0c\u8fd9\u4e9b\u53c2\u6570\u53ef\u7528\u4e8e\u63a7\u5236\u60a8\u521b\u5efa\u7684\u5f62\u72b6\u7684\u989c\u8272\u3001\u5927\u5c0f\u3001\u89d2\u5ea6\u7b49\u3002 \u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u60a8\u521b\u5efa\u7684\u4efb\u4f55\u5f62\u72b6\u90fd\u5c06\u4f7f\u7528\u6587\u6863\u6b63\u6587\u4f5c\u4e3a\u5176\u7236\u7ea7\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528 parent \u5c5e\u6027\u5c06\u4efb\u4f55\u5176\u4ed6\u5143\u7d20\u6307\u5b9a\u4e3a\u5176\u7236\u5143\u7d20\u3002\u60a8\u8fd8\u53ef\u4ee5\u501f\u52a9 className \u5c5e\u6027\u4e3a\u60a8\u521b\u5efa\u7684\u4efb\u4f55\u5f62\u72b6\u5206\u914d\u4e00\u4e2a\u7c7b\u3002\u5982\u679c\u60a8\u8df3\u8fc7\u6b64\u5c5e\u6027\uff0c\u5e93\u5c06\u4e0d\u4f1a\u5206\u914d\u4efb\u4f55\u9ed8\u8ba4\u7c7b\u3002 Mojs \u5185\u7f6e\u4e86\u516b\u79cd\u4e0d\u540c\u7684\u5f62\u72b6\uff0c\u56e0\u6b64\u60a8\u53ef\u4ee5\u901a\u8fc7\u4e3a shape \u5c5e\u6027\u8bbe\u7f6e\u503c\u6765\u76f4\u63a5\u521b\u5efa\u5b83\u4eec\u3002\u60a8\u53ef\u4ee5\u5c06\u5176\u503c\u8bbe\u7f6e\u4e3a circle \u521b\u5efa\u5706\u5f62\uff0crect \u521b\u5efa\u77e9\u5f62\uff0cpolygon \u521b\u5efa\u591a\u8fb9\u5f62\u3002\u60a8\u8fd8\u53ef\u4ee5\u901a\u8fc7\u5c06 shape \u7684\u503c\u8bbe\u7f6e\u4e3a lines \u6765\u7ed8\u5236\u76f4\u7ebf\u3002\u5982\u679c shape \u503c\u4e3a cross\uff0c\u5219\u5e93\u5c06\u7ed8\u5236\u4e24\u6761\u5782\u76f4\u7ebf\uff1b\u5982\u679c shape \u503c\u4e3a equal\u3002\u540c\u6837\uff0c\u53ef\u4ee5\u901a\u8fc7\u5c06\u5c5e\u6027\u503c\u8bbe\u7f6e\u4e3a zigzag \u6765\u521b\u5efa\u952f\u9f7f\u7ebf\u3002 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-32700","post","type-post","status-publish","format-standard","hentry","category-cms"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/32700","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=32700"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/32700\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=32700"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=32700"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=32700"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}