{"id":464,"date":"2016-03-23T17:03:25","date_gmt":"2016-03-23T08:03:25","guid":{"rendered":"http:\/\/www.takaya-com.jp\/archives\/?p=464"},"modified":"2016-03-23T17:03:25","modified_gmt":"2016-03-23T08:03:25","slug":"3dslideshow","status":"publish","type":"post","link":"https:\/\/takaya-com.jp\/archives\/2016\/03\/3dslideshow\/","title":{"rendered":"jQuery\u3067\u30013D\u30b9\u30e9\u30a4\u30c0\u30fc\u98a8\u30b9\u30e9\u30a4\u30c9\u30b7\u30e7\u30fc\u3092\u4f5c\u3063\u3066\u307f\u307e\u3057\u305f"},"content":{"rendered":"<p><!-- \u672c\u6587 --><\/p>\n<p>3D\u30b9\u30e9\u30a4\u30c0\u30fc\u98a8\u306b\u30b9\u30e9\u30a4\u30c9\u3059\u308b\u30b9\u30e9\u30a4\u30c9\u30b7\u30e7\u30fc\u3092jQuery\u3067\u4f5c\u3063\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u30b9\u30e9\u30a4\u30c9\u3057\u307e\u3059\u3002<\/p>\n<p><!--more--><\/p>\n<p>\u2193\u4ee5\u4e0b\u304c\u5b9f\u969b\u306e\u30bd\u30fc\u30b9\u30b5\u30f3\u30d7\u30eb\u3067\u3059\u3002<\/p>\n<pre class=\"lang:js decode:true \" title=\"\u25bcJavaScript\" >&lt;script&gt;\r\n$(function () {\r\n\tvar x = 320, \/\/\u753b\u50cf\u306e\u6a2a\u5e45\r\n\t\tzoom = 1.2, \/\/\u62e1\u5927\u306e\u500d\u7387\r\n\t\timgLength = $(\"ul li\").length,\r\n\t\timgLengthFront,\r\n\t\timgLengthBack,\r\n\t\tnum = 0,\r\n\t\tnum2 = 0,\r\n\t\thantei = true,\r\n\t\ti = 0;\r\n\r\n\tif (imgLength % 2 === 1) {\r\n\t\timgLengthFront = parseInt((imgLength \/ 2) + 1);\r\n\t\timgLengthBack = parseInt(imgLength \/ 2);\r\n\t} else {\r\n\t\timgLengthFront = parseInt(imgLength \/ 2);\r\n\t\timgLengthBack = parseInt((imgLength \/ 2) - 1);\r\n\t}\r\n\r\n\t$(\"ul li\").css({\r\n\t\t\"width\": x + \"px\",\r\n\t\t\"position\": \"absolute\"\r\n\t});\r\n\r\n\t$(\"ul li:eq(0)\").css(\"opacity\", \"1\");\r\n\r\n\t$(\"ul li\").each(function () {\r\n\t\tvar $this = $(this);\r\n\t\tif (num &lt; imgLengthFront) {\r\n\t\t\t$this.css(\"left\", (100 \/ imgLengthFront) * num + \"%\");\r\n\t\t} else {\r\n\t\t\t$this.css(\"left\", (100 \/ imgLengthFront) * (imgLength - (num + 1)) * zoom + \"%\");\r\n\t\t}\r\n\t\tnum++;\r\n\t});\r\n\r\n\t$(\"ul li:gt(\" + (imgLengthFront - 1) + \")\").css({\r\n\t\t\"width\": (x \/ zoom) + \"px\",\r\n\t\t\"height\": \"auto\",\r\n\t\t\"margin-left\": \"-\" + (((x * zoom) - (960 - (x * 2))) \/ 2) + \"px\",\r\n\t\t\"z-index\": \"0\",\r\n\t\t\"opacity\": \"1\"\r\n\t});\r\n\r\n\t$(\"ul li:lt(\" + imgLengthFront + \")\").css({\r\n\t\t\"z-index\": \"50\",\r\n\t\t\"opacity\": \"1\"\r\n\t});\r\n\r\n\t$(\"ul li:eq(1)\").css({\r\n\t\t\"width\": (x * zoom) + \"px\",\r\n\t\t\"height\": \"auto\",\r\n\t\t\"margin-left\": \"-\" + (((x * zoom) - (960 - (x * 2))) \/ 2) + \"px\",\r\n\t\t\"z-index\": \"100\",\r\n\t\t\"opacity\": \"1\"\r\n\t});\r\n\r\n\t$(\"ul li:eq(0), ul li:gt(1)\").css({\r\n\t\t\"margin-top\": ($(\"ul li:eq(1)\").height() - $(\"ul li:eq(0)\").height()) \/ 2 + \"px\"\r\n\t});\r\n\t$(\" ul li:gt(\" + (imgLengthFront - 1) + \")\").css({\r\n\t\t\"margin-top\": ($(\"ul li:eq(1)\").height() - $(\"ul li:eq(0)\").height()) + \"px\"\r\n\t});\r\n\r\n\t$(\"ul\").click(function () {\r\n\t\tif (hantei) {\r\n\t\t\thantei = false,\r\n\t\t\t\ti = 0,\r\n\t\t\t\tnum2 = 0;\r\n\r\n\t\t\twhile (i &lt; imgLength) {\r\n\t\t\t\tvar $this = $(this);\r\n\r\n\t\t\t\tif (num2 === 0) {\r\n\t\t\t\t\t$(\"ul li:eq(0)\").animate({\r\n\t\t\t\t\t\t\"left\": (100 \/ imgLengthFront) * num2 + \"%\",\r\n\t\t\t\t\t\t\"margin-top\": (($(\"ul li:eq(0)\").height() * zoom) - $(\"ul li:eq(0)\").height()) + \"px\",\r\n\t\t\t\t\t\t\"margin-left\": \"-\" + (((x * zoom) - (960 - (x * 2))) \/ 2) + \"px\",\r\n\t\t\t\t\t\t\"width\": x \/ zoom + \"px\",\r\n\t\t\t\t\t\t\"opacity\": \"1\"\r\n\t\t\t\t\t},1000,function(){\r\n\t\t\t\t\t\thantei = true;\r\n\t\t\t\t\t}).css(\"z-index\", \"50\");\r\n\t\t\t\t\tnum2++;\r\n\t\t\t\t} else if (num2 === 1) {\r\n\t\t\t\t\t$(\"ul li:eq(1)\").animate({\r\n\t\t\t\t\t\t\"left\": (100 \/ imgLengthFront) * (num2 - 1) + \"%\",\r\n\t\t\t\t\t\t\"margin-top\": (($(\"ul li:eq(0)\").height() * zoom) - $(\"ul li:eq(0)\").height()) \/ 2 + \"px\",\r\n\t\t\t\t\t\t\"margin-left\": \"0\",\r\n\t\t\t\t\t\t\"width\": x + \"px\",\r\n\t\t\t\t\t\t\"opacity\": \"1\"\r\n\t\t\t\t\t},1000,function(){\r\n\t\t\t\t\t\t$(\"ul li:eq(0)\").css(\"z-index\", \"0\").appendTo(\"ul\");\r\n\t\t\t\t\t\thantei = true;\r\n\t\t\t\t\t}).css(\"z-index\", \"50\");\r\n\t\t\t\t\tnum2++;\r\n\t\t\t\t} else if (num2 === 2) {\r\n\t\t\t\t\t$(\"ul li:eq(2)\").animate({\r\n\t\t\t\t\t\t\"left\": (100 \/ imgLengthFront) * (num2 - 1) + \"%\",\r\n\t\t\t\t\t\t\"width\": (x * zoom) + \"px\",\r\n\t\t\t\t\t\t\"margin-top\": \"0\",\r\n\t\t\t\t\t\t\"margin-left\": \"-\" + (((x * zoom) - (960 - (x * 2))) \/ 2) + \"px\",\r\n\t\t\t\t\t\t\"opacity\": \"1\"\r\n\t\t\t\t\t},1000).css(\"z-index\", \"100\");\r\n\t\t\t\t\tnum2++;\r\n\t\t\t\t} else if (num2 &lt; imgLengthFront) {\r\n\t\t\t\t\t$(\"ul li:eq(\" + num2 + \")\").animate({\r\n\t\t\t\t\t\t\"left\": (100 \/ imgLengthFront) * (num2 - 1) + \"%\",\r\n\t\t\t\t\t\t\"width\": x + \"px\",\r\n\t\t\t\t\t\t\"margin-top\": (($(\"ul li:eq(0)\").height() * zoom) - $(\"ul li:eq(0)\").height()) \/ 2 + \"px\",\r\n\t\t\t\t\t\t\"margin-left\": \"0\"\r\n\t\t\t\t\t}, 1000,function(){\r\n\t\t\t\t\t\thantei = true;\r\n\t\t\t\t\t});\r\n\t\t\t\t\tnum2++;\r\n\t\t\t\t\thantei = true;\r\n\t\t\t\t} else if (num2 === imgLengthFront) {\r\n\t\t\t\t\t$(\"ul li:eq(\" + num2 + \")\").animate({\r\n\t\t\t\t\t\t\"left\": (100 \/ imgLengthFront) * (imgLengthFront - 1) + \"%\",\r\n\t\t\t\t\t\t\"width\": x + \"px\",\r\n\t\t\t\t\t\t\"margin-top\": (($(\"ul li:eq(0)\").height() * zoom) - $(\"ul li:eq(0)\").height()) \/ 2 + \"px\",\r\n\t\t\t\t\t\t\"margin-left\": \"0\"\r\n\t\t\t\t\t}, 1000,function(){\r\n\t\t\t\t\t\thantei = true;\r\n\t\t\t\t\t}).css(\"z-index\", \"50\");\r\n\t\t\t\t\tnum2++;\r\n\t\t\t\t} else {\r\n\t\t\t\t\t$(\"ul li:eq(\" + num2 + \")\").animate({\r\n\t\t\t\t\t\t\"left\": ((100 \/ imgLengthFront) * (imgLength - (num2)) * zoom) + \"%\",\r\n\t\t\t\t\t\t\"margin-top\": (($(\"ul li:eq(0)\").height() * zoom) - $(\"ul li:eq(0)\").height()) + \"px\",\r\n\t\t\t\t\t}, 1000,function(){\r\n\t\t\t\t\t\thantei = true;\r\n\t\t\t\t\t}).css(\"z-index\", \"0\");\r\n\t\t\t\t\tnum2++;\r\n\t\t\t\t}\r\n\t\t\t\ti++;\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\treturn false;\r\n\t\t}\r\n\t});\r\n});\r\n&lt;\/script&gt;<\/pre>\n<pre class=\"lang:css decode:true \" title=\"\u25bcCSS\" >&lt;style&gt;\r\n\t\t* {\r\n\t\t\tmargin: 0;\r\n\t\t\tpadding: 0;\r\n\t\t\tborder: 0;\r\n\t\t}\r\n\r\n\t\t#main {\r\n\t\t\tposition: relative;\r\n\t\t\twidth: 960px;\r\n\t\t\theight: 500px;\r\n\t\t\tmargin: 0 auto;\r\n\t\t}\r\n\r\n\t\t#main ul li {\r\n\t\t\tdisplay: inline-block;\r\n\t\t\twidth: 320px;\r\n\t\t\theight: auto;\r\n\t\t\tbox-shadow: 0 10px 20px 0 rgba(0, 0, 0, 0.5);\r\n\t\t\topacity: 0.5;\r\n\t\t}\r\n\r\n\t\t#main ul li img {\r\n\t\t\twidth: 100%;\r\n\t\t\theight: auto;\r\n\t\t\tvertical-align: bottom;\r\n\t\t}\r\n&lt;\/style&gt;<\/pre>\n<pre class=\"lang:xhtml decode:true \" title=\"\u25bcHTML\" >&lt;div id=\"main\"&gt;\r\n&lt;ul&gt;&lt;!--\r\n--&gt;&lt;li&gt;&lt;img src=\"image\/topimg1.jpg\"&gt;&lt;\/li&gt;&lt;!--\r\n--&gt;&lt;li&gt;&lt;img src=\"image\/topimg2.jpg\"&gt;&lt;\/li&gt;&lt;!--\r\n--&gt;&lt;li&gt;&lt;img src=\"image\/topimg3.jpg\"&gt;&lt;\/li&gt;&lt;!--\r\n--&gt;&lt;li&gt;&lt;img src=\"image\/topimg4.jpg\"&gt;&lt;\/li&gt;&lt;!--\r\n--&gt;&lt;li&gt;&lt;img src=\"image\/topimg5.jpg\"&gt;&lt;\/li&gt;&lt;!--\r\n--&gt;&lt;li&gt;&lt;img src=\"image\/topimg3.jpg\"&gt;&lt;\/li&gt;&lt;!--\r\n--&gt;&lt;\/ul&gt;\r\n\t&lt;\/div&gt;<\/pre>\n<p><a href=\"http:\/\/www.takaya-com.jp\/archives\/demo\/3dslideshow\/\" target=\"_blank\">\u30c7\u30e2\u30da\u30fc\u30b8\u306f\u3001\u3053\u3061\u3089<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>3D\u30b9\u30e9\u30a4\u30c0\u30fc\u98a8\u306b\u30b9\u30e9\u30a4\u30c9\u3059\u308b\u30b9\u30e9\u30a4\u30c9\u30b7\u30e7\u30fc\u3092jQuery\u3067\u4f5c\u3063\u3066\u307f\u307e\u3057\u305f\u3002 \u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u30b9\u30e9\u30a4\u30c9\u3057\u307e\u3059\u3002<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/posts\/464"}],"collection":[{"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/comments?post=464"}],"version-history":[{"count":1,"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/posts\/464\/revisions"}],"predecessor-version":[{"id":465,"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/posts\/464\/revisions\/465"}],"wp:attachment":[{"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/media?parent=464"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/categories?post=464"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/tags?post=464"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}