{"id":489,"date":"2016-03-24T15:43:43","date_gmt":"2016-03-24T06:43:43","guid":{"rendered":"http:\/\/www.takaya-com.jp\/archives\/?p=489"},"modified":"2016-03-24T15:43:43","modified_gmt":"2016-03-24T06:43:43","slug":"individualzoom","status":"publish","type":"post","link":"https:\/\/takaya-com.jp\/archives\/2016\/03\/individualzoom\/","title":{"rendered":"jQuery\u3067\u3001\u500b\u5225\u306b\u753b\u50cf\u3092\u62e1\u5927\u7e2e\u5c0f\u3057\u3066\u307f\u307e\u3057\u305f\uff01"},"content":{"rendered":"<p><!-- \u672c\u6587 --><\/p>\n<p>\u500b\u5225\u306b\u753b\u50cf\u306e\u62e1\u5927\u7e2e\u5c0f\u304c\u3067\u304d\u308b\u30ea\u30b9\u30c8\u3092jQuery\u3067\u4f5c\u3063\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>\u753b\u50cf\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u62e1\u5927\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 = 100,\r\n\t\tzoom = 1.2,\r\n\t\timgWidthInit = parseInt($(\"img\").css(\"width\")),\r\n\t\timgWidth = 100;\r\n\r\n\t$(\"ul li img\").wrap(\"&lt;div class='box'&gt;&lt;\/div&gt;\").before(\"&lt;div class='init'&gt;\u5143\u306b\u623b\u3059&lt;\/div&gt;\").after(\"&lt;div class='out'&gt;\u7e2e\u5c0f\u3059\u308b&lt;\/div&gt;\");\r\n\r\n\t$(\"ul li img\").click(function(){\r\n\t\tvar $this = $(this);\r\n\t\timgWidth = parseInt($this.css(\"width\"));\r\n\r\n\t\tif (imgWidth === imgWidthInit) {\r\n\t\t\tx = 100;\r\n\t\t\t$this.animate({\r\n\t\t\t\t\"width\": x * zoom + \"%\"\r\n\t\t\t},500);\r\n\t\t} else {\r\n\t\t\t$this.animate({\r\n\t\t\t\t\"width\": x * ((imgWidth \/ imgWidthInit) + (zoom - 1)) + \"%\"\r\n\t\t\t},500);\r\n\t\t}\r\n\t});\r\n\r\n\t$(document).on(\"click\", \".init\",function(){\r\n\t\tvar $this = $(this);\r\n\t\t$this.next(\"img\").animate({\r\n\t\t\t\"width\": \"100%\"\r\n\t\t},1000);\r\n\t});\r\n\r\n\t$(document).on(\"click\", \".out\",function(){\r\n\t\tvar $this = $(this);\r\n\t\timgWidth = parseInt($this.prev(\"img\").css(\"width\"));\r\n\r\n\t\tif (imgWidth === imgWidthInit) {\r\n\t\t\tx = 100;\r\n\t\t\t$this.prev(\"img\").animate({\r\n\t\t\t\t\"width\": x \/ zoom + \"%\"\r\n\t\t\t},500);\r\n\t\t} else {\r\n\t\t\t$this.prev(\"img\").animate({\r\n\t\t\t\t\"width\": x \/ ((imgWidthInit \/ imgWidth) + (zoom - 1)) + \"%\"\r\n\t\t\t},500);\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\tborder: 1px solid #000;\r\n\t\t\tmargin: 0 auto;\r\n\t\t\toverflow: hidden;\r\n\t\t}\r\n\r\n\t\t#main ul li {\r\n\t\t\tposition: relative;\r\n\t\t\twidth: 960px;\r\n\t\t\theight: 415px;\r\n\t\t}\r\n\r\n\t\t#main ul li img {\r\n\t\t\tdisplay: block;\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\r\n\t\t.box {\r\n\t\t\twidth: 960px;\r\n\t\t\theight: 400px;\r\n\t\t\toverflow: scroll;\r\n\t\t}\r\n\r\n\t\t.init {\r\n\t\t\tposition: absolute;\r\n\t\t\ttop: 0;\r\n\t\t\tdisplay: inline-block;\r\n\t\t\tpadding: 5px;\r\n\t\t\tbackground: rgba(200,200,200,0.5);\r\n\t\t}\r\n\r\n\t\t.out {\r\n\t\t\tposition: absolute;\r\n\t\t\ttop: 0;\r\n\t\t\tright: 0;\r\n\t\t\tdisplay: inline-block;\r\n\t\t\tpadding: 5px;\r\n\t\t\tbackground: rgba(200,200,200,0.5);\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;\/ul&gt;\r\n&lt;\/div&gt;<\/pre>\n<p><a href=\"http:\/\/www.takaya-com.jp\/archives\/demo\/individualzoom\/\" target=\"_blank\">\u30c7\u30e2\u30da\u30fc\u30b8\u306f\u3001\u3053\u3061\u3089<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u500b\u5225\u306b\u753b\u50cf\u306e\u62e1\u5927\u7e2e\u5c0f\u304c\u3067\u304d\u308b\u30ea\u30b9\u30c8\u3092jQuery\u3067\u4f5c\u3063\u3066\u307f\u307e\u3057\u305f\u3002 \u753b\u50cf\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u62e1\u5927\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\/489"}],"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=489"}],"version-history":[{"count":1,"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/posts\/489\/revisions"}],"predecessor-version":[{"id":490,"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/posts\/489\/revisions\/490"}],"wp:attachment":[{"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/media?parent=489"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/categories?post=489"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/tags?post=489"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}