{"id":28327,"date":"2024-11-24T17:59:35","date_gmt":"2024-11-24T09:59:35","guid":{"rendered":"https:\/\/fwq.ai\/blog\/28327\/"},"modified":"2024-11-24T17:59:35","modified_gmt":"2024-11-24T09:59:35","slug":"%e4%bd%bf%e7%94%a8-translate3d-%e5%ae%9e%e7%8e%b0%e8%bd%ae%e6%92%ad%e5%9b%be%e6%97%b6%e5%a6%82%e4%bd%95%e8%a7%a3%e5%86%b3%e6%9c%80%e5%90%8e%e4%b8%80%e9%a1%b5%e5%88%87%e6%8d%a2%e5%88%b0%e7%ac%ac","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/28327\/","title":{"rendered":"\u4f7f\u7528 translate3d \u5b9e\u73b0\u8f6e\u64ad\u56fe\u65f6\u5982\u4f55\u89e3\u51b3\u6700\u540e\u4e00\u9875\u5207\u6362\u5230\u7b2c\u4e00\u9875\u65f6\u7684\u95ea\u52a8\u95ee\u9898\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173155124780370.jpg\" class=\"aligncenter\" title=\"\u4f7f\u7528 translate3d \u5b9e\u73b0\u8f6e\u64ad\u56fe\u65f6\u5982\u4f55\u89e3\u51b3\u6700\u540e\u4e00\u9875\u5207\u6362\u5230\u7b2c\u4e00\u9875\u65f6\u7684\u95ea\u52a8\u95ee\u9898\uff1f\u63d2\u56fe\" alt=\"\u4f7f\u7528 translate3d \u5b9e\u73b0\u8f6e\u64ad\u56fe\u65f6\u5982\u4f55\u89e3\u51b3\u6700\u540e\u4e00\u9875\u5207\u6362\u5230\u7b2c\u4e00\u9875\u65f6\u7684\u95ea\u52a8\u95ee\u9898\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u8f6e\u64ad\u56fe\u8f6e\u56de\u5207\u6362\u65f6\u7684\u95ea\u52a8\u95ee\u9898<\/strong><\/p>\n<p>\u5728\u4f7f\u7528 translate3d \u6765\u5b9e\u73b0\u8f6e\u64ad\u56fe\u65f6\uff0c\u5728\u6700\u540e\u4e00\u9875\u5207\u6362\u5230\u7b2c\u4e00\u9875\u65f6\uff0c\u5982\u679c\u60a8\u5207\u6362\u8f83\u6162\uff0c\u53ef\u80fd\u4f1a\u51fa\u73b0\u56fe\u7247\u95ea\u52a8\u7684\u95ee\u9898\u3002<\/p>\n<p>\u8fd9\u662f\u56e0\u4e3a\u5728\u5207\u6362\u7684\u65f6\u5019\uff0ctransition \u7684\u8fc7\u6e21\u65f6\u95f4\u8fd8\u5728\u7ee7\u7eed\uff0c\u5982\u679c\u9f20\u6807\u70b9\u51fb\u5f88\u5feb\uff0c\u56fe\u7247\u4f1a\u77ac\u95f4\u8df3\u5230\u4e0b\u4e00\u5f20\uff0c\u4e0d\u4f1a\u7b49\u5230\u8fc7\u6e21\u7ed3\u675f\u3002\u56e0\u6b64\uff0c\u4f1a\u51fa\u73b0\u56fe\u7247\u95ea\u52a8\u7684\u60c5\u51b5\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848<\/strong><\/p>\n<p>\u60a8\u53ef\u4ee5\u4fee\u6539 changeCur \u65b9\u6cd5\u6765\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u3002\u89e3\u51b3\u65b9\u6848\u5982\u4e0b\uff1a<\/p>\n<pre>changeCur(add){\n                \/\/ this.out.style.setProperty('--trans', 'transform');\n                this.con.style.transitionDuration = '.3s';\n\n                \/\/\u5207\u6362cur\u65b9\u6cd5\n                let cur = this.out.style.getPropertyValue('--cur');\n                cur = parseInt(cur);\n\n                if(add){\n                    \/\/ this.setCur(cur+1);\n\n                    \/\/ if(cur &gt; this.num-1){\n                    \/\/     setTimeout(() =&gt; {\n                    \/\/         \/\/ cur = 1;\n                    \/\/         \/\/ this.out.style.setProperty('--trans', 'none');\n                    \/\/         this.con.style.transitionDuration = '0s';\n                    \/\/         this.setCur(1);\n                    \/\/     }, 300)\n                    \/\/ }\n                   if (cur === this.num) {\n                        this.con.style.transitionDuration = '0s';\n                        this.setCur(0);\n                        this.con.offsetWidth;\n                        this.con.style.transitionDuration = '.3s';\n                        this.setCur(1);\n\n                    } else {\n                        this.setCur(cur + 1);\n                    }\n\n                }\n                else{\n                    \/\/ this.setCur(cur-1);\n                    \/\/ if(cur &lt; 2){\n                    \/\/     \/\/ setTimeout(() =&gt; {\n                    \/\/     \/\/     \/\/ cur = this.num;\n                    \/\/     \/\/     \/\/ this.out.style.setProperty('--trans', 'none');\n                    \/\/     \/\/     this.con.style.transitionDuration = '0s';\n                    \/\/     \/\/     this.setCur(this.num);\n                    \/\/     \/\/ }, 300)\n                    \/\/ }\n                    if (cur === 1) {\n                        this.con.style.transitionDuration = '0s';\n                        this.setCur(this.num + 1);\n                        this.con.offsetWidth;\n                        this.con.style.transitionDuration = '.3s';\n                        this.setCur(this.num);\n                    } else {\n                        this.setCur(cur - 1);\n                    }\n\n                }\n            }<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u4f7f\u7528 translate3d \u5b9e\u73b0\u8f6e\u64ad\u56fe\u65f6\u5982\u4f55\u89e3\u51b3\u6700\u540e\u4e00\u9875\u5207\u6362\u5230\u7b2c\u4e00\u9875\u65f6\u7684\u95ea\u52a8\u95ee\u9898\uff1f\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>\u8f6e\u64ad\u56fe\u8f6e\u56de\u5207\u6362\u65f6\u7684\u95ea\u52a8\u95ee\u9898 \u5728\u4f7f\u7528 translate3d \u6765\u5b9e\u73b0\u8f6e\u64ad\u56fe\u65f6\uff0c\u5728\u6700\u540e\u4e00\u9875\u5207\u6362\u5230\u7b2c\u4e00\u9875\u65f6\uff0c\u5982\u679c\u60a8\u5207\u6362\u8f83\u6162\uff0c\u53ef\u80fd\u4f1a\u51fa\u73b0\u56fe\u7247\u95ea\u52a8\u7684\u95ee\u9898\u3002 \u8fd9\u662f\u56e0\u4e3a\u5728\u5207\u6362\u7684\u65f6\u5019\uff0ctransition \u7684\u8fc7\u6e21\u65f6\u95f4\u8fd8\u5728\u7ee7\u7eed\uff0c\u5982\u679c\u9f20\u6807\u70b9\u51fb\u5f88\u5feb\uff0c\u56fe\u7247\u4f1a\u77ac\u95f4\u8df3\u5230\u4e0b\u4e00\u5f20\uff0c\u4e0d\u4f1a\u7b49\u5230\u8fc7\u6e21\u7ed3\u675f\u3002\u56e0\u6b64\uff0c\u4f1a\u51fa\u73b0\u56fe\u7247\u95ea\u52a8\u7684\u60c5\u51b5\u3002 \u89e3\u51b3\u65b9\u6848 \u60a8\u53ef\u4ee5\u4fee\u6539 changeCur \u65b9\u6cd5\u6765\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u3002\u89e3\u51b3\u65b9\u6848\u5982\u4e0b\uff1a changeCur(add){ \/\/ this.out.style.setProperty(&#8216;&#8211;trans&#8217;, &#8216;transform&#8217;); this.con.style.transitionDuration = &#8216;.3s&#8217;; \/\/\u5207\u6362cur\u65b9\u6cd5 let cur = this.out.style.getPropertyValue(&#8216;&#8211;cur&#8217;); cur = parseInt(cur); if(add){ \/\/ this.setCur(cur+1); \/\/ if(cur &gt; this.num-1){ \/\/ setTimeout(() =&gt; { \/\/ \/\/ cur = 1; \/\/ \/\/ this.out.style.setProperty(&#8216;&#8211;trans&#8217;, &#8216;none&#8217;); \/\/ this.con.style.transitionDuration = &#8216;0s&#8217;; \/\/ this.setCur(1); \/\/ }, 300) \/\/ [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-28327","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/28327","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=28327"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/28327\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=28327"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=28327"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=28327"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}