{"id":2565,"date":"2024-09-23T11:19:56","date_gmt":"2024-09-23T02:19:56","guid":{"rendered":"https:\/\/haugenic.com\/?p=2565"},"modified":"2024-09-23T11:28:09","modified_gmt":"2024-09-23T02:28:09","slug":"2565","status":"publish","type":"post","link":"https:\/\/haugenic.com\/?p=2565","title":{"rendered":"\u3010JavaScript\u30112\u679a\u306e\u753b\u50cf\u3092\u30af\u30ea\u30c3\u30af\u3067\u30d5\u30e5\u30fc\u30b8\u30e7\u30f3\u3059\u308b\u3088\u3046\u306b\u5207\u308a\u66ff\u3048\u308b\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3"},"content":{"rendered":"<p>\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u3067\u753b\u50cf\u3092\u30d5\u30e5\u30fc\u30b8\u30e7\u30f3\u3055\u305b\u308b\u65b9\u6cd5\u3002Javascript\u3092\u7528\u3044\u3066\u30af\u30ea\u30c3\u30af\u30672\u679a\u306e\u753b\u50cf\u304c\u5f90\u3005\u306b\u5207\u308a\u66ff\u308f\u308b\u3088\u3046\u306b\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\r\n<h2>2\u679a\u306e\u753b\u50cf\u3092\u7528\u610f<\/h2>\r\n<div class=\"clearfix responbox50 smart50 gazouab\">\r\n<div class=\"lbox\"><img decoding=\"async\" src=\"https:\/\/haugenic.com\/wp-content\/uploads\/2024\/09\/kirikae2.jpg\" alt=\"\u753b\u50cfA\" data-st-lazy-load=\"false\" \/><br \/>\r\n<span class=\"maruobi1\">\u753b\u50cfA<\/span><\/div>\r\n<div class=\"rbox\"><img decoding=\"async\" src=\"https:\/\/haugenic.com\/wp-content\/uploads\/2024\/09\/kirikae1.jpg\" alt=\"\u753b\u50cfB\" data-st-lazy-load=\"false\" \/><br \/>\r\n<span class=\"maruobi4\">\u753b\u50cfB<\/span><\/div>\r\n<\/div>\r\n<p>\u5207\u308a\u66ff\u3048\u305f\u3044A\u3068B\u306e2\u679a\u306e\u753b\u50cf\u3092\u7528\u610f\u3057\u307e\u3059\u3002\u30b5\u30a4\u30ba\u306f\u9055\u3063\u3066\u3082\u69cb\u3044\u307e\u305b\u3093\u304c\u3001<span style=\"color: #000080;\"><\/span><span class=\"zebline-maker zebline-color-a\"><span style=\"color: #000080;\">\u30a2\u30b9\u30da\u30af\u30c8\u6bd4\u3092\u5408\u308f\u305b\u3066\u304a\u304f\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059<\/span><\/span>\u3002<\/p>\r\n<h2>\u30af\u30ea\u30c3\u30af\u3067\u753b\u50cf\u3092\u5207\u308a\u66ff\u3048\u308b<\/h2>\r\n<h3 class=\"sa sa--up\">\u901a\u5e38\u306e\u5207\u308a\u66ff\u3048<\/h3>\r\n<p><span onclick=\"var img = this.querySelector('img'); \r\n    img.src = img.src.endsWith('kirikae2.jpg') ? 'https:\/\/haugenic.com\/wp-content\/uploads\/2024\/09\/kirikae1.jpg' : 'https:\/\/haugenic.com\/wp-content\/uploads\/2024\/09\/kirikae2.jpg';\"> <img decoding=\"async\" src=\"https:\/\/haugenic.com\/wp-content\/uploads\/2024\/09\/kirikae2.jpg\" width=\"200px\" \/> <\/span><\/p>\r\n<p>\u3053\u308c\u306f\u30b7\u30f3\u30d7\u30eb\u306b<span class=\"maruobi1\">\u753b\u50cfA<\/span>\u3068<span class=\"maruobi4\">\u753b\u50cfB<\/span>\u3092\u30af\u30ea\u30c3\u30af\u3054\u3068\u306b\u5207\u308a\u66ff\u3048\u308b\u30d1\u30bf\u30fc\u30f3\u3067\u3059\u3002<\/p>\r\n\r\n\t\t\t\t\r\n\t\t\t\t\t<a href=\"https:\/\/haugenic.com\/?p=2510\" class=\"st-cardlink\">\r\n\t\t\t\t\t<div class=\"kanren st-cardbox \" >\r\n\t\t\t\t\t\t\t\t\t\t\t\t<dl class=\"clearfix\">\r\n\t\t\t\t\t\t\t<dt class=\"st-card-img\">\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" width=\"640\" height=\"320\" src=\"https:\/\/haugenic.com\/wp-content\/uploads\/2024\/09\/kirikae1.gif\" class=\"attachment-st_thumb150 size-st_thumb150 wp-post-image\" alt=\"\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/dt>\r\n\t\t\t\t\t\t\t<dd>\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<h5 class=\"st-cardbox-t\">\u3010JavaScript\u3011\u89e6\u308c\u308b\u30fb\u30af\u30ea\u30c3\u30af\u306e\u4e21\u65b9\u30672\u679a\u306e\u753b\u50cf\u3092\u5207\u308a\u66ff\u3048\u308b\u65b9\u6cd5\u3010PC\u30fb\u30b9\u30de\u30db\u5bfe\u5fdc\u3011<\/h5>\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<p class=\"cardbox-more\">\u7d9a\u304d\u3092\u898b\u308b<\/p>\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/dd>\r\n\t\t\t\t\t\t<\/dl>\r\n\t\t\t\t\t<\/div>\r\n\t\t\t\t\t<\/a>\r\n\r\n\t\t\t\t\r\n<h2>\u30af\u30ea\u30c3\u30af\u3067\u753b\u50cf\u3092\u30d5\u30e5\u30fc\u30b8\u30e7\u30f3\u3055\u305b\u308b<\/h2>\r\n<h3 class=\"sa sa--up\">\u30d5\u30e5\u30fc\u30b8\u30e7\u30f3\u5207\u308a\u66ff\u3048<\/h3>\r\n<div class=\"fusion-container\" style=\"position: relative; width: 100%; max-width: 200px; height: 200px; cursor: pointer;\"><img decoding=\"async\" src=\"https:\/\/haugenic.com\/wp-content\/uploads\/2024\/09\/kirikae2.jpg\" class=\"fusion-img bottom\" data-src-a=\"https:\/\/haugenic.com\/wp-content\/uploads\/2024\/09\/kirikae2.jpg\" data-src-b=\"https:\/\/haugenic.com\/wp-content\/uploads\/2024\/09\/kirikae1.jpg\" style=\"position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover;\" \/> <img decoding=\"async\" src=\"https:\/\/haugenic.com\/wp-content\/uploads\/2024\/09\/kirikae1.jpg\" class=\"fusion-img top\" data-src-a=\"https:\/\/haugenic.com\/wp-content\/uploads\/2024\/09\/kirikae2.jpg\" data-src-b=\"https:\/\/haugenic.com\/wp-content\/uploads\/2024\/09\/kirikae1.jpg\" style=\"position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0; object-fit: cover;\" \/><\/div>\r\n<p>\u3053\u308c\u306f\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u3067\u753b\u50cf\u3092\u30d5\u30e5\u30fc\u30b8\u30e7\u30f3\u3055\u305b\u308b\u30d1\u30bf\u30fc\u30f3\u3067\u3059\u3002<\/p>\r\n<p><span class=\"maruobi1\">\u753b\u50cfA<\/span>\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u5f90\u3005\u306b\u3058\u308f\u3041\uff5e\u3063\u3068<span class=\"maruobi4\">\u753b\u50cfB<\/span>\u306b\u5207\u308a\u66ff\u308f\u308a\u307e\u3059\u3002\u518d\u5ea6\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u3001\u5f90\u3005\u306b\u3058\u308f\u3041\uff5e\u3063\u3068<span class=\"maruobi1\">\u753b\u50cfA<\/span>\u306b\u623b\u308a\u307e\u3059\u3002<\/p>\r\n<p><span class=\"maruobi1\">\u753b\u50cfA<\/span>\u3068<span class=\"maruobi4\">\u753b\u50cfB<\/span>\u3092\u91cd\u306d\u3001Javascript\u3092\u7528\u3044\u3066\u900f\u660e\u5ea6<span class=\"marker_yellow_futo\">opacity<\/span>\u306e\u5024\u3092\u5f90\u3005\u306b\u5909\u5316\u3055\u305b\u3001\u30d5\u30e5\u30fc\u30b8\u30e7\u30f3\u3057\u3066\u3044\u308b\u3088\u3046\u306b\u898b\u305b\u308b\u3001\u3068\u3044\u3063\u305f\u30ab\u30e9\u30af\u30ea\u3067\u3059\u3002\u30d5\u30e5\u30fc\u30b8\u30e7\u30f3\u4e2d\u306f\u30af\u30ea\u30c3\u30af\u3067\u304d\u306a\u3044\u3088\u3046\u306b\u5236\u9650\u3092\u304b\u3051\u3066\u3044\u307e\u3059\u3002<\/p>\r\n<h2>\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9<\/h2>\r\n<h3 class=\"sa sa--up\">JavaScript\u30b3\u30fc\u30c9<\/h3>\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\">&lt;script&gt;\r\n(function() {\r\n    const animationConfig = {\r\n        duration: 2000,  \/\/ 2\u79d2\r\n        easing: function easeInOutQuad(t) {\r\n            return t &lt; 0.5 ? 2 * t * t : 1 - Math.pow(-2 * t + 2, 2) \/ 2;\r\n        }\r\n    };\r\n\r\n    function preloadImages(sources) {\r\n        sources.forEach(src =&gt; {\r\n            const img = new Image();\r\n            img.src = src;\r\n        });\r\n    }\r\n\r\n    function handleImageClick(event) {\r\n        const container = event.target.closest('.fusion-container');\r\n        if (!container) return;\r\n\r\n        const bottomImg = container.querySelector('.bottom');\r\n        const topImg = container.querySelector('.top');\r\n        container.style.pointerEvents = 'none';\r\n\r\n        let progress = 0;\r\n        const startTime = performance.now();\r\n\r\n        function animate(currentTime) {\r\n            progress = (currentTime - startTime) \/ animationConfig.duration;\r\n            if (progress &lt; 1) {\r\n                const easeProgress = animationConfig.easing(progress);\r\n                topImg.style.opacity = easeProgress;\r\n                requestAnimationFrame(animate);\r\n            } else {\r\n                topImg.style.opacity = 1;\r\n                [bottomImg.src, topImg.src] = [topImg.src, bottomImg.src];\r\n                topImg.style.opacity = 0;\r\n                container.style.pointerEvents = 'auto';\r\n            }\r\n        }\r\n\r\n        requestAnimationFrame(animate);\r\n    }\r\n\r\n    document.addEventListener('click', function(event) {\r\n        const container = event.target.closest('.fusion-container');\r\n        if (container) {\r\n            handleImageClick(event);\r\n        }\r\n    });\r\n\r\n    document.querySelectorAll('.fusion-container').forEach(container =&gt; {\r\n        const bottomSrc = container.querySelector('.bottom').getAttribute('data-src-a');\r\n        const topSrc = container.querySelector('.top').getAttribute('data-src-b');\r\n        preloadImages([bottomSrc, topSrc]);\r\n    });\r\n})();\r\n&lt;\/script&gt;<\/pre>\r\n<p>JavaScript\u30b3\u30fc\u30c9\u306f<span class=\"marker_yellow_futo\">&lt;\/body&gt;<\/span>\u306e\u524d\u306b\u5165\u308c\u307e\u3059\u3002<\/p>\r\n<p>3\u884c\u76ee\u306e<span class=\"marker_yellow_futo\">duration: 2000<\/span>\u306f\u30d5\u30e5\u30fc\u30b8\u30e7\u30f3\u3059\u308b\u6642\u9593\uff08\u30df\u30ea\u79d2\uff09\u3092\u8868\u3057\u307e\u3059\u30023500\u306b\u3059\u308c\u30703.5\u79d2\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\r\n<h3 class=\"sa sa--up\">HTML\u30b3\u30fc\u30c9<\/h3>\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"html\">&lt;div class=\"fusion-container\" style=\"position: relative; width: 100%; max-width: 200px; height: 200px; cursor: pointer;\"&gt;\r\n  &lt;img src=\"a.jpg\" class=\"fusion-img bottom\" data-src-a=\"a.jpg\" data-src-b=\"b.jpg\" style=\"position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover;\"&gt;\r\n  &lt;img src=\"b.jpg\" class=\"fusion-img top\" data-src-a=\"a.jpg\" data-src-b=\"b.jpg\" style=\"position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0; object-fit: cover;\"&gt;\r\n&lt;\/div&gt;<\/pre>\r\n<p><span class=\"maruobi1\">a.jpg<\/span>\u3068<span class=\"maruobi4\">b.jpg<\/span>\u3092\u54043\u7b87\u6240\u305a\u3064\u8a2d\u5b9a\u3057\u307e\u3059\u3002\u521d\u671f\u8868\u793a\u306f<span class=\"maruobi1\">a.jpg<\/span>\u3067\u3059\u3002<\/p>\r\n<p>\u753b\u50cf\u306e\u30b5\u30a4\u30ba\u306f<span class=\"marker_yellow_futo\">max-width: 200px;<\/span>\u3001<span class=\"marker_yellow_futo\">height: 200px;<\/span><span>\u3068\u8a2d\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002\u753b\u50cf\u30b5\u30a4\u30ba\u306b\u5fdc\u3058\u3066\u30a4\u30b8\u3063\u3066\u304f\u3060\u3055\u3044\u3002<\/span><\/p>\r\n<p><span>\u753b\u50cf\u306b\u89e6\u308c\u305f\u6642\u306b\u30ab\u30fc\u30bd\u30eb\u304c\u624b\u306e\u5f62\u306b<\/span>\u306a\u308b\u3088\u3046<span class=\"marker_yellow_futo\">cursor: pointer;<\/span>\u3092<span>\u8a2d\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002\u3053\u308c\u306f<span class=\"huto\"><span style=\"color: #000080;\">\u30af\u30ea\u30c3\u30af\u3067\u304d\u308b\u8981\u7d20\u3060\u3088\uff5e<\/span><\/span>\u3068\u308f\u304b\u308a\u3084\u3059\u304f\u3059\u308b\u305f\u3081\u3067\u3059\u304c\u3001\u666e\u901a\u306e\u30ab\u30fc\u30bd\u30eb\u306e\u307e\u307e\u304c\u3088\u3051\u308c\u3070\u524a\u9664\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/span><\/p>\r\n<h2>JavaScript\u3092\u4f7f\u308f\u306a\u3044\u30b7\u30f3\u30d7\u30eb\u306a\u30d1\u30bf\u30fc\u30f3<\/h2>\r\n<h3 class=\"sa sa--up\">\u7c21\u6613\u30d5\u30e5\u30fc\u30b8\u30e7\u30f3\u5207\u308a\u66ff\u3048<\/h3>\r\n<div class=\"fusion-container2\" onclick=\"this.classList.toggle('is-fusionped')\" style=\"max-width: 200px;\">\r\n<div class=\"fusion-image\"><img decoding=\"async\" src=\"https:\/\/haugenic.com\/wp-content\/uploads\/2024\/09\/kirikae2.jpg\" data-st-lazy-load=\"false\" \/> <img decoding=\"async\" src=\"https:\/\/haugenic.com\/wp-content\/uploads\/2024\/09\/kirikae1.jpg\" data-st-lazy-load=\"false\" \/><\/div>\r\n<\/div>\r\n<p>HTML\u3068CSS\u3060\u3051\u3067\u3082\u4f3c\u305f\u3088\u3046\u306a\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\r\n<p><span class=\"maruobi1\">\u753b\u50cfA<\/span>\u3068<span class=\"maruobi4\">\u753b\u50cfB<\/span>\u304c\u5207\u308a\u66ff\u308f\u308b\u77ac\u9593\u306b\u753b\u50cf\u304c\u82e5\u5e72\u8584\u308c\u3066\u898b\u3048\u308b\u3001\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u4e2d\u306b\u30af\u30ea\u30c3\u30af\u3067\u304d\u3066\u3057\u307e\u3046\u3001\u3068\u3044\u3046\u6b20\u70b9\u306f\u3042\u308a\u307e\u3059\u304c\u3001JavaScript\u3092\u4f7f\u308f\u306a\u3044\u306e\u3067\u5b9f\u88c5\u306f\u7c21\u5358\u3067\u3059\u3002<\/p>\r\n<div class=\"su-spoiler su-spoiler-style-default su-spoiler-icon-plus su-spoiler-closed\" data-scroll-offset=\"0\" data-anchor-in-url=\"no\"><div class=\"su-spoiler-title\" tabindex=\"0\" role=\"button\"><span class=\"su-spoiler-icon\"><\/span>\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u898b\u308b<\/div><div class=\"su-spoiler-content su-u-clearfix su-u-trim\">\r\n<h3 class=\"sa sa--up\">HTML\u30b3\u30fc\u30c9<\/h3>\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"html\">&lt;div class=\"fusion-container\" onclick=\"this.classList.toggle('is-fusionped')\" style=\"max-width: 200px;\"&gt;\r\n  &lt;div class=\"fusion-image\"&gt;\r\n    &lt;img src=\"a.jpg\"&gt;\r\n    &lt;img src=\"b.jpg\"&gt;\r\n  &lt;\/div&gt;\r\n&lt;\/div&gt;<\/pre>\r\n<p>\u753b\u50cf\u306e\u30b5\u30a4\u30ba\u306f<span class=\"marker_yellow_futo\">max-width: 200px;<\/span><span>\u306e\u6570\u5b57\u3092\u30a4\u30b8\u308b\u3068\u8abf\u6574\u3067\u304d\u307e\u3059\u3002<\/span><\/p>\r\n<h3 class=\"sa sa--up\">CSS\u30b3\u30fc\u30c9<\/h3>\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"css\">.fusion-container {\r\n  width: 100%;\r\n  cursor: pointer;\r\n  overflow: hidden;\r\n}\r\n.fusion-image {\r\n  position: relative;\r\n  width: 100%;\r\n  padding-top: 100%;\r\n}\r\n.fusion-image img {\r\n  position: absolute;\r\n  top: 0;\r\n  left: 0;\r\n  width: 100%;\r\n  height: 100%;\r\n  object-fit: cover; \r\n  transition: opacity 2s ease-in-out, transform 2s ease-in-out;\r\n}\r\n\r\n.fusion-image img:nth-child(1) {\r\n  opacity: 1;\r\n}\r\n.fusion-image img:nth-child(2) {\r\n  opacity: 0;\r\n}\r\n.fusion-container.is-fusionped .fusion-image img:nth-child(1) {\r\n  opacity: 0;\r\n}\r\n.fusion-container.is-fusionped .fusion-image img:nth-child(2) {\r\n  opacity: 1;\r\n}<\/pre>\r\n<\/div><\/div>","protected":false},"excerpt":{"rendered":"\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u30672\u679a\u306e\u753b\u50cf\u3092\u30d5\u30e5\u30fc\u30b8\u30e7\u30f3\u3055\u305b\u308b\u65b9\u6cd5\u3002\u30af\u30ea\u30c3\u30af\u3067\u753b\u50cf\u3092\u5207\u308a\u66ff\u3048\u307e\u3059\u3002","protected":false},"author":1,"featured_media":2587,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[5],"tags":[],"class_list":["post-2565","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript"],"acf":[],"_links":{"self":[{"href":"https:\/\/haugenic.com\/index.php?rest_route=\/wp\/v2\/posts\/2565","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/haugenic.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/haugenic.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/haugenic.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/haugenic.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2565"}],"version-history":[{"count":18,"href":"https:\/\/haugenic.com\/index.php?rest_route=\/wp\/v2\/posts\/2565\/revisions"}],"predecessor-version":[{"id":2762,"href":"https:\/\/haugenic.com\/index.php?rest_route=\/wp\/v2\/posts\/2565\/revisions\/2762"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/haugenic.com\/index.php?rest_route=\/wp\/v2\/media\/2587"}],"wp:attachment":[{"href":"https:\/\/haugenic.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2565"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/haugenic.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2565"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/haugenic.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2565"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}