{"id":2311,"date":"2019-02-22T08:07:03","date_gmt":"2019-02-21T23:07:03","guid":{"rendered":"http:\/\/kats-eye.net\/info\/?p=2311"},"modified":"2019-03-02T09:29:41","modified_gmt":"2019-03-02T00:29:41","slug":"drag_drop_01","status":"publish","type":"post","link":"https:\/\/kats-eye.net\/info\/2019\/02\/22\/drag_drop_01\/","title":{"rendered":"\u30de\u30a6\u30b9\u30c9\u30e9\u30c3\u30b0\u306b\u3088\u308b\u8981\u7d20\u4e26\u3073\u66ff\u3048\u691c\u8a0e\u2460"},"content":{"rendered":"<table style=\"width: 100%; border-collapse: collapse; border-style: none; height: 27px;\" border=\"1\">\n<tbody>\n<tr style=\"height: 30px; border-bottom: 3px #0000ff solid;\">\n<td style=\"width: 1.5%; border-style: none; background-color: #0000ff; height: 27px;\"><\/td>\n<td style=\"width: 2%; border-style: none; height: 27px; background-color: #ffffff;\"><\/td>\n<td style=\"border-style: none; height: 27px; background-color: #ffffff;\"><span style=\"font-family: verdana, geneva, sans-serif;\"><strong><span style=\"font-size: 18pt; color: #0000ff;\">\u6982\u3000\u8981<\/span><\/strong><\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5c11\u3057\u524d\u306b jQuery UI \u201cSortable\u201d \u3092\u4f7f\u3063\u3066\u3001&lt;li&gt;\uff0c&lt;tr&gt;\uff0c&lt;div&gt; \u7b49\u306e\u8981\u7d20\u3092\u4e26\u3073\u66ff\u3048\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f5c\u308a\u307e\u3057\u305f\u3002\u6700\u8fd1\u4f5c\u3063\u3066\u3044\u305f\u304a\u7d75\u63cf\u304d\u30c4\u30fc\u30eb\u3067\u7de8\u96c6\u3057\u305f\u5199\u771f\u3092\u767b\u9332\u3057\u3001\u4e26\u3073\u66ff\u3048\u305f\u308a\u3059\u308b\u3053\u3068\u3092\u60f3\u5b9a\u3057\u3066\u3044\u307e\u3057\u305f\u3002<br \/>\n\u304a\u7d75\u63cf\u304d\u30c4\u30fc\u30eb\u306e\u65b9\u304c\u3042\u308b\u7a0b\u5ea6\u51fa\u6765\u3066\u304d\u305f\u306e\u3067\u3001\u5b9f\u969b\u306b\u5199\u771f\u3092\u767b\u9332\u3057\u3001\u4e26\u3073\u66ff\u3048\u308b\u65b9\u6cd5\u3092\u8003\u3048\u3088\u3046\u3068\u3059\u308b\u3068\u518d\u7de8\u96c6\u3059\u308b\u6642\u306e\u547c\u3073\u51fa\u3057\u65b9\u6cd5\u3001\u201cSortable\u201d\u3067\u6271\u3048\u308b\u6700\u5927\u5199\u771f\u679a\u6570\u3001\u5199\u771f\u304c\u591a\u3044\u5834\u5408\u306b\u30da\u30fc\u30b8\u3092\u5206\u3051\u308b\u306a\u3069\u3044\u308d\u3044\u308d\u3068\u8003\u3048\u308b\u69d8\u306b\u306a\u308a\u3001\u5177\u4f53\u7684\u691c\u8a3c\u3082\u3057\u306a\u3044\u307e\u307e\u6642\u9593\u304c\u904e\u304e\u3066\u3057\u307e\u3044\u307e\u3057\u305f\u3002<br \/>\n\u305d\u3093\u306a\u4e2d\u3067\u3001\u8981\u7d20\u3092\u30c9\u30e9\u30c3\u30b0\u30a2\u30f3\u30c9\u30c9\u30ed\u30c3\u30d7\u3067\u79fb\u52d5\u3055\u305b\u308b\u3068\u3044\u3046\u8a18\u4e8b\u3092\u898b\u3066\u3001jQuery \u306b\u983c\u3089\u306a\u3044\u65b9\u6cd5\u3092\u79c1\u306a\u308a\u306b\u691c\u8a0e\u3057\u3066\u3044\u307e\u3059\u3002\u3053\u308c\u307e\u3067\u306e\u78ba\u8a8d\u5185\u5bb9\u3092\u6574\u7406\u3057\u3066\u304a\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u53c2\u8003\u307e\u3067\u306b\u3001\u4e0b\u8a18\u304c\u30ba\u30fc\u30e0\u6a5f\u80fd\u3092\u4ed8\u4e0e\u3057\u305f\u304a\u7d75\u63cf\u304d\u30c4\u30fc\u30eb\u3078\u306e\u30ea\u30f3\u30af\u3067\u3059\u3002\u304a\u7d75\u63cf\u304d\u6a5f\u80fd\u3068\u30ba\u30fc\u30e0\u6a5f\u80fd\u3092\u7d71\u5408\u3057\u3001\u305d\u308c\u305e\u308c\u50c5\u304b\u306a\u304c\u3089\u3082\u6539\u826f\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\n\uff08\u2192<a href=\"https:\/\/kats-eye.net\/test_prog\/1902002_drw_tst03\/cvs_edt_30\" target=\"_blank\" rel=\"noopener\">\u30ba\u30fc\u30e0\u6a5f\u80fd\u4ed8\u304d\u306e\u304a\u7d75\u63cf\u304d\u30c4\u30fc\u30eb<\/a>\uff09<\/p>\n<table style=\"width: 100%; border-collapse: collapse; border-style: none; height: 27px;\" border=\"1\">\n<tbody>\n<tr style=\"height: 30px; border-bottom: 3px #0000ff solid;\">\n<td style=\"width: 1.5%; border-style: none; background-color: #0000ff; height: 27px;\"><\/td>\n<td style=\"width: 2%; border-style: none; height: 27px; background-color: #ffffff;\"><\/td>\n<td style=\"border-style: none; height: 27px; background-color: #ffffff;\"><span style=\"font-family: verdana, geneva, sans-serif;\"><strong><span style=\"font-size: 18pt; color: #0000ff;\">\u30c9\u30e9\u30c3\u30b0\u306b\u3088\u308b\u8981\u7d20\u79fb\u52d5<\/span><\/strong><\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>jQuery \u306b\u983c\u3089\u305a\u30c9\u30e9\u30c3\u30b0\u30a2\u30f3\u30c9\u30c9\u30ed\u30c3\u30d7\u3067\u8981\u7d20\u3092\u4e26\u3073\u66ff\u3048\u308b\u70ba\u306b\u306f\u3001\u5148\u305a\u306f\u30c9\u30e9\u30c3\u30b0\u30a2\u30f3\u30c9\u30c9\u30ed\u30c3\u30d7\u3067\u8981\u7d20\u3092\u4efb\u610f\u306e\u4f4d\u7f6e\u306b\u79fb\u52d5\u51fa\u6765\u308b\u69d8\u306b\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u5148\u305a\u306f\u7b2c\u4e00\u30b9\u30c6\u30c3\u30d7\u306e\u79fb\u52d5\u65b9\u6cd5\u306b\u3064\u3044\u3066\u691c\u8a0e\u3057\u307e\u3057\u305f\u3002\u6b21\u306e\u56f3\u304c\u4eca\u56de\u306e\u30c6\u30b9\u30c8\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u5b9f\u884c\u72b6\u6cc1\u3067\u3059\u3002\u30da\u30fc\u30b8\u3092\u958b\u3044\u305f\u521d\u671f\u72b6\u614b\u3067\u6a2a\u65b9\u5411\u306b\u4e26\u3093\u3060\uff16\u3064\u306e\u8981\u7d20\u3092\u30de\u30a6\u30b9\u64cd\u4f5c\u3067\u79fb\u52d5\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br \/>\n\uff08\u2192<a href=\"https:\/\/kats-eye.net\/test_prog\/1902002_drw_tst03\/dd_xy_003_dsp\" target=\"_blank\" rel=\"noopener\">\u30c9\u30e9\u30c3\u30b0\u306b\u3088\u308b\u8981\u7d20\u79fb\u52d5\u30c6\u30b9\u30c8\u30d7\u30ed\u30b0\u30e9\u30e0<\/a>\uff09<br \/>\n<img loading=\"lazy\" class=\"aligncenter size-full wp-image-2329\" src=\"https:\/\/kats-eye.net\/info\/wp-content\/uploads\/2019\/02\/001-2.jpg\" alt=\"\" width=\"1068\" height=\"585\" srcset=\"https:\/\/kats-eye.net\/info\/wp-content\/uploads\/2019\/02\/001-2.jpg 1068w, https:\/\/kats-eye.net\/info\/wp-content\/uploads\/2019\/02\/001-2-300x164.jpg 300w, https:\/\/kats-eye.net\/info\/wp-content\/uploads\/2019\/02\/001-2-768x421.jpg 768w, https:\/\/kats-eye.net\/info\/wp-content\/uploads\/2019\/02\/001-2-1024x561.jpg 1024w\" sizes=\"(max-width: 1068px) 100vw, 1068px\" \/><\/p>\n<table style=\"width: 100%; border-collapse: collapse; border-style: none; height: 27px;\" border=\"1\">\n<tbody>\n<tr style=\"height: 30px; border-bottom: 3px #0000ff solid;\">\n<td style=\"width: 1.5%; border-style: none; background-color: #0000ff; height: 27px;\"><\/td>\n<td style=\"width: 2%; border-style: none; height: 27px; background-color: #ffffff;\"><\/td>\n<td style=\"border-style: none; height: 27px; background-color: #ffffff;\"><span style=\"color: #0000ff; font-family: verdana, geneva, sans-serif;\"><span style=\"font-size: 24px;\"><b>\u30c6\u30b9\u30c8\u30d7\u30ed\u30b0\u30e9\u30e0<\/b><\/span><\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u4eca\u56de\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\uff08html\uff0bJavaScript\uff09\u3092\u6b21\u306b\u793a\u3057\u307e\u3059\u3002<br \/>\n\u30da\u30fc\u30b8\u8aad\u8fbc\u5b8c\u4e86\u5f8c\u3001\u884c\u756a77\u3067 \u201cinit_chk()\u201d (\u884c\u756a25\uff5e27) \u7d4c\u7531\u3067 \u201cget_window_info()\u201d (\u884c\u756a55\uff5e72) \u3092\u547c\u3073\u51fa\u3057\u307e\u3059\u3002<br \/>\n\u3053\u3053\u3067\u306f\u3001\u884c\u756a79\uff5e84\u3067\u914d\u7f6e\u3057\u3066\u3044\u308b\u3008div\u3009\u8981\u7d20\u3092\u53d6\u5f97\u3057\u3001\u5404\u8981\u7d20\u306b\u5bfe\u3057\u5ea7\u6a19\u8a2d\u5b9a\uff0c\uff29\uff24\u756a\u53f7\u8868\u793a\u7b49\u3092\u884c\u3044\u521d\u671f\u914d\u7f6e\u3057\u307e\u3059\u3002<\/p>\n<p>\u521d\u671f\u914d\u7f6e\u5f8c\u3001\u5404\u30de\u30a6\u30b9\u30a4\u30d9\u30f3\u30c8\u767a\u751f\u6642\u306b\u30a4\u30d9\u30f3\u30c8\u304c\u767a\u751f\u3057\u305f\u8981\u7d20\u306b\u5bfe\u3057\u3066\u5ea7\u6a19\u66f4\u65b0\u3092\u884c\u3046\u3053\u3068\u3067\u8981\u7d20\u3092\u79fb\u52d5\u3055\u305b\u307e\u3059\u3002<br \/>\n\u5177\u4f53\u7684\u306b\u306f\u3001\u307e\u305a\u884c\u756a30\uff5e37\u306e\u30de\u30a6\u30b9\u30c0\u30a6\u30f3\u30a4\u30d9\u30f3\u30c8\u767a\u751f\uff08\u30af\u30ea\u30c3\u30af\uff09\u6642\u306b\u884c\u756a32\u306e\u00a0 \u201cevent.target.id\u201d\u00a0 \u306b\u3088\u308a\u5bfe\u8c61\u8981\u7d20\u306e\uff29\uff24\u756a\u53f7\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002\u6b21\u306b\u884c\u756a40\uff5e47\u306e\u30de\u30a6\u30b9\u30e0\u30fc\u30d6\u30a4\u30d9\u30f3\u30c8\u767a\u751f\uff08\u30c9\u30e9\u30c3\u30b0\u64cd\u4f5c\uff09\u6642\u306b\u3001\u53d6\u5f97\u3057\u305f\uff29\uff24\u306e\u8981\u7d20\u5ea7\u6a19\u3092\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u3067\u8981\u7d20\u3092\u79fb\u52d5\u3055\u305b\u307e\u3059\u3002\u884c\u756a50\u306e\u30de\u30a6\u30b9\u30a2\u30c3\u30d7\u30a4\u30d9\u30f3\u30c8\u767a\u751f\u6642\u306b\u306f\u3001\uff29\uff24\u756a\u53f7\uff0c\u64cd\u4f5c\u30d5\u30e9\u30b0\uff08\u201cmv_fg\u201d\uff09\u3092\u521d\u671f\u5316\u3057\u3001\u4e00\u9023\u306e\u79fb\u52d5\u51e6\u7406\u3092\u5b8c\u4e86\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"height-set:true height:800 lang:default decode:true\">&lt;!doctype html&gt;\r\n&lt;html lang=\"ja\"&gt;\r\n\r\n&lt;head&gt;\r\n    &lt;meta charset=\"utf-8\"&gt;\r\n\r\n    &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"&gt;\r\n    &lt;title&gt;DRAG &amp; DROP&lt;\/title&gt;\r\n\r\n    &lt;style&gt;\r\n\t* { margin:0; }\r\n\t.draw_info th, .draw_info td { border:solid 1px #000000; text-align:center; vertical-align:middle; }\r\n\t.draw_info { border: solid 1px #000000; border-collapse:collapse; margin:5px 10px;}\r\n\t.div_dragbl { cursor:move; position:absolute; }\r\n    &lt;\/style&gt;\r\n\r\n    &lt;script type=\"text\/javascript\"&gt;\r\n\r\n\tvar mv_fg=\"\"; \r\n\tvar mvs_x=0; var mvs_y=0;\r\n\tvar tgt_id_no; var z_idx_ini=100;\r\n\tvar X_STT_P=0; var Y_STT_P=100;\r\n\tvar img_wdt=150; var img_hgt=120;\r\n\r\n\tfunction init_chk(){\r\n\t    get_window_info() ;\r\n\t}\r\n\r\n\t\/\/ \u25c6\u30de\u30a6\u30b9\u30c0\u30a6\u30f3\u25c6\r\n\twindow.onmousedown = function(e) {\r\n\r\n\t    mv_fg = \"true\" ; tgt_id_no = event.target.id ; z_idx_ini = z_idx_ini + 1 ;\r\n\r\n\t    document.getElementById(tgt_id_no).style.zIndex = z_idx_ini ;\r\n\t    mvs_x = event.clientX - parseInt(document.getElementById(tgt_id_no).style.left.replace(\"px\",\"\")) ;\r\n\t    mvs_y = event.clientY - parseInt(document.getElementById(tgt_id_no).style.top.replace(\"px\",\"\")) ;\r\n\t}\r\n\r\n\t\/\/ \u25c6\u30de\u30a6\u30b9\u30e0\u30fc\u30d6\u25c6\r\n\twindow.onmousemove = function(e) {\r\n\t    if(mv_fg == \"true\") {\r\n\t\tvar cur_x = event.clientX - mvs_x ; var cur_y = event.clientY - mvs_y ;\r\n\r\n\t\tdocument.getElementById(tgt_id_no).style.left = cur_x + \"px\" ;\r\n\t\tdocument.getElementById(tgt_id_no).style.top = cur_y + \"px\"  ;\r\n\t    }\r\n\t}\r\n\r\n\t\/\/ \u25c6\u30de\u30a6\u30b9\u30a2\u30c3\u30d7\u25c6\r\n\twindow.onmouseup = function(e) { mv_fg = \"false\" ; tgt_id_no = \"\" ; }\r\n\r\n\t\/\/ \u25c6\u30a6\u30a3\u30f3\u30c9\u30a6\u30ea\u30b5\u30a4\u30ba\u25c6\r\n\twindow.onresize = function(e) { get_window_info() ; }\r\n\r\n\tfunction get_window_info(){\r\n\t    \r\n\t    var sW = window.innerWidth ; var sH = window.innerHeight ;\r\n\t    var elm_div = document.getElementById(\"draggable_div\") ;\r\n\t    var rect = elm_div.getBoundingClientRect() ;\r\n\t    Y_STT_P = Math.ceil(rect.top\/10) + 20 ;\r\n\t    X_STT_P = Math.ceil(rect.left\/10) + 20 ;\r\n\r\n\t    var drg_elm=document.getElementsByClassName(\"div_dragbl\");\r\n\t    for(var i=0 ; drg_elm.length &gt; i ; i++){\r\n\t\tdrg_elm[i].style.top = Y_STT_P + \"px\" ;\r\n\t\tdrg_elm[i].style.left = X_STT_P + i * img_wdt + \"px\" ;\r\n\t\tdrg_elm[i].style.width = img_wdt + \"px\" ;\r\n\t\tdrg_elm[i].style.height = img_hgt + \"px\" ;\r\n\t\tdrg_elm[i].style.zIndex = z_idx_ini ;\r\n\t\tdrg_elm[i].innerHTML = drg_elm[i].id ;\r\n\t    }\r\n\t}\r\n\r\n    &lt;\/script&gt;\r\n&lt;\/head&gt;\r\n\r\n&lt;body onLoad=\"init_chk()\"&gt;\r\n\t&lt;div id=\"draggable_div\" style=\"position:relative ; clear:both;\"&gt;\r\n\t&lt;div class=\"div_dragbl\" id=\"000001\" style=\"left:0px; top:0px; background-color:blue;\"&gt;&lt;\/div&gt;\r\n\t&lt;div class=\"div_dragbl\" id=\"000002\" style=\"left:0px; top:0px; background-color:red;\"&gt;&lt;\/div&gt;\r\n\t&lt;div class=\"div_dragbl\" id=\"000003\" style=\"left:0px; top:0px; background-color:green;\"&gt;&lt;\/div&gt;\r\n\t&lt;div class=\"div_dragbl\" id=\"000004\" style=\"left:0px; top:0px; background-color:aqua;\"&gt;&lt;\/div&gt;\r\n\t&lt;div class=\"div_dragbl\" id=\"000005\" style=\"left:0px; top:0px; background-color:yellow;\"&gt;&lt;\/div&gt;\r\n\t&lt;div class=\"div_dragbl\" id=\"000006\" style=\"left:0px; top:0px; background-color:pink;\"&gt;&lt;\/div&gt;\r\n\t&lt;\/div&gt;\r\n&lt;\/body&gt; \r\n\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>&nbsp;<\/p>\n<table style=\"width: 100%; border-collapse: collapse; border-style: none; height: 27px;\" border=\"1\">\n<tbody>\n<tr style=\"height: 30px; border-bottom: 3px #0000ff solid;\">\n<td style=\"width: 1.5%; border-style: none; background-color: #0000ff; height: 27px;\"><\/td>\n<td style=\"width: 2%; border-style: none; height: 27px; background-color: #ffffff;\"><\/td>\n<td style=\"border-style: none; height: 27px; background-color: #ffffff;\"><span style=\"font-family: verdana, geneva, sans-serif;\"><strong><span style=\"font-size: 18pt; color: #0000ff;\">\u307e\u3068\u3081<\/span><\/strong><\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6b21\u56de\u306f\u3001\u30a6\u30a3\u30f3\u30c9\u30a6\u30b5\u30a4\u30ba\u3092\u691c\u51fa\u3057\u3001\u6c34\u5e73\u65b9\u5411\u306b\u8981\u7d20\u304c\u306f\u307f\u51fa\u3055\u306a\u3044\u69d8\u306b\u8907\u6570\u884c\u306b\u3057\u3066\u914d\u5217\u3055\u305b\u308b\u65b9\u6cd5\u3092\u691c\u8a0e\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u3000\u8981 \u5c11\u3057\u524d\u306b jQuery UI \u201cSortable\u201d \u3092\u4f7f\u3063\u3066\u3001&lt;li&gt;\uff0c&lt;tr&gt;\uff0c&lt;div&gt; \u7b49\u306e\u8981\u7d20\u3092\u4e26\u3073\u66ff\u3048\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f5c\u308a\u307e\u3057\u305f\u3002\u6700\u8fd1\u4f5c\u3063\u3066\u3044\u305f\u304a\u7d75\u63cf\u304d\u30c4\u30fc\u30eb\u3067\u7de8\u96c6\u3057\u305f &hellip; <a href=\"https:\/\/kats-eye.net\/info\/2019\/02\/22\/drag_drop_01\/\" class=\"more-link\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"screen-reader-text\">\u30de\u30a6\u30b9\u30c9\u30e9\u30c3\u30b0\u306b\u3088\u308b\u8981\u7d20\u4e26\u3073\u66ff\u3048\u691c\u8a0e\u2460<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":2333,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[44],"tags":[59,53,48],"_links":{"self":[{"href":"https:\/\/kats-eye.net\/info\/wp-json\/wp\/v2\/posts\/2311"}],"collection":[{"href":"https:\/\/kats-eye.net\/info\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kats-eye.net\/info\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kats-eye.net\/info\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kats-eye.net\/info\/wp-json\/wp\/v2\/comments?post=2311"}],"version-history":[{"count":26,"href":"https:\/\/kats-eye.net\/info\/wp-json\/wp\/v2\/posts\/2311\/revisions"}],"predecessor-version":[{"id":2355,"href":"https:\/\/kats-eye.net\/info\/wp-json\/wp\/v2\/posts\/2311\/revisions\/2355"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kats-eye.net\/info\/wp-json\/wp\/v2\/media\/2333"}],"wp:attachment":[{"href":"https:\/\/kats-eye.net\/info\/wp-json\/wp\/v2\/media?parent=2311"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kats-eye.net\/info\/wp-json\/wp\/v2\/categories?post=2311"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kats-eye.net\/info\/wp-json\/wp\/v2\/tags?post=2311"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}