{"id":5081,"date":"2015-12-05T20:08:35","date_gmt":"2015-12-05T12:08:35","guid":{"rendered":"http:\/\/www.zhangxinxu.com\/wordpress\/?p=5081"},"modified":"2023-05-04T22:48:30","modified_gmt":"2023-05-04T14:48:30","slug":"css3-animation-js-canvas-gif-pause-stop-play","status":"publish","type":"post","link":"https:\/\/www.zhangxinxu.com\/wordpress\/2015\/12\/css3-animation-js-canvas-gif-pause-stop-play\/","title":{"rendered":"CSS\u6216JS\u5b9e\u73b0gif\u52a8\u6001\u56fe\u7247\u7684\u505c\u6b62\u4e0e\u64ad\u653e"},"content":{"rendered":"<p>by <a href=\"http:\/\/www.zhangxinxu.com\/\">zhangxinxu<\/a> from <a href=\"http:\/\/www.zhangxinxu.com\/\">http:\/\/www.zhangxinxu.com<\/a><br \/>\n\u672c\u6587\u5730\u5740\uff1a<a href=\"http:\/\/www.zhangxinxu.com\/wordpress\/?p=5081\">http:\/\/www.zhangxinxu.com\/wordpress\/?p=5081<\/a><\/p>\n<p><meta name=\"referrer\" content=\"no-referrer\"><\/p>\n<h3>\u4e00\u3001\u5c4b\u5916\uff1a\u5bd2\u98ce\u5439\uff0c\u96ea\u82b1\u98d8\uff1b\u5c4b\u5185\uff1a\u7a7a\u8c03\u5439\uff0c\u4ee3\u7801\u98d8<\/h3>\n<p>\u4e0a\u5348\u51fa\u53bb\u4e70\u83dc\uff0c\u6b63\u597d\u4e0b\u96e8\u4e86\uff0c\u8fd8\u5939\u6742\u7740\u51b0\u73e0\u5b50\u3002\u9119\u4eba\u5927\u610f\uff0c\u7a7f\u7684\u662f\u4e00\u4ef6\u5e05\u6c14\u4f46\u5355\u8584\u7684\u9ec4\u8272\u5927\u8863\uff0c\u7acb\u9a6c\u51bb\u6210\u4e86\u4e2d\u534e\u7530\u56ed\u72ac\u3002\u539f\u672c\u8ba1\u5212\u53bb\u9493\u9c7c\u7684\uff0c\u79d1\u79d1\uff0c\u4f5c\u7f62\uff0c\u4e0a\u5348\u5728\u5bb6\u770bCCTV5 \u9a91\u58eb\u961fvs\u9e48\u9e55\u961f\uff0c\u4e0b\u5348\u8865\u52a8\u6f2b\u7801\u4ee3\u7801\u505a\u6587\u7ae0\uff0c\u597d\u751f\u60ec\u610f\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201512\/dog-cold-s.jpg\" width=\"250\" height=\"220\" alt=\"\u51bb\u6210\u4e86\u4e2d\u534e\u7530\u56ed\u72ac\" class=\"alignnone\" \/><\/p>\n<p>\u5bf9\u4e8e\u4e60\u60ef\u6027\u5237\u5fae\u535a\u7684\u6211\uff0c\u603b\u65f6\u4e0d\u65f6\u4f1a\u770b\u5230\u7c7b\u4f3c\u4e0b\u9762\u7684\u6e38\u620f\uff1a<\/p>\n<blockquote><p>\u6d4b\u6d4b\u4f60\u4eca\u5929\u4f1a\u53d1\u751f\u4ec0\u4e48\uff1fie\u6d4f\u89c8\u5668\u7684\u540c\u5b66\u53ef\u4ee5\u6309esc\u952e(\u6216\u622a\u5c4f)\uff0c\u636e\u8bf4\u5728\u54ea\u4e2a\u8bcd\u6682\u505c\uff0c\u54ea\u4e2a\u8bcd\u5c31\u662f\u4f60\u54e6\uff01<img decoding=\"async\" src=\"http:\/\/img.t.sinajs.cn\/t4\/appstyle\/expression\/ext\/normal\/0b\/tootha_org.gif\" title=\"[\u563b\u563b]\" alt=\"[\u563b\u563b]\" type=\"face\"><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202305\/esc.gif\" width=\"150\" height=\"450\" alt=\"\u4eba\u7279\u8d28gif\u52a8\u753b\" class=\"alignnone\" \/><\/p><\/blockquote>\n<p>OK, \u8fd9\u91cc\u51fa\u73b0\u4e00\u4e2a\u6d4f\u89c8\u5668\u7279\u6027\uff0c\u5c31\u662f\u901a\u8fc7ESC\u5feb\u6377\u952e\uff0c\u6682\u505cgif\u7684\u64ad\u653e\u3002\u636e\u8bf4FireFox\u6d4f\u89c8\u5668\u4ee5\u524d\u4e5f\u6709\uff0c\u540e\u6765\u88ab\u5e72\u6389\u4e86\uff0c\u6839\u636e<a href=\"http:\/\/weibo.com\/u\/1708684567\" target=\"_blank\">@\u7d2b\u4e91\u5983<\/a>\u7684\u8bf4\u6cd5\u662f\uff1a<\/p>\n<blockquote><p>\u662f\u8fd9\u6837\u7684,Firefox\u539f\u6765\u7684\u8868\u73b0\u662f:\u5728\u9875\u9762load\u4e8b\u4ef6\u5b8c\u6210,\u540c\u65f6x\u6309\u94ae\u53d8\u6210\u5237\u65b0\u6309\u94ae\u4e4b\u540e,esc\u4ecd\u7136\u6709\u51e0\u4e2a\u4f5c\u7528,\u4e2d\u65ad\u5f53\u524d\u6b63\u5728\u53d1\u9001\u7684ajax\u3001websocket\uff0c\u505c\u6b62gif\u3001apng\u52a8\u753b\u7684\u64ad\u653e.\u4f46\u8fd9\u4e9b\u529f\u80fd\u592a\u5c0f\u4f17\u4e86,\u5f71\u54cd\u4e86\u666e\u901a\u7528\u6237\u7684\u4f7f\u7528,\u53ef\u80fd\u4e0d\u5c0f\u5fc3\u6309\u4e86esc,\u7ed3\u679cajax\u65ad\u4e86,\u7f51\u9875\u51fa\u9519\u4e86.\u6240\u4ee5Firefox20\u4fee\u6539\u6210\uff1a\u7f51\u9875\u52a0\u8f7d\u5b8c\u6210\u540e\uff0cesc\u952e\u5b8c\u5168\u5931\u6548.<\/p><\/blockquote>\n<p>\u7136\u800c\uff0c\u8fd9\u79cd\u9690\u6666\u7684\u4f46\u4f3c\u4e4e\u4f1a\u5f71\u54cd\u6b63\u5e38\u529f\u80fd\u7684\u5c0f\u6280\u5de7\u663e\u7136\u662f\u65e0\u6cd5\u5b9e\u73b0\u771f\u6b63\u610f\u4e49\u4e0a\u7684gif\u52a8\u6001\u56fe\u7247\u7684\u505c\u6b62\u4e0e\u64ad\u653e\u7684\u3002\u4e00\u662f\u517c\u5bb9\u6027\uff0c\u4e8c\u662f\u529f\u80fd\u6027\uff0c\u4e09\u662f\u79fb\u52a8\u7aef\u6ca1\u6709ESC\u952e\u3002<\/p>\n<p>\u6240\u4ee5\uff0c\u5982\u679c\u6211\u4eec\u9047\u5230\u9700\u8981\u53ef\u4ee5\u968f\u65f6\u968f\u5730\u505c\u6b62gif\u52a8\u6001\u56fe\u7247\u64ad\u653e\u7684\u9700\u6c42\u7684\u65f6\u5019\uff0c\u5c31\u9700\u8981\u5bfb\u627e\u5176\u4ed6\u7684\u51fa\u8def\u3002\u597d\uff0c\u5bd2\u51ac\u91cc\u7684\u6696\u8eab\u7ed3\u675f\uff0c\u5f00\u59cb\u8fdb\u5165\u6b63\u9898~~<\/p>\n<h3>\u4e8c\u3001gif\u56fe\u7247\u81ea\u5df1\u53ef\u63a7\u524d\u63d0\u4e0b\u7684\u65b9\u6cd5\u4e00\uff1a\u591aimg\u8d44\u6e90\u63a7\u5236\u5904\u7406<\/h3>\n<p>\u5047\u5982\u8bf4\uff0c\u6211\u4eec\u5e0c\u671b\u6682\u505c\u7684gif\u662f\u81ea\u5df1(\u5f00\u53d1\u4eba\u5458)\u4f20\u4e0a\u53bb\u7684\uff0c\u4e0d\u662f\u7528\u6237\u53ef\u4ee5\u968f\u673a\u4e0a\u4f20\u4e0d\u53ef\u63a7\u7684gif. \u6211\u4eec\u53ef\u4ee5\u8fd9\u4e48\u5904\u7406\uff0c\u5c31\u662f\u51c6\u59072\u5957\u56fe\u7247\uff0c\u4e00\u4e2a\u662fgif\u52a8\u6001\u56fe\u7247\uff0c\u8fd8\u6709\u4e00\u4e2a\u662f\u53ea\u6709\u4e00\u5e27\u7684\u9759\u6b62\u7684\u56fe\u7247\u3002\u7136\u540e\u4f7f\u7528JS\u6765\u56de\u5207\u6362<code>&lt;img&gt;<\/code>\u7684<code>src<\/code>\u503c\u4e3a\u8fd9\u4e24\u5f20\u56fe\u7247\u5730\u5740\u5c31\u597d\u4e86\u3002<\/p>\n<p>\u6b64\u65b9\u6cd5\u751a\u7b80\u5355\uff0c\u6211\u5c31\u4e0d\u653e\u5b9e\u4f8b\u4e86\u3002<\/p>\n<div class=\"zxx_code\">\n<pre>img.src=\"animate.gif\";\r\n<span style=\"color:green;\">\/\/ \u6216\u8005\u5448\u73b0\u7684\u662f<\/span>\r\nimg.src=\"static.png\";<\/pre>\n<\/div>\n<p>\u8fd9\u4e2a\u65b9\u6cd5\u6700\u5927\u7684\u4f18\u70b9\u5c31\u662f\u517c\u5bb9\u6027\u5f3a\uff0c\u6240\u6709\u6d4f\u89c8\u5668\u90fd\u53ef\u4ee5\u5b9e\u73b0\u505c\u6b62\u6548\u679c\u3002\u7136\u800c\uff0c\u8fd9\u79cd\u65b9\u6cd5\u6709\u4e2a\u5c40\u9650\uff0c\u5c31\u662f\uff0c\u6682\u505c\u65f6\u5019\u5448\u73b0\u7684\u56fe\u7247\u6c38\u8fdc\u662f\u540c\u4e00\u5f20\u3002\u57fa\u672c\u4e0a\u53ef\u4ee5\u8bf4\u662f\u505c\u6b62\uff0c\u800c\u4e0d\u662f\u6682\u505c\u3002<\/p>\n<p>\u90a3\u6709\u6ca1\u6709\u4ec0\u4e48\u65b9\u6cd5\u53ef\u4ee5\u771f\u6b63\u610f\u4e49\u4e0a\u7684\u6682\u505c\u5462\uff1f\u8fd8\u771f\u6709\uff01<\/p>\n<h3>\u4e09\u3001gif\u56fe\u7247\u81ea\u5df1\u53ef\u63a7\u524d\u63d0\u4e0b\u7684\u65b9\u6cd5\u4e8c\uff1aCSS3 animation\u63a7\u5236<\/h3>\n<p>\u4e5f\u5c31\u662f\u6211\u4eec\u770b\u5230\u7684gif\u6548\u679c\u5e76\u4e0d\u662f\u4e00\u4e2a\u771f\u6b63\u7684gif\u56fe\u7247\uff0c\u800c\u662f\u4f7f\u7528CSS3\u7684animation\u5c5e\u6027\u63a7\u5236\u5f62\u6210\u7684\u9010\u5e27\u52a8\u6001\u56fe\u7247\u6548\u679c\u3002\u6211\u641c\u4e86\u4e0b\uff0c<a href=\"http:\/\/weibo.com\/fengxiang366\" target=\"_blank\">@DO1\u8def\u4eba\u4e59<\/a>\u6709\u7bc7\u6587\u7ae0\u201c<a href=\"http:\/\/xiaoho.com\/css3-animations\/\" target=\"_blank\">css3-animation\u5236\u4f5c\u9010\u5e27\u52a8\u753b<\/a>\u201d\u4e13\u95e8\u4ecb\u7ecd\u4e86\u8fd9\u79cd\u6280\u672f\u3002\u8bf4\u7a7f\u4e86\u5c31\u662fanimation\u63a7\u5236Sprites\u56fe\u7247\u7684background-position\u503c\u6a21\u62dfgif\u6548\u679c\u3002<\/p>\n<p>\u4f8b\u5982\uff0c\u65b0\u7248twitter\u7684Like\u7684\u6548\u679c\uff0c\u8c8c\u4f3c\u5c31\u6709\u4f7f\u7528\u8be5\u6280\u672f\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202305\/like.gif\" width=\"220\" height=\"220\" alt=\"twitter\u7684Like\u6548\u679c\" class=\"alignnone\" \/><\/p>\n<p>\u4f7f\u7528CSS3 animation\u5b9e\u73b0\u7c7bgif\u6548\u679c\u7684\u597d\u5904\u5728\u4e8e\uff0c\u56fe\u7247\u53ef\u4ee5\u65e0\u635f\uff0c\u4e14\u6211\u4eec\u53ef\u4ee5\u5f88\u8f7b\u677e\u5730\u63a7\u5236\u56fe\u7247\u52a8\u753b\u7684\u6682\u505c\u548c\u64ad\u653e\uff0c\u4f7f\u7528\u7684\u662f\uff1a<code>animation-play-state: paused;<\/code>\u8fd9\u4e2a\u58f0\u660e\u3002<\/p>\n<p>\u60a8\u53ef\u4ee5\u72e0\u72e0\u5730\u70b9\u51fb\u8fd9\u91cc\uff1a<a class=\"a_link\" href=\"http:\/\/www.zhangxinxu.com\/study\/201512\/gif-stop-and-play-by-css3-animation.html\" target=\"_blank\">\u4f7f\u7528CSS3 animation\u5b9e\u73b0gif\u52a8\u56fe\u7684\u6682\u505c\u548c\u64ad\u653edemo<\/a><\/p>\n<p>\u70b9\u51fbdemo\u9875\u9762\u7684\u6682\u505c\u6309\u94ae\uff0c\u60a8\u4f1a\u53d1\u73b0\uff0c\u76f4\u63a5\u5c31\u505c\u4f4f\u4e86\uff0c\u5982\u4e0b\u622a\u56fe\u793a\u610f\uff0c\u622a\u81eaIE10\u6d4f\u89c8\u5668\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201512\/2015-12-05_191238.png\" width=\"333\" height=\"231\" alt=\"IE10\u6d4f\u89c8\u5668\u52a8\u753b\u6682\u505c\u622a\u56fe\" class=\"alignnone\" \/><\/p>\n<p>\u518d\u6b21\u70b9\u51fb\uff0c\u5c31\u4f1a\u5728\u6682\u505c\u753b\u9762\u4e4b\u540e\u7ee7\u7eed\u64ad\u653e\u4e86\u3002\u4ece\u800c\u5b9e\u73b0\u4e86\u6211\u4eec\u5bf9\u52a8\u753b\u56fe\u7247\u7684\u7cbe\u786e\u63a7\u5236\u6548\u679c\u3002<\/p>\n<p>\u6b64\u65b9\u6cd5\u770b\u4e0a\u53bb\u5b8c\u7f8e\uff0c\u4f46\u662f\uff0c1. IE10+\u7b49\u652f\u6301CSS3 animation\u7684\u6d4f\u89c8\u5668\u624d\u884c\uff1b2. \u6700\u5927\u7684\u95ee\u9898\u662f\u56fe\u7247\u9700\u8981\u662f\u81ea\u5df1\u63a7\u5236\uff0c\u5982\u679c\u60f3\u63a7\u5236\u7528\u6237\u4e0a\u4f20\u7684\u771f\u6b63\u610f\u4e49\u7684gif\u56fe\u7247\uff0c\u53ea\u80fd\u2026\u2026\u671b\u6d0b\u5174\u53f9\u2026\u2026\u2026\u2026\u2026\u2026\u2026\u2026\u5417\uff1f<\/p>\n<h3>\u56db\u3001\u81ea\u5df1\u65e0\u6cd5\u63a7\u5236\u7684gif\u56fe\u7247\u7684\u505c\u6b62\u4e0e\u64ad\u653e<\/h3>\n<p>\u6bd4\u65b9\u8bf4\uff0c\u9875\u9762\u4e0a\u7528\u6237\u4e0a\u4f20\u4e86\u4e9bgif\u56fe\u7247\uff0c\u54ce\u5440\uff0c\u95ea\u778e\u4e86\u6211\u7684\u4e2d\u534e\u7530\u56ed\u773c\uff0c\u6211\u8981\u5168\u90e8\u6682\u505c\uff0c\u80bf\u4e48\u529e\uff1f\u5982\u679c\u540e\u53f0\u540c\u5b66\u6ca1\u6709\u5bf9gif\u8fdb\u884c\u9759\u6001\u5904\u7406\uff0c\u6b64\u65f6\uff0c\u53ea\u80fd\u9760\u524d\u7aef\u5c0f\u4f19\u4f34\uff0c\u6709\u4ec0\u4e48\u529e\u6cd5\u5417\uff1f<\/p>\n<p>\u6709\u4e00\u4e2a\u3002HTML5 canvas\u53ef\u4ee5\u8bfb\u53d6\u56fe\u7247\u4fe1\u606f\uff0c\u7ed8\u5236\u5f53\u524d\u56fe\u7247\u3002\u4e8e\u662f\u53ef\u4ee5\u5b9e\u73b0\u56fe\u7247\u9a6c\u8d5b\u514b\uff0c\u6a21\u7cca\uff0c\u8272\u503c\u8fc7\u6ee4\u7b49\u5f88\u591a\u56fe\u7247\u7279\u6548\u3002\u6211\u4eec\u8fd9\u91cc\u4e0d\u7528\u90a3\u4e48\u590d\u6742\uff0c\u53ea\u8981\u8bfb\u53d6\u6211\u4eec\u7684\u56fe\u7247\uff0c\u91cd\u7ed8\u4e0b\u5c31\u53ef\u4ee5\u3002<\/p>\n<p>\u60a8\u53ef\u4ee5\u72e0\u72e0\u5730\u70b9\u51fb\u8fd9\u91cc\uff1a<a class=\"a_link\" href=\"http:\/\/www.zhangxinxu.com\/study\/201512\/gif-stop-and-play-by-js-canvas.html\" target=\"_blank\">\u4f7f\u7528JS\u548ccanvas\u5b9e\u73b0gif\u52a8\u56fe\u7684\u505c\u6b62\u548c\u64ad\u653edemo<\/a><\/p>\n<p>\u70b9\u51fb\u6309\u94ae\uff0c\u7136\u540e\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201512\/2015-12-05_193635.png\" width=\"431\" height=\"288\" alt=\"gif\u505c\u6b62\u4e2d\" class=\"alignnone\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201512\/2015-12-05_193718.png\" width=\"441\" height=\"288\" alt=\"gif\u56fe\u7247\u64ad\u653e\u4e2d\u2026\u2026\" class=\"alignnone\" \/><\/p>\n<p><strong>\u5982\u4f55\u4f7f\u7528\uff1f<\/strong><br \/>\n\u6211\u5bf9HTMLImageElement\u539f\u578b\u8fdb\u884c\u4e86\u6269\u5c55\uff0c\u589e\u52a0\u4e86<code>stop()<\/code>\u548c<code>play()<\/code>\u4e24\u4e2a\u65b9\u6cd5\uff0c\u5982\u4e0b\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>if ('getContext' in document.createElement('canvas')) {\r\n    HTMLImageElement.prototype.play = function() {\r\n        if (this.storeCanvas) {\r\n            <span style=\"color:green;\">\/\/ \u79fb\u9664\u5b58\u50a8\u7684canvas<\/span>\r\n            this.storeCanvas.parentElement.removeChild(this.storeCanvas);\r\n            this.storeCanvas = null;\r\n            <span style=\"color:green;\">\/\/ \u900f\u660e\u5ea6\u8fd8\u539f<\/span>\r\n            image.style.opacity = '';\r\n        }\r\n        if (this.storeUrl) {\r\n            this.src = this.storeUrl;    \r\n        }\r\n    };\r\n    HTMLImageElement.prototype.stop = function() {\r\n        var canvas = document.createElement('canvas');\r\n        <span style=\"color:green;\">\/\/ \u5c3a\u5bf8<\/span>\r\n        var width = this.width, height = this.height;\r\n        if (width && height) {\r\n            <span style=\"color:green;\">\/\/ \u5b58\u50a8\u4e4b\u524d\u7684\u5730\u5740<\/span>\r\n            if (!this.storeUrl) {\r\n                this.storeUrl = this.src;\r\n            }\r\n            <span style=\"color:green;\">\/\/ canvas\u5927\u5c0f<\/span>\r\n            canvas.width = width;\r\n            canvas.height = height;\r\n            <span style=\"color:green;\">\/\/ \u7ed8\u5236\u56fe\u7247\u5e27\uff08\u7b2c\u4e00\u5e27\uff09<\/span>\r\n            canvas.getContext('2d').drawImage(this, 0, 0, width, height);\r\n            <span style=\"color:green;\">\/\/ \u91cd\u7f6e\u5f53\u524d\u56fe\u7247<\/span>\r\n            try {\r\n                this.src = canvas.toDataURL(\"image\/gif\");\r\n            } catch(e) {\r\n                <span style=\"color:green;\">\/\/ \u8de8\u57df<\/span>\r\n                this.removeAttribute('src');\r\n                <span style=\"color:green;\">\/\/ \u8f7d\u5165canvas\u5143\u7d20<\/span>\r\n                canvas.style.position = 'absolute';\r\n                <span style=\"color:green;\">\/\/ \u524d\u9762\u63d2\u5165\u56fe\u7247<\/span>\r\n                this.parentElement.insertBefore(canvas, this);\r\n                <span style=\"color:green;\">\/\/ \u9690\u85cf\u539f\u56fe<\/span>\r\n                this.style.opacity = '0';\r\n                <span style=\"color:green;\">\/\/ \u5b58\u50a8canvas<\/span>\r\n                this.storeCanvas = canvas;\r\n            }\r\n        }\r\n    };\r\n}<\/pre>\n<\/div>\n<p>\u5927\u5bb6\u53ea\u8981\u5728\u9875\u9762\u4e2d\u81ea\u5df1\u7684JS\u6587\u4ef6\u4e2d\u590d\u5236\u4e0a\u9762\u7684\u4ee3\u7801\uff0c\u7136\u540e\u5c31\u53ef\u4ee5\u76f4\u63a5\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>var image = document.getElementsByTagName(\"img\")[0];\r\n<span style=\"color:green;\">\/\/ \u505c\u6b62gif\u56fe\u7247<\/span>\r\nimage.stop();\r\n<span style=\"color:green;\">\/\/ \u64ad\u653egif\u56fe\u7247<\/span>\r\nimage.play();<\/pre>\n<\/div>\n<p><span class=\"s\">\/\/zxx: \u4e0a\u9762\u4ee3\u7801\u5e76\u672a\u8be6\u5c3d\u6d4b\u8bd5\uff0c\u4ee5\u53ca\u53ef\u80fd\u7684\u4f53\u9a8c\u95ee\u9898\uff08IE\u95ea\u52a8\uff09\u6ca1\u6709\u5177\u4f53\u5904\u7406\uff08\u5f71\u54cd\u539f\u7406\u793a\u610f\uff09\uff0c\u82e5\u8981\u5b9e\u9645\u4f7f\u7528\uff0c\u9700\u8981\u81ea\u5df1\u518d\u5fae\u8c03\u5b8c\u7f8e\u4e0b\u3002<\/span><\/p>\n<p><strong>\u4e0d\u8db3<\/strong><br \/>\n1. IE9+\u652f\u6301\u3002IE7\/IE8\u4e0d\u652f\u6301canvas\u6ca1\u641e\u5934\u3002<br \/>\n2. \u53ea\u80fd\u505c\u6b62gif\uff0c\u4e0d\u80fd\u771f\u6b63\u610f\u4e49\u7684\u6682\u505c\u3002\u56e0\u4e3acanvas\u83b7\u5f97\u7684gif\u56fe\u7247\u4fe1\u606f\u4e3a\u7b2c\u4e00\u5e27\u7684\u4fe1\u606f\uff0c\u540e\u9762\u7684\u8c8c\u4f3c\u83b7\u53d6\u4e0d\u5230\u3002\u8981\u60f3\u5b9e\u73b0\u6682\u505c\uff0c\u800c\u4e0d\u662f\u505c\u6b62\uff0c\u8fd8\u9700\u8981\u8fdb\u4e00\u6b65\u7814\u7a76\uff0c\u5982\u679c\u4f60\u6709\u65b9\u6cd5\uff0c\u975e\u5e38\u6b22\u8fce\u5206\u4eab\u3002<\/p>\n<p><strong>\u66f4\u65b0\u4e8e2020-08-11<\/strong><\/p>\n<p>\u53ef\u4ee5\u8bd5\u8bd5\u4f7f\u7528libgif.js\u8fd9\u4e2a\u9879\u76ee\u5e93\u6682\u505cGIF\uff0c<a href=\"https:\/\/github.com\/buzzfeed\/libgif-js\">https:\/\/github.com\/buzzfeed\/libgif-js<\/a><\/p>\n<p>\u53ef\u4ee5\u5bf9GIF\u6587\u4ef6\u8fdb\u884c\u5b8c\u5168\u7684\u89e3\u6790\uff0c\u56e0\u6b64\uff0c\u6682\u505c\u5177\u4f53\u7684\u67d0\u4e00\u5e27\u4e0d\u5728\u8bdd\u4e0b\u3002<\/p>\n<p><strong>\u66f4\u65b0\u4e8e2021-09-12<\/strong><\/p>\n<p>\u5982\u679c\u60f3\u8981\u5bf9 APNG \u52a8\u56fe\u8fdb\u884c\u64ad\u653e\u4e0e\u6682\u505c\u8bbe\u7f6e\uff0c\u53ef\u4ee5\u53c2\u8003\u8fd9\u7bc7\u6587\u7ae0\u201c<a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/2021\/09\/apng-maker-pause-play-ie\/\">APNG\u5728\u7ebf\u5236\u4f5c\u3001\u517c\u5bb9\u3001\u64ad\u653e\u548c\u6682\u505c<\/a>\u201d\u3002<\/p>\n<h3>\u4e94\u3001\u7ed3\u675f\u8bed<\/h3>\n<p>\u662f\u80e1\u4e0d\u662f\u970d\uff0c\u662f\u970d\u8eb2\u4e0d\u8fc7\uff01\u54c8\u54c8\uff01<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202305\/2023-05-04_224420.jpg\" width=\"194\" height=\"133\" alt=\"\u662f\u80e1\u4e0d\u662f\u970d\uff0c\u662f\u970d\u8eb2\u4e0d\u8fc7\uff01\" class=\"alignnone\" \/><\/p>\n<p>\u4e0a\u9762\u8fd9\u4e2agif\u4e5f\u662fdemo\u793a\u610fgif\u5f3a\u529b\u5019\u9009\u3002\u540e\u6765\u4e00\u7422\u78e8\uff0c\u770b\u6211\u6587\u7ae0\u7684\u8fd8\u662f\u5b85\u7537\u591a\uff0c\u8150\u5973\u5c11\uff0c\u6240\u4ee5\uff0c\u4f60\u61c2\u7684\u2026\u2026<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/emtion\/point.gif\" width=\"150\" height=\"150\" alt=\"\u4f60\u61c2\u7684\" class=\"alignnone\" \/><\/p>\n<p><span class=\"s\">&#8212;&#8212;\u6211\u662f\u591a\u5e74\u4e0d\u89c1\u7684\u4f4e\u8c03\u7684\u5206\u9694\u7ebf&#8212;&#8211;<\/span><\/p>\n<p>\u672c\u6587gif\u6bd4\u8f83\u591a\uff0c\u5982\u679c\u60a8\u662f\u79fb\u52a8\u8bbe\u5907\u67e5\u770b\u672c\u6587\uff0c\u4f1a\u53d1\u73b0\uff0c\u600e\u4e48\u6211\u7684\u7535\u6c60\u600e\u4e48\u8d8a\u6765\u8d8a\u7626\u4e86\uff01\u4e0d\u662f\u56e0\u4e3a\u5929\u51b7\u51bb\u5c0f\u4e86\uff0c\u800c\u662fgif\u6bd4\u8f83\u8017\u7535\u3002\u6240\u4ee5\uff0c\u4ece\u8fd9\u4e2a\u89d2\u5ea6\u8bb2\uff0c\u6211\u4eec\u5176\u5b9e\u6709\u5fc5\u8981\u5728\u79fb\u52a8\u7aef\u9ed8\u8ba4\u505c\u6b62\u8fd9\u4e9bgif\u7684\u64ad\u653e\uff0c\u7528\u6237\u70b9\u51fb\u518d\u64ad\u653e\u3002\u4e00\u6765\u7701\u6d41\u91cf\uff0c\u4e8c\u6765\u7701\u7535\u3002<\/p>\n<p>\u5982\u679c\u6ca1\u6709\u9759\u6001\u56fe\u7247\u8d44\u6e90\u652f\u6301\uff0c\u90a3\u4e0d\u59a8\u8bd5\u8bd5\u6587\u7ae0\u51fa\u73b0\u7684\u4e00\u4e9b\u65b9\u6cd5\uff0c\u6709\u5fc3\u5f97\u8bb0\u5f97\u6765\u8fd9\u91cc\u53cd\u9988\u54c8\uff01 <img decoding=\"async\" src=\"http:\/\/mat1.gtimg.com\/www\/mb\/images\/face\/13.gif\" align=\"absmiddle\"><\/p>\n<p>\u6700\u540e\uff0c\u672c\u6587\u7684\u65b9\u6cd5\u90fd\u662f\u6709\u7455\u75b5\u7684\uff0c\u81ea\u5df1\u4e5f\u5c1a\u672a\u5728\u5b9e\u9645\u9879\u76ee\u4e2d\u4f7f\u7528\u8fc7\u3002\u56e0\u6b64\uff0c\u5047\u5982\u9605\u8bfb\u672c\u6587\u7684\u60a8\uff1a<br \/>\n1. \u6709\u66f4\u5b8c\u7f8e\u7684gif\u6682\u505c\u4e0e\u64ad\u653e\u65b9\u6cd5\uff1b<br \/>\n2. \u53d1\u73b0\u6587\u4e2d\u65b9\u6cd5\u6709\u4e0d\u8db3\u548c\u9057\u6f0f\uff1b<\/p>\n<p>\u90fd\u975e\u5e38\u5e0c\u671b\u53ef\u4ee5\u4e0d\u541d\u8d50\u6559\uff01<\/p>\n<p>\u611f\u8c22\u9605\u8bfb\uff01\u5468\u672b\u6e29\u6696\uff01<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/mat1.gtimg.com\/www\/mb\/images\/face\/14.gif\" align=\"absmiddle\"><\/p>\n<p>\u672c\u6587\u4e3a\u539f\u521b\u6587\u7ae0\uff0c\u5305\u542b\u811a\u672c\u884c\u4e3a\uff0c\u4f1a\u7ecf\u5e38\u66f4\u65b0\u77e5\u8bc6\u70b9\u4ee5\u53ca\u4fee\u6b63\u4e00\u4e9b\u9519\u8bef\uff0c\u56e0\u6b64\u8f6c\u8f7d\u8bf7\u4fdd\u7559\u539f\u51fa\u5904\uff0c\u65b9\u4fbf\u6eaf\u6e90\uff0c\u907f\u514d\u9648\u65e7\u9519\u8bef\u77e5\u8bc6\u7684\u8bef\u5bfc\uff0c\u540c\u65f6\u6709\u66f4\u597d\u7684\u9605\u8bfb\u4f53\u9a8c\u3002<br \/>\n\u672c\u6587\u5730\u5740\uff1a<a href=\"http:\/\/www.zhangxinxu.com\/wordpress\/?p=5081\">http:\/\/www.zhangxinxu.com\/wordpress\/?p=5081<\/a><\/p>\n<p>\uff08\u672c\u7bc7\u5b8c\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u9898\uff0c\u672c\u6587\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528CSS\u6216\u8005JS\u7b49\u524d\u7aef\u65b9\u6cd5\u5b9e\u73b0\u4ee3\u7801\u63a7\u5236gif\u56fe\u7247\u7684\u6682\u505c\u6216\u8005\u64ad\u653e\u3002\u4e00\u5982\u65e2\u5f80\uff0c\u6709demo\u6709\u622a\u56fe\u8fd8\u6709\u5fc5\u8981\u7684\u6e90\u4ee3\u7801\u5c55\u793a\uff0c\u66f4\u5173\u952e\u7684\u662f\uff0c\u672c\u6587gif\u6bd4\u8f83\u591a\u2026\u2026<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[896],"tags":[531,1445,53,168,1648,75],"_links":{"self":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/5081"}],"collection":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/comments?post=5081"}],"version-history":[{"count":0,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/5081\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/media?parent=5081"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/categories?post=5081"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/tags?post=5081"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}