{"id":1787,"date":"2022-03-10T01:18:44","date_gmt":"2022-03-09T16:18:44","guid":{"rendered":"https:\/\/www.dogrow.net\/hp\/?p=1787"},"modified":"2022-03-12T07:07:55","modified_gmt":"2022-03-11T22:07:55","slug":"blog117","status":"publish","type":"post","link":"https:\/\/www.dogrow.net\/hp\/blog117\/","title":{"rendered":"(117) \u30da\u30fc\u30b8\u5148\u982d\u304b\u3089\u4efb\u610f\u306e\u8981\u7d20\u306e\u4e0a\u7aef\u30fb\u4e0b\u7aef\u307e\u3067\u306e\u30aa\u30d5\u30bb\u30c3\u30c8\u91cf\u3092\u53d6\u5f97\u3057\u305f\u3044\u3002"},"content":{"rendered":"<h1 class=\"my_h\">1. \u3084\u308a\u305f\u3044\u3053\u3068<\/h1>\n<p>\u4efb\u610f\u306e\u8981\u7d20\u306b\u3064\u3044\u3066\u3001<br \/>\n<span class=\"my_fc_deeppinkBBig\">\u30da\u30fc\u30b8\u5148\u982d\u304b\u3089\u3001\u8981\u7d20\u4e0a\u7aef\u307e\u3067\u306e\u8ddd\u96e2[px]\u3092\u77e5\u308a\u305f\u3044\u3002<\/span><br \/>\n\u540c\u6642\u306b\u3001<br \/>\n<span class=\"my_fc_deeppinkBBig\">\u30da\u30fc\u30b8\u5148\u982d\u304b\u3089\u3001\u8981\u7d20\u4e0b\u7aef\u307e\u3067\u306e\u8ddd\u96e2[px]\u3092\u77e5\u308a\u305f\u3044\u3002<\/span><\/p>\n<h1 class=\"my_h\">2. \u3084\u3063\u3066\u307f\u308b<\/h1>\n<p>\u4ee5\u4e0b\u306e 3\u6bb5\u968e\u3067\u6c42\u3081\u308b\u5fc5\u8981\u304c\u3042\u308b\u306e\u3060\u305d\u3046\u306a\u3002<\/p>\n<h3 class=\"my_h\">Step 1 : \u30da\u30fc\u30b8\u4e0a\u7aef\u304b\u3089\u753b\u9762\u4e0a\u7aef\u307e\u3067\u306e\u8ddd\u96e2[px]\u3092\u77e5\u308b\u3002<\/h3>\n<p>\u3053\u308c\u306f <span class=\"my_fc_deeppinkB\">window.pageYOffset<\/span> \u3092\u53c2\u7167\u3059\u308c\u3070\u3088\u3044\u3002<br \/>\n\u30b9\u30af\u30ed\u30fc\u30eb\u3057\u3066\u3044\u306a\u3051\u308c\u3070\u3001\u3053\u306e\u5024\u306f 0\u3060\u3002<br \/>\n\u30b9\u30af\u30ed\u30fc\u30eb\u3057\u3066\u3044\u308c\u3070\u3001\u3053\u306e\u5024\u306f\u30b9\u30af\u30ed\u30fc\u30eb\u91cf\u306b\u306a\u3063\u3066\u3044\u308b\u3002<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.dogrow.net\/hp\/wp-content\/uploads\/2022\/02\/i001-3.gif\" alt=\"\" class=\"my_add_bs1\" \/><\/p>\n<h3 class=\"my_h\">Step 2 : \u753b\u9762\u4e0a\u7aef\u304b\u3089\u8981\u7d20\u4e0a\u7aef\u307e\u3067\u306e\u8ddd\u96e2[px]\u3092\u77e5\u308b\u3002<\/h3>\n<p>\u3053\u308c\u306f <span class=\"my_fc_deeppinkB\">\u8981\u7d20.getBoundingClientRect().top<\/span> \u3092\u53c2\u7167\u3059\u308c\u3070\u3088\u3044\u3002<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.dogrow.net\/hp\/wp-content\/uploads\/2022\/02\/i002.gif\" alt=\"\" class=\"my_add_bs1\" \/><\/p>\n<h3 class=\"my_h\">Step 3 : \u4e21\u8005\u3092\u8db3\u3057\u7b97\u3059\u308b\u3002<\/h3>\n<p>\u95a2\u6570\u306b\u3057\u3066\u307f\u305f\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n\/\/ \u25a0 \u6307\u5b9a\u8981\u7d20\u306e\u4e0a\u7aef\u306e\u30da\u30fc\u30b8Y\u5ea7\u6a19\u3092\u5f97\u308b\u95a2\u6570\u3002\r\n\/\/ \u203belem\u306f native object\u3067\u3042\u308b\u3053\u3068\u3002(JQuery\u306f NG)\r\nfunction get_elem_pagePosY_top( elem ){\r\n  const pos = elem.getBoundingClientRect();   \/\/ \u6307\u5b9a\u8981\u7d20\u306eviewport\u5185\u306e\u76f8\u5bfe\u4f4d\u7f6e\u3092\u53d6\u5f97\r\n  return window.pageYOffset + pos.top;\r\n}\r\n<\/pre>\n<p>\u3064\u3044\u3067\u306b\u3001\u3053\u306e\u5024\u306b\u8981\u7d20\u306e\u9ad8\u3055\u3092\u8db3\u305b\u3070\u3001\u30da\u30fc\u30b8\u5148\u982d\u304b\u3089\u8981\u7d20\u4e0b\u7aef\u307e\u3067\u306e\u8ddd\u96e2\u304c\u6c42\u3081\u3089\u308c\u308b\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n\/\/ \u25a0 \u6307\u5b9a\u8981\u7d20\u306e\u4e0b\u7aef\u306e\u30da\u30fc\u30b8Y\u5ea7\u6a19\u3092\u5f97\u308b\u95a2\u6570\u3002\r\n\/\/ \u203belem\u306f native object\u3067\u3042\u308b\u3053\u3068\u3002(JQuery\u306f NG)\r\nfunction get_elem_pagePosY_bottom( elem ){\r\n  const pos = elem.getBoundingClientRect();   \/\/ \u6307\u5b9a\u8981\u7d20\u306eviewport\u5185\u306e\u76f8\u5bfe\u4f4d\u7f6e\u3092\u53d6\u5f97\r\n  return window.pageYOffset + pos.top + pos.height;\r\n}\r\n<\/pre>\n<p>getBoundingClientRect\u306b\u3064\u3044\u3066\u306f\u3001\u3053\u3061\u3089\u306e\u30da\u30fc\u30b8\u3067\u4ed5\u69d8\u3092\u8aac\u660e\u3057\u3066\u304f\u3060\u3055\u3063\u3066\u3044\u308b\u3002 m(_ _)m<br \/>\n<a href=\"https:\/\/developer.mozilla.org\/ja\/docs\/Web\/API\/Element\/getBoundingClientRect\" target=\"_blank\" rel=\"noopener\">Element.getBoundingClientRect()<\/a><\/p>\n<p><span class=\"my_fc_redBBig\">\u203b\u6ce8\u610f<\/span><br \/>\n\u56e0\u307f\u306b\u3001JQuery\u3067 $(elem).height() \u3068\u3059\u308b\u3068 border, padding\u3092\u9664\u3044\u305f\u5185\u90e8\u9818\u57df\u306e\u9ad8\u3055\u304c\u53d6\u5f97\u3067\u304d\u308b\u3002<br \/>\n\u4e0a\u8a18\u95a2\u6570\u4e2d\u306e height \u306f border, padding\u3092\u542b\u3080\u5024\u3001JQuery\u3067\u66f8\u304f\u306a\u3089\u3070 $(elem).outerHeight() \u306b\u76f8\u5f53\u3059\u308b\u5024\u304c\u53d6\u5f97\u3067\u304d\u308b\u3002 <\/p>\n<p>\u56f3\u306b\u307e\u3068\u3081\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308b\u3002<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.dogrow.net\/hp\/wp-content\/uploads\/2022\/02\/i003.gif\" alt=\"\" \/><\/p>\n<h1 class=\"my_h\">3. \u5fdc\u7528<\/h1>\n<h3 class=\"my_h\">(1) \u5b9f\u7528\u7684\u306a\u95a2\u6570\u306b\u3059\u308b\u3002<\/h3>\n<p>\u5fdc\u7528\u3068\u8a00\u3046\u307b\u3069\u3067\u306f\u306a\u3044\u304c\u3001TOP\u3068 BOTTOM\u3092\u540c\u6642\u306b\u77e5\u308a\u305f\u3044\u30b1\u30fc\u30b9\u3082\u591a\u3044\u306e\u3067\u3001\u3053\u308c\u306b\u5bfe\u5fdc\u3059\u308b\u3002<br \/>\n\u623b\u308a\u5024\u3092\u914d\u5217\u3067\u8fd4\u3059\u3060\u3051\u3060\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n\/\/ \u25a0 \u6307\u5b9a\u8981\u7d20\u306e\u4e0a\u7aef\u30fb\u4e0b\u7aef\u306e\u30da\u30fc\u30b8Y\u5ea7\u6a19\u3092\u5f97\u308b\u95a2\u6570\u3002\r\n\/\/ \u203belem\u306f native object\u3067\u3042\u308b\u3053\u3068\u3002(JQuery\u306f NG)\r\nfunction get_elem_pagePosY( elem ){\r\n  const pos = elem.getBoundingClientRect();   \/\/ \u6307\u5b9a\u8981\u7d20\u306eviewport\u5185\u306e\u76f8\u5bfe\u4f4d\u7f6e\u3092\u53d6\u5f97\r\n  const topY = window.pageYOffset + pos.top;  \/\/ \u6307\u5b9a\u8981\u7d20\u4e0a\u7aef\u306e\u30da\u30fc\u30b8Y\u5ea7\u6a19\u3092\u7b97\u51fa\r\n  const btmY = topY + pos.height;             \/\/ \u6307\u5b9a\u8981\u7d20\u4e0b\u7aef\u306e\u30da\u30fc\u30b8Y\u5ea7\u6a19\u3092\u7b97\u51fa\r\n  return &#x5B;topY, btmY];                        \/\/ Call\u5143\u306b\u914d\u5217\u3067\u8fd4\u5374\u3059\u308b\u3002\r\n}\r\n<\/pre>\n<p>\u3053\u306e\u95a2\u6570\u306f\u3053\u3093\u306a\u98a8\u306b\u4f7f\u3048\u3070\u3088\u3044\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nvar &#x5B;posYtop, posYbottom] = get_elem_pageY(elem);\r\n<\/pre>\n<p>\u56e0\u307f\u306b\u3001$(&#8216;#AAA&#8217;) \u306a\u3069 JQuery\u3067\u4f5c\u3063\u305f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u6e21\u3059\u5834\u5408 $(&#8216;#AAA&#8217;).<span class=\"my_fc_deeppinkB\">get(0)<\/span> \u3067\u30cd\u30a4\u30c6\u30a3\u30d6\u306b\u623b\u3057\u3066\u304b\u3089\u6e21\u3059\u3053\u3068\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nvar &#x5B;posYtop, posYbottom] = get_elem_pageY(elem.get(0));\r\n<\/pre>\n<hr class=\"my_hr_bottom\">\n","protected":false},"excerpt":{"rendered":"<p>1. \u3084\u308a\u305f\u3044\u3053\u3068 \u4efb\u610f\u306e\u8981\u7d20\u306b\u3064\u3044\u3066\u3001 \u30da\u30fc\u30b8\u5148\u982d\u304b\u3089\u3001\u8981\u7d20\u4e0a\u7aef\u307e\u3067\u306e\u8ddd\u96e2[px]\u3092\u77e5\u308a\u305f\u3044\u3002 \u540c\u6642\u306b\u3001 \u30da\u30fc\u30b8\u5148\u982d\u304b\u3089\u3001\u8981\u7d20\u4e0b\u7aef\u307e\u3067\u306e\u8ddd\u96e2[px]\u3092\u77e5\u308a\u305f\u3044\u3002 2. \u3084\u3063\u3066\u307f\u308b \u4ee5\u4e0b\u306e 3\u6bb5\u968e\u3067\u6c42\u3081\u308b\u5fc5\u8981\u304c\u3042\u308b\u306e\u3060\u305d\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.dogrow.net\/hp\/blog117\/\">\u7d9a\u304d\u3092\u8aad\u3080 &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-1787","post","type-post","status-publish","format-standard","hentry","category-javascriptjquery"],"views":1002,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.dogrow.net\/hp\/wp-json\/wp\/v2\/posts\/1787","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dogrow.net\/hp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dogrow.net\/hp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dogrow.net\/hp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dogrow.net\/hp\/wp-json\/wp\/v2\/comments?post=1787"}],"version-history":[{"count":26,"href":"https:\/\/www.dogrow.net\/hp\/wp-json\/wp\/v2\/posts\/1787\/revisions"}],"predecessor-version":[{"id":1958,"href":"https:\/\/www.dogrow.net\/hp\/wp-json\/wp\/v2\/posts\/1787\/revisions\/1958"}],"wp:attachment":[{"href":"https:\/\/www.dogrow.net\/hp\/wp-json\/wp\/v2\/media?parent=1787"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dogrow.net\/hp\/wp-json\/wp\/v2\/categories?post=1787"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dogrow.net\/hp\/wp-json\/wp\/v2\/tags?post=1787"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}