{"id":4697,"date":"2016-01-29T12:43:35","date_gmt":"2016-01-29T03:43:35","guid":{"rendered":"https:\/\/gunmagisgeek.com\/wordpress\/?p=4697"},"modified":"2016-01-29T12:43:35","modified_gmt":"2016-01-29T03:43:35","slug":"post-4697","status":"publish","type":"post","link":"https:\/\/gunmagisgeek.com\/blog\/d3-js\/4697","title":{"rendered":"\u3010D3.js\u3011Before After Image Slider"},"content":{"rendered":"<p><a href=\"http:\/\/bl.ocks.org\/shimizu\/cdcd6a1dcd304c2318fd\" rel=\"attachment wp-att-4698\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2016\/01\/d3_Before_After_Image-Slider.png\" alt=\"d3_Before_After_Image\" width=\"590\" height=\"304\" class=\"aligncenter size-full wp-image-4698 border\" srcset=\"https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2016\/01\/d3_Before_After_Image-Slider.png 590w, https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2016\/01\/d3_Before_After_Image-Slider-291x150.png 291w\" sizes=\"auto, (max-width: 590px) 100vw, 590px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/bl.ocks.org\/shimizu\/cdcd6a1dcd304c2318fd\">example<\/a><\/p>\n<p>\u30b9\u30e9\u30a4\u30c0\u30fc\u3067\uff12\u679a\u306e\u753b\u50cf\u3092\u5207\u308a\u66ff\u3048\u3066\u6bd4\u8f03\u3067\u304d\u308b\u3001\u3044\u308f\u3086\u308b\u300c<a href=\"http:\/\/bit.ly\/20wrL1x\">Before After Image Slider<\/a>\u300d\u3068\u3044\u3046\u3082\u306e\u3092D3.js\u3067\u4f5c\u3063\u3066\u307f\u305f\u3002<br \/>\n\u300c\uff12\u679a\u3067\u306a\u304f\u8907\u6570\u679a\u91cd\u306d\u3066\u5207\u308a\u66ff\u3048\u3089\u308c\u308b\u3082\u306e\u3092\u300d\u3068\u3044\u3046\u3053\u3068\u3060\u3063\u305f\u306e\u3067\u4f5c\u3063\u3066\u307f\u305f\u306e\u3060\u3051\u308c\u3069\u3001\u3042\u307e\u308a\u4f7f\u3044\u304c\u3063\u3066\u304c\u826f\u304f\u306a\u3044\u306e\u3067\u304a\u8535\u5165\u308a\u3002\u305b\u3063\u304b\u304f\u306a\u306e\u3067bl.ocks\u306b\u8f09\u305b\u3066\u307f\u305f\u3002<br \/>\n\u308f\u304b\u308a\u3084\u3059\u304f\u8272\u3067\u8868\u793a\u3057\u3066\u3044\u308b\u304c\u3001\u5404div\u8981\u7d20\u306e\u30d0\u30c3\u30af\u30b0\u30e9\u30a6\u30c9\u306b\u753b\u50cf\u3092\u8a2d\u5b9a\u3059\u308c\u3070\u30a4\u30e1\u30fc\u30b8\u30b9\u30e9\u30a4\u30c0\u30fc\u3068\u3057\u3066\u4f7f\u3046\u3053\u3068\u304c\u3067\u304d\u308b\u3002<\/p>\n<h2>\u89e3\u8aac<\/h2>\n<p>\u5b9f\u306e\u3068\u3053\u308dD3\u306fdrag\u30d3\u30d8\u30a4\u30d3\u30a2\u3092\u4f7f\u3063\u3066\u30b9\u30e9\u30a4\u30c0\u30fc\u3092\u5236\u5fa1\u3059\u308b\u3053\u3068\u306b\u3057\u304b\u4f7f\u3063\u3066\u3044\u306a\u3044\u3002<br \/>\nscale\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3046\u3053\u3068\u3067\u7a3c\u50cd\u7bc4\u56f2\u3092\u5236\u5fa1\u3057\u3066\u3044\u308b\u3002<\/p>\n<pre class=\"lang:js decode:true \" >var xScale = d3.scale.linear().domain([0, &lt;\u6a2a\u5e45\u6700\u5927\u5024&gt;]).range([0, &lt;\u6a2a\u5e45\u6700\u5927\u5024&gt;]).clamp(true)<\/pre>\n<p>\u30dd\u30a4\u30f3\u30c8\u306fclamp\u3092true\u306b\u6307\u5b9a\u3059\u308b\u3053\u3068\u3002\u3053\u308c\u306b\u3088\u3063\u3066\u30b9\u30b1\u30fc\u30eb\u306e\u30c9\u30e1\u30a4\u30f3\u7bc4\u56f2\u3092\u8d85\u3048\u305f\u5024\u306f\u81ea\u52d5\u7684\u306b\u6700\u5c0f\u5024\u30fb\u6700\u5927\u5024\u306b\u53ce\u3081\u3089\u308c\u308b\u3002<\/p>\n<pre class=\"lang:js decode:true \" >function dragFn(d,i ) {\r\n    var x = d3.select(this).node().offsetLeft + d3.event.dx;\r\n    d3.select(this).style(\"left\", xScale(x) + \"px\")\r\n}<\/pre>\n<p>drag\u30d3\u30d8\u30a4\u30d3\u30a2\u306e\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u306a\u3044\u3067\u30de\u30a6\u30b9\u5ea7\u6a19\u304b\u3089\u5f97\u305f\u5024\u3092\u5148\u307b\u3069\u306e\u30b9\u30b1\u30fc\u30eb\u3092\u4f7f\u3063\u3066\u7a3c\u50cd\u7bc4\u56f2\u306a\u3044\u306e\u5024\u306b\u5909\u63db\u3057\u3001\u30b9\u30e9\u30a4\u30c0\u30fc\u8981\u7d20(div)\u306eleft\u5024\u306b\u9069\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u30b9\u30e9\u30a4\u30c0\u30fc\u3092\u5b9f\u88c5\u3057\u3066\u3044\u308b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>example \u30b9\u30e9\u30a4\u30c0\u30fc\u3067\uff12\u679a\u306e\u753b\u50cf\u3092\u5207\u308a\u66ff\u3048\u3066&hellip;<\/p>\n","protected":false},"author":1,"featured_media":4698,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-4697","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-d3-js","has-post-thumbnail-archive"],"_links":{"self":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts\/4697","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/comments?post=4697"}],"version-history":[{"count":0,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts\/4697\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/media\/4698"}],"wp:attachment":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/media?parent=4697"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/categories?post=4697"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/tags?post=4697"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}