1/** 2 * BNature Theme - Front Page JavaScript 3 */ 4 5document.addEventListener('DOMContentLoaded', function() { 6 // åæå 7 init(); 8}); 9 10/** 11 * åæå颿° 12 */ 13function init() { 14 // ãããã¼ãã´ã®åæå 15 initHeaderLogo(); 16 17 // ãã³ãã¼ã¬ã¼ã¡ãã¥ã¼ã®åæå 18 initHamburgerMenu(); 19 20 // ã¹ã ã¼ã¹ã¹ã¯ãã¼ã«ã®åæå 21 initSmoothScroll(); 22 23 // ããããã¿ã³ã®åæå 24 initToTopButton(); 25 26 // ã«ã¹ã¿ã ã«ã¼ã½ã«ã®åæå 27 initCustomCursor(); 28 29 // ã¹ã©ã¤ãã·ã§ã¼ã®åæå 30 initSlideshow(); 31 32 // ãã§ã¼ãã¤ã³ã¢ãã¡ã¼ã·ã§ã³ã®åæå 33 initFadeInAnimation(); 34 35 // ã¡ã¤ã³ãã¸ã¥ã¢ã«ããã¹ãã¢ãã¡ã¼ã·ã§ã³ã®åæå 36 initMainVisualTextAnimation(); 37 38 // Aboutãã¼ã¸ã®ãã´ã¢ãã¡ã¼ã·ã§ã³åæå 39 initAboutLogoAnimation(); 40 41 // ã¿ã¤ãã«ã¢ãã¡ã¼ã·ã§ã³ã®åæå 42 initTitleAnimation(); 43 44 // p-case-detail__subimage-containerã®é«ãè¨ç®åæå 45 initSubimageContainerHeight(); 46 47 // ãã©ã©ãã¯ã¹ã¢ãã¡ã¼ã·ã§ã³ã®åæå 48 initParallaxAnimation(); 49 50 // è¤åã¢ãã¡ã¼ã·ã§ã³ã®åæå 51 initComplexImageAnimation(); 52 53 // ã±ã¼ã¹ã¢ã¤ãã ã¢ãã¡ã¼ã·ã§ã³ã®åæå 54 initCaseItemAnimation(); 55 56 // Load Moreãã¿ã³ã®åæå 57 initLoadMore('.c-case__list'); 58 initLoadMore('.c-blog__list'); 59 initLoadMore('.c-information__list'); 60} 61 62/** 63 * ãããã¼ãã´ã®è¡¨ç¤ºå¶å¾¡ 64 */ 65function initHeaderLogo() { 66 const headerLogo = document.querySelector('.l-header__logo'); 67 const mainvisual = document.querySelector('.p-mainvisual'); 68 69 if (!headerLogo || !mainvisual) return; 70 71 // Intersection Observerã®è¨å® 72 const observerOptions = { 73 root: null, 74 rootMargin: '0px', 75 threshold: 0 76 }; 77 78 const observer = new IntersectionObserver((entries) => { 79 entries.forEach((entry) => { 80 if (entry.isIntersecting) { 81 // mainvisualãç»é¢å ã«ããæï¼ãã´ãé表示 82 headerLogo.style.opacity = '0'; 83 headerLogo.style.visibility = 'hidden'; 84 } else { 85 // mainvisualãç»é¢å¤ã®æï¼ãã´ã表示 86 headerLogo.style.opacity = '1'; 87 headerLogo.style.visibility = 'visible'; 88 } 89 }); 90 }, observerOptions); 91 92 // mainvisualãç£è¦éå§ 93 observer.observe(mainvisual); 94} 95 96/** 97 * ãã³ãã¼ã¬ã¼ã¡ãã¥ã¼ã®å¶å¾¡ 98 */ 99function initHamburgerMenu() { 100 const hamburgerButton = document.querySelector('.c-hamburger'); 101 const gnav = document.querySelector('.c-gnav'); 102 const body = document.body; 103 104 if (!hamburgerButton || !gnav) return; 105 106 hamburgerButton.addEventListener('click', function() { 107 // ã¡ãã¥ã¼ã®ééç¶æ ãåãæ¿ã 108 const isOpen = gnav.classList.contains('is-open'); 109 110 if (isOpen) { 111 // ã¡ãã¥ã¼ãéãã 112 gnav.classList.remove('is-open'); 113 hamburgerButton.classList.remove('is-open'); 114 // body.classList.remove('is-nav-open'); 115 } else { 116 // ã¡ãã¥ã¼ãéã 117 gnav.classList.add('is-open'); 118 hamburgerButton.classList.add('is-open'); 119 // body.classList.add('is-nav-open'); 120 } 121 }); 122 123 // ã¡ãã¥ã¼å¤ã¯ãªãã¯æã«éãã 124 // gnav.addEventListener('click', function(e) { 125 // if (e.target === gnav) { 126 // gnav.classList.remove('is-open'); 127 // hamburgerButton.classList.remove('is-open'); 128 // body.classList.remove('is-nav-open'); 129 // } 130 // }); 131} 132 133/** 134 * ã¹ã ã¼ã¹ã¹ã¯ãã¼ã«ã®å¶å¾¡ 135 */ 136function initSmoothScroll() { 137 // ã¹ã ã¼ã¹ã¹ã¯ãã¼ã«ã®å®è£ 138} 139 140/** 141 * ãããã«æ»ããã¿ã³ã®å¶å¾¡ 142 */ 143function initToTopButton() { 144 const toTopButton = document.querySelector('.c-to-top'); 145 146 if (toTopButton) { 147 toTopButton.addEventListener('click', function(e) { 148 e.preventDefault(); 149 150 // æä¸é¨ã«ã¹ã ã¼ã¹ã¹ã¯ãã¼ã« 151 window.scrollTo({ 152 top: 0, 153 behavior: 'smooth' 154 }); 155 }); 156 } 157} 158 159/** 160 * ã«ã¹ã¿ã ã«ã¼ã½ã«ã®å¶å¾¡ - ã³ã³ãã¼ãã³ããã¼ã¹ 161 */ 162function initCustomCursor() { 163 const cursor = document.querySelector('.c-cursor'); 164 165 if (!cursor) return; 166 167 let mouseX = 0; 168 let mouseY = 0;
169 let currentState = '-default'; 170 171 // ã³ã³ãã¼ãã³ãå¥ã®ç¶æ å®ç¾©ï¼åªå é ä½é ï¼ 172 const cursorStates = [ 173 { selector: '.p-mainvisual', state: '-arrow-down' }, 174 { selector: '.p-sec01__link', state: '-hover' }, 175 { selector: '.p-sec02__item', state: '-plus' }, 176 { selector: '.c-case__item a', state: '-plus' }, 177 { selector: '.c-blog__item a', state: '-arrow-right' }, 178 { selector: '.c-information__item a', state: '-hover' }, 179 { selector: '.l-section__view-all', state: '-hover' }, 180 { selector: '.c-cta a', state: '-banner' }, 181 { selector: '.p-banner-about__link', state: '-banner' }, 182 { selector: '.c-hamburger', state: '-hover' } 183 ]; 184 185 // ãã®ä»ã®aã¿ã°ãbuttonã¿ã°ã®ããã©ã«ã 186 const defaultInteractiveState = '-hover'; 187 188 // ãã¦ã¹åº§æ¨ã追跡 189 document.addEventListener('mousemove', function(e) { 190 mouseX = e.clientX; 191 mouseY = e.clientY; 192 }); 193 194 // requestAnimationFrameã使ç¨ãã¦ã¹ã ã¼ãºãªè¿½å¾ 195 function updateCursor() { 196 cursor.style.transform = `translate3d(${mouseX - 0.5}px, ${mouseY - 0.5}px, 0px)`; 197 requestAnimationFrame(updateCursor); 198 } 199 200 // ã¢ãã¡ã¼ã·ã§ã³ã«ã¼ãéå§ 201 updateCursor(); 202 203 // åæç¶æ ãè¨å® 204 setCursorState('-default'); 205 206 // ç¶æ 夿´é¢æ° 207 function setCursorState(newState) { 208 if (currentState === newState) return; 209 210 // ç¶æ ã¯ã©ã¹ã®ãªã¹ã 211 const stateClasses = ['-default', '-hover', '-arrow-down', '-arrow-right', '-plus', '-banner', '-countdown', '-none']; 212 213 // æ¢åã®ç¶æ ã¯ã©ã¹ãåé¤ 214 stateClasses.forEach(stateClass => { 215 cursor.classList.remove(stateClass); 216 }); 217 218 // æ°ããç¶æ ã¯ã©ã¹ã追å 219 cursor.classList.add(newState); 220 currentState = newState; 221 } 222 223 // è¦ç´ ã®ç¶æ ãåå¾ï¼åªå é ä½ã«å¾ã£ã¦ãã§ãã¯ï¼ 224 function getElementState(element) { 225 // å®ç¾©ãããè¦ç´ ãåªå é ä½é ã«ãã§ã㯠226 for (let config of cursorStates) { 227 if (element.matches(config.selector) || element.closest(config.selector)) { 228 return config.state; 229 } 230 } 231 232 // ã¤ã³ã¿ã©ã¯ãã£ãè¦ç´ ï¼a, buttonï¼ã®å ´åã¯ããã©ã«ãç¶æ ãè¿ã 233 if (element.matches('a, button') || element.closest('a, button')) { 234 return defaultInteractiveState; 235 } 236 237 // ãã以å¤ã¯éå¸¸ç¶æ 238 return '-default'; 239 } 240 241 // ãã¦ã¹ããã¼ã¸ãé¢ããæã¯é表示 242 document.addEventListener('mouseleave', function() { 243 cursor.classList.add('is-hidden'); 244 }); 245 246 // ãã¦ã¹ããã¼ã¸ã«å ¥ã£ãæã¯è¡¨ç¤º 247 document.addEventListener('mouseenter', function() { 248 cursor.classList.remove('is-hidden'); 249 }); 250 251 // cursorStatesããåçã«ã»ã¬ã¯ã¿ãçæ 252 const customSelectors = cursorStates.map(state => state.selector).join(', '); 253 const allElements = document.querySelectorAll(`a, button, ${customSelectors}`); 254 255 allElements.forEach(element => { 256 element.addEventListener('mouseenter', function() { 257 const state = getElementState(element); 258 setCursorState(state); 259 }); 260 261 element.addEventListener('mouseleave', function() { 262 setCursorState('-default'); 263 }); 264 }); 265} 266 267/** 268 * ã¹ã©ã¤ãã·ã§ã¼ã®å¶å¾¡ 269 */ 270function initSlideshow() { 271 const slides = document.querySelectorAll('.p-sec02__slideshow-img'); 272 const indicator = document.querySelector('.p-sec02__slider-indicator'); 273 274 if (!slides.length || !indicator) return; 275 276 let currentSlide = 0; 277 const totalSlides = slides.length; 278 279 // ã¹ã©ã¤ããåãæ¿ãã颿° 280 function changeSlide() { 281 // ç¾å¨ã®ã¢ã¯ãã£ããªã¹ã©ã¤ããéã¢ã¯ãã£ãã«ãã 282 slides[currentSlide].classList.remove('active'); 283 284 // 次ã®ã¹ã©ã¤ãã®ã¤ã³ããã¯ã¹ãè¨ç® 285 currentSlide = (currentSlide + 1) % totalSlides; 286 287 // æ°ããã¹ã©ã¤ããã¢ã¯ãã£ãã«ãã 288 slides[currentSlide].classList.add('active'); 289 } 290 291 // ããã°ã¬ã¹ãã¼ãéå§ï¼CSSã¢ãã¡ã¼ã·ã§ã³ã§èªåã«ã¼ãï¼ 292 indicator.classList.add('active'); 293 294 // 3ç§ééã§ã¹ã©ã¤ããåãæ¿ã 295 setInterval(changeSlide, 3000); 296} 297 298/**
299 * ãã§ã¼ãã¤ã³ã¢ãã¡ã¼ã·ã§ã³ã®å¶å¾¡ 300 */ 301function initFadeInAnimation() { 302 // p-sec01__contenté ä¸ã®è¦ç´ ãåå¾ 303 const fadeElements = document.querySelectorAll('.p-sec01__title, .p-sec01__text1, .p-sec01__text2, .p-sec01__link'); 304 305 if (!fadeElements.length) return; 306 307 // åè¦ç´ ã«å ±éã®ãã§ã¼ãã¤ã³ã¯ã©ã¹ã追å 308 fadeElements.forEach(element => { 309 element.classList.add('fade-in-element'); 310 }); 311 312 // Intersection Observerã®è¨å® 313 const observerOptions = { 314 root: null, 315 rootMargin: '0px', 316 threshold: 0.1 317 }; 318 319 const observer = new IntersectionObserver((entries) => { 320 entries.forEach((entry) => { 321 if (entry.isIntersecting) { 322 // è¦ç´ ãç»é¢å ã«å ¥ã£ãæãé çªã«ã¢ãã¡ã¼ã·ã§ã³ãéå§ 323 const targetElement = entry.target; 324 const elementIndex = Array.from(fadeElements).indexOf(targetElement); 325 326 // è¦ç´ ãã¨ã«æéå·®ã§ã¢ãã¡ã¼ã·ã§ã³ï¼0.2ç§ãã¤é å»¶ï¼ 327 setTimeout(() => { 328 targetElement.classList.add('fade-in-up'); 329 }, elementIndex * 200); 330 331 // ä¸åº¦ã¢ãã¡ã¼ã·ã§ã³ãããç£è¦ã忢 332 observer.unobserve(targetElement); 333 } 334 }); 335 }, observerOptions); 336 337 // åè¦ç´ ãç£è¦éå§ 338 fadeElements.forEach(element => { 339 observer.observe(element); 340 }); 341} 342 343/** 344 * ã¡ã¤ã³ãã¸ã¥ã¢ã«ããã¹ãã¢ãã¡ã¼ã·ã§ã³ã®å¶å¾¡ 345 */ 346function initMainVisualTextAnimation() { 347 const titleEn = document.querySelector('.p-mainvisual__title-en'); 348 const titleJa = document.querySelector('.p-mainvisual__title-ja'); 349 350 if (!titleEn || !titleJa) return; 351 352 // ::beforeã®ã¢ãã¡ã¼ã·ã§ã³å®äºå¾ï¼2ç§å¾ï¼ã«ããã¹ãã¢ãã¡ã¼ã·ã§ã³ãéå§ 353 setTimeout(() => { 354 // è±èªã¿ã¤ãã«ãæåã«ã¢ãã¡ã¼ã·ã§ã³ 355 titleEn.classList.add('fade-in-slide'); 356 357 // æ¥æ¬èªã¿ã¤ãã«ã0.3ç§é ãã¦ã¢ãã¡ã¼ã·ã§ã³ 358 setTimeout(() => { 359 titleJa.classList.add('fade-in-slide'); 360 }, 300); 361 }, 1000); 362} 363 364/** 365 * æ±ç¨èªã¿è¾¼ã¿æ©è½ã®å¶å¾¡ 366 * @param {string} listSelector - æç¨¿ã追å ãããªã¹ãã®ã»ã¬ã¯ã¿ 367 */ 368function initLoadMore(listSelector) {
369 const loadMoreBtn = document.querySelector('.p-archive-more-btn'); 370 371 if (!loadMoreBtn) return; 372 373 loadMoreBtn.addEventListener('click', function() { 374 const btn = this; 375 const currentPage = parseInt(btn.dataset.currentPage); 376 const maxPages = parseInt(btn.dataset.maxPages); 377 const postType = btn.dataset.postType; 378 const nextPage = currentPage + 1; 379 380 // Ajax ã¢ã¯ã·ã§ã³ãæç¨¿ã¿ã¤ãã«å¿ãã¦æ±ºå® 381 let ajaxAction; 382 if (postType === 'case') { 383 ajaxAction = 'load_more_cases'; 384 } else if (postType === 'information') { 385 ajaxAction = 'load_more_information'; 386 } else { 387 ajaxAction = 'load_more_posts'; 388 } 389 390 // ãã¿ã³ã®ãã¼ãã£ã³ã°ç¶æ ã«å¤æ´ 391 setLoadingState(btn, true); 392 393 // Ajaxéä¿¡ 394 fetch(ajax_object.ajax_url, { 395 method: 'POST', 396 headers: { 397 'Content-Type': 'application/x-www-form-urlencoded', 398 }, 399 body: new URLSearchParams({ 400 action: ajaxAction, 401 page: nextPage, 402 post_type: postType, 403 nonce: ajax_object.nonce 404 }) 405 }) 406 .then(response => response.json()) 407 .then(data => { 408 console.log('Ajax response:', data); 409 410 if (data.success && data.data.html) { 411 // æ°ããæç¨¿ããªã¹ãã«è¿½å 412 const list = document.querySelector(listSelector); 413 if (list) { 414 list.insertAdjacentHTML('beforeend', data.data.html); 415 416 // æ°ãã追å ãããè¦ç´ ã«ã¢ãã¡ã¼ã·ã§ã³ãåæå 417 if (listSelector === '.c-case__list') { 418 // æ°ãã追å ãããã±ã¼ã¹ã¢ã¤ãã ã«ã¢ãã¡ã¼ã·ã§ã³ãé©ç¨ 419 initCaseItemAnimation(); 420 } 421 } 422 } else { 423 console.error('Error loading more posts:', data); 424 } 425 426 // ãã¿ã³ã®ç¶æ ãæ´æ° 427 btn.dataset.currentPage = nextPage; 428 429 // æå¾ã®ãã¼ã¸ã«éããããã¿ã³ãé表示 430 if (nextPage >= maxPages) { 431 btn.style.display = 'none'; 432 } 433 }) 434 .catch(error => { 435 console.error('Error:', error); 436 }) 437 .finally(() => { 438 // ãã¼ãã£ã³ã°ç¶æ ãè§£é¤ 439 setLoadingState(btn, false); 440 }); 441 }); 442} 443 444/** 445 * Aboutãã¼ã¸ã®ãã´éæåº¦å¶å¾¡ 446 */ 447function initAboutLogoAnimation() { 448 const logo = document.querySelector('.p-about-mainvisual__logo'); 449 const mainvisualImg = document.querySelector('.p-about-mainvisual__img'); 450 const messageImage = document.querySelector('.p-about-message__image1'); 451 const messageContent2 = document.querySelector('.p-about-message__content2'); 452 453 if (!logo && !mainvisualImg && !messageImage) return; 454 455 // ã¹ã¯ãã¼ã«ã¤ãã³ããªã¹ãã¼ 456 window.addEventListener('scroll', () => { 457 const scrollTop = window.pageYOffset || document.documentElement.scrollTop; 458 const windowHeight = window.innerHeight; 459 460 // ãã´ã®éæåº¦å¶å¾¡ 461 if (logo) { 462 // ç»é¢ã®é«ãã®ååãåºæºã«éæåº¦ãè¨ç® 463 const halfWindowHeight = windowHeight / 2; 464 465 // ã¹ã¯ãã¼ã«éã«åºã¥ãã¦éæåº¦ãè¨ç®ï¼0ã1ã®ç¯å²ï¼ 466 let logoOpacity = 1 - (scrollTop / halfWindowHeight); 467 468 // éæåº¦ã0ã1ã®ç¯å²ã«å¶é 469 logoOpacity = Math.max(0, Math.min(1, logoOpacity)); 470 471 // ãã´ã®éæåº¦ãè¨å® 472 logo.style.opacity = logoOpacity; 473 } 474 475 // ã¡ã¤ã³ãã¸ã¥ã¢ã«ç»åã®éæåº¦å¶å¾¡ 476 if (mainvisualImg) { 477 // 1ç»é¢ã®é«ãåãèµ·ç¹ã1.5ç»é¢åã®é«ããã´ã¼ã« 478 const startPoint = windowHeight; // 1ç»é¢å 479 const endPoint = windowHeight * 1.5; // 1.5ç»é¢å 480 481 // ã¹ã¯ãã¼ã«éã«åºã¥ãã¦éæåº¦ãè¨ç®ï¼0ã1ã®ç¯å²ï¼ 482 let imgOpacity = 1; 483 484 if (scrollTop >= startPoint && scrollTop <= endPoint) { 485 // 1ç»é¢åã1.5ç»é¢åã®éã§éæåº¦ãå¤å 486 const progress = (scrollTop - startPoint) / (endPoint - startPoint); 487 imgOpacity = 1 - progress; 488 } else if (scrollTop > endPoint) { 489 // 1.5ç»é¢åãè¶ ãããå®å ¨éæ 490 imgOpacity = 0; 491 } else { 492 // 1ç»é¢åæªæºã¯å®å ¨è¡¨ç¤º 493 imgOpacity = 1; 494 } 495 496 // éæåº¦ã0ã1ã®ç¯å²ã«å¶é 497 imgOpacity = Math.max(0, Math.min(1, imgOpacity)); 498 499 // ã¡ã¤ã³ãã¸ã¥ã¢ã«ç»åã®éæåº¦ãè¨å® 500 mainvisualImg.style.opacity = imgOpacity; 501 } 502 503 // ã¡ãã»ã¼ã¸ç»åã®ã¢ãã¡ã¼ã·ã§ã³å¶å¾¡ 504 if (messageImage && messageContent2) { 505 const content2Rect = messageContent2.getBoundingClientRect(); 506 const content2Top = content2Rect.top; 507 const content2Bottom = content2Rect.bottom; 508 const windowHeight = window.innerHeight; 509 const upperThird = windowHeight / 3; // ç»é¢ã®ä¸1/3ã®ä½ç½® 510 511 // p-about-message__content2ãç»é¢ã®ä¸1/3ãééãã¦ããéã®ã¿p-about-message__image1ã表示 512 // content2ã®ä¸ç«¯ãç»é¢ã®ä¸1/3ã«å°éããããã§ã¼ãã¤ã
512³ 513 if (content2Top <= upperThird) { 514 messageImage.classList.add('visible'); 515 } 516 517 // content2ã®ä¸ç«¯ãç»é¢ã®ä¸1/3ã«å°éããããã§ã¼ãã¢ã¦ã 518 if (content2Bottom <= upperThird) { 519 messageImage.classList.remove('visible'); 520 } 521 } 522 523 // ãã§ã¼ãã¤ã³ç»åã®è¡¨ç¤ºå¶å¾¡ï¼ä¸å¤®1/3ã¨ãªã¢ï¼ 524 const fadeInImagesCenter = document.querySelectorAll('.fade-in-image'); 525 fadeInImagesCenter.forEach(image => { 526 const imageRect = image.getBoundingClientRect(); 527 const imageTop = imageRect.top; 528 const imageBottom = imageRect.bottom; 529 const windowHeight = window.innerHeight; 530 const centerStart = windowHeight / 3; // ç»é¢ã®ä¸å¤®1/3ã®éå§ä½ç½® 531 const centerEnd = windowHeight * 2 / 3; // ç»é¢ã®ä¸å¤®1/3ã®çµäºä½ç½® 532 533 // ç»åãç»é¢ã®ä¸å¤®1/3ã«å ¥ã£ã¦ããéã®ã¿è¡¨ç¤º 534 if (imageBottom > centerStart && imageTop < centerEnd) { 535 image.classList.add('visible'); 536 } else { 537 image.classList.remove('visible'); 538 } 539 }); 540 541 // p-about-produce__itemã®Y軸ã¢ãã¡ã¼ã·ã§ã³å¶å¾¡ 542 const produceList = document.querySelector('.p-about-produce__list'); 543 if (produceList) { 544 const listRect = produceList.getBoundingClientRect(); 545 const listTop = listRect.top; 546 const listBottom = listRect.bottom; 547 const windowHeight = window.innerHeight; 548 549 // ãªã¹ããç»é¢å ã«å ¥ã£ã¦ããéã®ã¿ã¢ãã¡ã¼ã·ã§ã³ 550 if (listBottom > 0 && listTop < windowHeight) { 551 // ç»é¢å ã§ã®é²è¡åº¦ãè¨ç®ï¼0ã1ï¼ 552 const progress = Math.max(0, Math.min(1, (windowHeight - listTop) / (windowHeight + listRect.height))); 553 554 // åã¢ã¤ãã ã®Y軸移åéãè¨ç® 555 const items = produceList.querySelectorAll('.p-about-produce__item'); 556 items.forEach((item, index) => { 557 const initialOffset = index * 40; // åæãªãã»ããï¼0px, 20px, 40pxï¼ 558 const finalOffset = -index * 40; // æçµãªãã»ããï¼0px, -20px, -40pxï¼ 559 const currentOffset = initialOffset + (finalOffset - initialOffset) * progress; 560 561 item.style.transform = `translateY(${currentOffset}px)`; 562 }); 563 } 564 } 565 566 // ãã§ã¼ãã¤ã³ç»åã®å¶å¾¡ 567 const fadeInImages = document.querySelectorAll('.fade-in-image'); 568 fadeInImages.forEach(image => { 569 const imageRect = image.getBoundingClientRect(); 570 const imageTop = imageRect.top; 571 const imageBottom = imageRect.bottom; 572 const windowHeight = window.innerHeight; 573 const centerPosition = windowHeight / 2; // ç»é¢ã®ä¸å¤®ä½ç½® 574 575 // ç»åãç»é¢ã®ä¸å¤®ã«æ¥ãããã§ã¼ãã¤ã³ï¼ä¸åº¦ã ãï¼ 576 if (imageTop <= centerPosition && imageBottom >= centerPosition && !image.classList.contains('visible')) { 577 image.classList.add('visible'); 578 } 579 }); 580 581 582 583 584 585 // ã¹ã©ã¤ãã¤ã³è¦ç´ ã®ã¢ãã¡ã¼ã·ã§ã³å¶å¾¡ 586 const slideInElements = document.querySelectorAll('.slide-in-element'); 587 slideInElements.forEach(element => { 588 const elementRect = element.getBoundingClientRect(); 589 const elementTop = elementRect.top; 590 const elementBottom = elementRect.bottom; 591 const windowHeight = window.innerHeight; 592 const centerPosition = windowHeight / 2; // ç»é¢ã®ä¸å¤®ä½ç½® 593 594 // è¦ç´ ãç»é¢ã®ä¸å¤®ã«æ¥ããã¹ã©ã¤ãã¤ã³ï¼ä¸åº¦ã ãï¼ 595 if (elementTop <= centerPosition && elementBottom >= centerPosition && !element.classList.contains('slide-in-left')) { 596 element.classList.add('slide-in-left'); 597 } 598 }); 599 600 601 }); 602} 603 604/** 605 * ãã¿ã³ã®ãã¼ãã£ã³ã°ç¶æ ãå¶å¾¡ï¼çµ±åçï¼ 606 */ 607function setLoadingState(btn, isLoading) { 608 const textSpan = btn.querySelector('.p-archive-more-text'); 609 const loadingSpan = btn.querySelector('.p-archive-more-loading'); 610 611 if (isLoading) { 612 btn.disabled = true; 613 textSpan.style.display = 'none'; 614 loadingSpan.style.display = 'inline'; 615 } else { 616 btn.disabled = false;
617 textSpan.style.display = 'inline'; 618 loadingSpan.style.display = 'none'; 619 } 620} 621 622/** 623 * ã¿ã¤ãã«ããã¹ãã¢ãã¡ã¼ã·ã§ã³ã®å¶å¾¡ 624 */ 625function initTitleAnimation() { 626 const titleElements = document.querySelectorAll('.l-section__title'); 627 628 if (!titleElements.length) return; 629 630 // åã¿ã¤ãã«è¦ç´ ã®ããã¹ãã1æåãã¤spanè¦ç´ ã«åå² 631 titleElements.forEach(titleElement => { 632 const text = titleElement.textContent; 633 titleElement.innerHTML = ''; 634 635 // åæåãspanè¦ç´ ã§å²ã 636 Array.from(text).forEach((char, index) => { 637 const span = document.createElement('span'); 638 span.textContent = char === ' ' ? '\u00A0' : char; // ã¹ãã¼ã¹ã¯ ã«å¤æ 639 span.classList.add('title-char'); 640 span.style.display = 'inline-block'; 641 span.style.opacity = '0'; 642 span.style.transform = 'translateX(10px)'; 643 span.style.transition = 'opacity 1.2s ease, transform 1.2s ease'; 644 // å·¦ããé çªã«ã¢ãã¡ã¼ã·ã§ã³ 645 span.style.transitionDelay = `${index * 0.2}s`; 646 titleElement.appendChild(span); 647 }); 648 649 // ã¢ãã¡ã¼ã·ã§ã³ã¯ã©ã¹ã追å ï¼ããã«ããCSSã§è¡¨ç¤ºç¶æ ã«ãªãï¼ 650 titleElement.classList.add('title-animation-ready'); 651 }); 652 653 // Intersection Observerã®è¨å® 654 const observerOptions = { 655 root: null, 656 rootMargin: '0px', 657 threshold: 0.3 658 }; 659 660 const observer = new IntersectionObserver((entries) => { 661 entries.forEach((entry) => { 662 if (entry.isIntersecting) { 663 const titleElement = entry.target; 664 const chars = titleElement.querySelectorAll('.title-char'); 665 666 // åæåãé çªã«å³ããå·¦ã«ã¹ã©ã¤ãã¤ã³ããªãããã§ã¼ãã¤ã³ 667 chars.forEach(char => { 668 char.style.opacity = '1'; 669 char.style.transform = 'translateX(0)'; 670 }); 671 672 // ä¸åº¦ã¢ãã¡ã¼ã·ã§ã³ãããç£è¦ã忢 673 observer.unobserve(titleElement); 674 } 675 }); 676 }, observerOptions); 677 678 // åã¿ã¤ãã«è¦ç´ ãç£è¦éå§ 679 titleElements.forEach(titleElement => { 680 observer.observe(titleElement); 681 }); 682} 683 684/** 685 * p-case-detail__subimage-containerã®é«ããåçã«è¨ç®ãã颿° 686 */ 687function calculateSubimageContainerHeight() { 688 const containers = document.querySelectorAll('.p-case-detail__subimage-container'); 689 console.log(`Found ${containers.length} subimage containers`); 690 691 containers.forEach((container, index) => { 692 const imgElement = container.querySelector('img'); 693 if (imgElement) { 694 // HTMLã®width屿§ã¨height屿§ã®å¤ãåå¾ 695 const widthAttr = imgElement.getAttribute('width'); 696 const heightAttr = imgElement.getAttribute('height'); 697 698 // ç»åã®èªç¶ãªãµã¤ãºãåå¾ 699 const naturalWidth = imgElement.naturalWidth; 700 const naturalHeight = imgElement.naturalHeight; 701 702 console.log(`Container ${index}:`, { 703 widthAttr, 704 heightAttr, 705 naturalWidth, 706 naturalHeight, 707 imgComplete: imgElement.complete, 708 containerWidth: container.offsetWidth 709 }); 710 711 let aspectRatio; 712 713 // HTML屿§ãåå¨ããå ´åã¯ããã使ç¨ããªããã°èªç¶ãªãµã¤ãºãä½¿ç¨ 714 if (widthAttr && heightAttr) { 715 aspectRatio = parseInt(heightAttr) / parseInt(widthAttr); 716 console.log(`Container ${index}: Using HTML attributes, aspectRatio = ${aspectRatio}`); 717 }
717 else if (naturalWidth && naturalHeight) { 718 aspectRatio = naturalHeight / naturalWidth; 719 console.log(`Container ${index}: Using natural dimensions, aspectRatio = ${aspectRatio}`); 720 } else { 721 console.log(`Container ${index}: No valid dimensions found`); 722 } 723 724 if (aspectRatio) { 725 // ã³ã³ããã®ç¾å¨ã®å¹ ãåå¾ 726 let containerWidth = container.offsetWidth; 727 728 // å¹ ã0ã®å ´åã¯ã親è¦ç´ ã®å¹ ãåå¾ããããããã©ã«ãå¤ãä½¿ç¨ 729 if (containerWidth === 0) { 730 const parentContainer = container.closest('.p-case-detail__subimage'); 731 if (parentContainer) { 732 containerWidth = parentContainer.offsetWidth; 733 } 734 735 // ããã§ã0ã®å ´åã¯ãç»é¢å¹ ã®80%ãããã©ã«ãã¨ãã¦ä½¿ç¨ 736 if (containerWidth === 0) { 737 containerWidth = window.innerWidth * 0.8; 738 console.log(`Container ${index}: Using default width: ${containerWidth}`); 739 } 740 } 741 742 let calculatedHeight; 743 744 calculatedHeight = containerWidth * aspectRatio; 745 console.log(`Container ${index}: containerWidth = ${containerWidth}, calculatedHeight = ${calculatedHeight}`); 746 747 // ã³ã³ããã®é«ããè¨å® 748 container.style.height = `${calculatedHeight}px`; 749 } else { 750 console.log(`Container ${index}: No aspect ratio calculated, trying fallback...`); 751 752 // ãã©ã¼ã«ããã¯: ããã©ã«ãã®ã¢ã¹ãã¯ãæ¯ï¼16:9ï¼ãä½¿ç¨ 753 let containerWidth = container.offsetWidth; 754 if (containerWidth === 0) { 755 const parentContainer = container.closest('.p-case-detail__subimage'); 756 if (parentContainer) { 757 containerWidth = parentContainer.offsetWidth; 758 } 759 if (containerWidth === 0) { 760 containerWidth = window.innerWidth * 0.8; 761 } 762 } 763 764 if (containerWidth > 0) { 765 const fallbackAspectRatio = 9 / 16; // 16:9ã®éæ° 766 const fallbackHeight = containerWidth * fallbackAspectRatio; 767 console.log(`Container ${index}: Using fallback aspect ratio, height = ${fallbackHeight}`); 768 container.style.height = `${fallbackHeight}px`; 769 } else { 770 console.log(`Container ${index}: Container width is 0, cannot calculate height`); 771 } 772 } 773 } else { 774 console.log(`Container ${index}: No img element found`); 775 } 776 }); 777} 778 779/** 780 * ã¹ã¯ãã¼ã«ã«åããã¦å é¨ã®imgãä¸ä¸ã«åããæ±ç¨é¢æ° 781 */ 782function animateImageParallax(containerSelector, minOffset = -15, maxOffset = 15) { 783 const containers = document.querySelectorAll(containerSelector); 784 785 // ã»ã¬ã¯ã¿ãè¦ã¤ãããªãå ´åã¯çµäº 786 if (containers.length === 0) { 787 return; 788 } 789 790 791 792 containers.forEach(container => { 793 const containerRect = container.getBoundingClientRect(); 794 const containerTop = containerRect.top; 795 const containerBottom = containerRect.bottom; 796 const windowHeight = window.innerHeight; 797 798 // ã³ã³ãããç»é¢å ã«ããéã®ã¿ã¢ãã¡ã¼ã·ã§ã³ 799 if (containerBottom > 0 && containerTop < windowHeight) { 800 const imgElement = container.querySelector('img'); 801 if (imgElement) { 802 // è¤åã¢ãã¡ã¼ã·ã§ã³ãå®äºãã¦ããããã§ãã¯ï¼è©²å½è¦ç´ ã®ã¿ï¼ 803 const isAnimationCompleted = container.dataset.animationCompleted === 'true'; 804 const shouldApplyParallax = container.dataset.animationCompleted !== undefined ? isAnimationCompleted : true; 805 806 // ç»é¢å ã§ã®é²è¡åº¦ãè¨ç®ï¼0ã1ï¼ 807 const progress = Math.max(0, Math.min(1, (windowHeight - containerTop
807) / (windowHeight + containerRect.height))); 808 809 // æå®ãããç¯å²ã§Y軸移åéãè¨ç®ï¼å°æ°ç¹ä»¥ä¸2æ¡ã¾ã§ï¼ 810 const currentOffset = Math.round((minOffset + (maxOffset - minOffset) * progress) * 100) / 100; 811 812 // æ¢åã®translateå¤ãä¿æãã¤ã¤ãY軸ã®ã¿æ´æ° 813 const currentTranslate = imgElement.style.transform || ''; 814 const translateMatch = currentTranslate.match(/translate\(([^)]+)\)/); 815 816 if (translateMatch) { 817 // æ¢åã®translateå¤ãããå ´åãX軸ã®å¤ãä¿æãã¦Y軸ã®ã¿æ´æ° 818 const translateValues = translateMatch[1].split(','); 819 const xValue = translateValues[0].trim(); 820 821 // æ¡ä»¶ã«å¿ãã¦ãã©ã©ãã¯ã¹ãé©ç¨ 822 if (shouldApplyParallax) { 823 imgElement.style.transform = `translate(${xValue}, ${currentOffset}px)`; 824 } 825 } else { 826 // æ¢åã®translateå¤ããªãå ´åãY軸ã®ã¿è¨å® 827 if (shouldApplyParallax) { 828 imgElement.style.transform = `translate(0, ${currentOffset}px)`; 829 } 830 } 831 } 832 } 833 }); 834} 835 836/** 837 * p-case-detail__subimage-containerã®é«ãè¨ç®åæå 838 */ 839function initSubimageContainerHeight() { 840 console.log('Initializing subimage container height calculation...'); 841 842 // åæè¨ç®ï¼è¡¨ç¤ºããã¦ããè¦ç´ ã®ã¿ï¼ 843 calculateSubimageContainerHeight(); 844 845 // Intersection Observerã使ç¨ãã¦è¦ç´ ãç»é¢ã«å ¥ã£ãæã«é«ããè¨ç® 846 const containers = document.querySelectorAll('.p-case-detail__subimage-container'); 847 848 const observer = new IntersectionObserver((entries) => { 849 entries.forEach((entry) => { 850 if (entry.isIntersecting) { 851 const container = entry.target; 852 const index = Array.from(containers).indexOf(container); 853 console.log(`Container ${index} entered viewport, calculating height...`); 854 855 // è¦ç´ ãç»é¢ã«å ¥ã£ãæã«é«ããè¨ç® 856 calculateContainerHeight(container, index); 857 858 // ä¸åº¦è¨ç®ãããç£è¦ã忢 859 observer.unobserve(container); 860 } 861 }); 862 }, { 863 rootMargin: '50px' // 50pxæåããç£è¦éå§ 864 }); 865 866 // åã³ã³ãããç£è¦éå§ 867 containers.forEach(container => { 868 observer.observe(container); 869 }); 870 871 // ã¦ã£ã³ãã¦ãªãµã¤ãºæã«åè¨ç® 872 window.addEventListener('resize', function() { 873 calculateSubimageContainerHeight(); 874 }); 875} 876 877/** 878 * åå¥ã®ã³ã³ããã®é«ããè¨ç®ãã颿° 879 */ 880function calculateContainerHeight(container, index) { 881 const imgElement = container.querySelector('img'); 882 if (imgElement) { 883 // HTMLã®width屿§ã¨height屿§ã®å¤ãåå¾ 884 const widthAttr = imgElement.getAttribute('width'); 885 const heightAttr = imgElement.getAttribute('height'); 886 887 // ç»åã®èªç¶ãªãµã¤ãºãåå¾ 888 const naturalWidth = imgElement.naturalWidth; 889 const naturalHeight = imgElement.naturalHeight; 890 891 console.log(`Container ${index}:`, { 892 widthAttr, 893 heightAttr, 894 naturalWidth, 895 naturalHeight, 896 imgComplete: imgElement.complete, 897 containerWidth: container.offsetWidth 898 }); 899 900 let aspectRatio; 901 902 // HTML屿§ãåå¨ããå ´åã¯ããã使ç¨ããªããã°èªç¶ãªãµã¤ãºãä½¿ç¨ 903 if (widthAttr && heightAttr) { 904 aspectRatio = parseInt(heightAttr) / parseInt(widthAttr); 905 console.log(`Container ${index}: Using HTML attributes, aspectRatio = ${aspectRatio}`); 906 }
906 else if (naturalWidth && naturalHeight) { 907 aspectRatio = naturalHeight / naturalWidth; 908 console.log(`Container ${index}: Using natural dimensions, aspectRatio = ${aspectRatio}`); 909 } else { 910 console.log(`Container ${index}: No valid dimensions found`); 911 } 912 913 if (aspectRatio) { 914 // ã³ã³ããã®ç¾å¨ã®å¹ ãåå¾ 915 let containerWidth = container.offsetWidth; 916 917 // å¹ ã0ã®å ´åã¯ã親è¦ç´ ã®å¹ ãåå¾ããããããã©ã«ãå¤ãä½¿ç¨ 918 if (containerWidth === 0) { 919 const parentContainer = container.closest('.p-case-detail__subimage'); 920 if (parentContainer) { 921 containerWidth = parentContainer.offsetWidth; 922 } 923 924 // ããã§ã0ã®å ´åã¯ãç»é¢å¹ ã®80%ãããã©ã«ãã¨ãã¦ä½¿ç¨ 925 if (containerWidth === 0) { 926 containerWidth = window.innerWidth * 0.8; 927 console.log(`Container ${index}: Using default width: ${containerWidth}`); 928 } 929 } 930 931 let calculatedHeight; 932
933 // ã¢ã¹ãã¯ãæ¯ã«åºã¥ãã¦é«ããè¨ç® 934 if (aspectRatio > 1) { 935 // 縦é·ã®ç»åã®å ´åï¼ã³ã³ããå¹ ãé«ãã¨ãã¦ä½¿ç¨ 936 calculatedHeight = containerWidth; 937 console.log(`Container ${index}: Vertical image, using container width as height: ${calculatedHeight}`); 938 } else { 939 // 横é·ã®ç»åã®å ´åï¼ã¢ã¹ãã¯ãæ¯ã«åºã¥ãã¦é«ããè¨ç® 940 calculatedHeight = containerWidth * aspectRatio; 941 console.log(`Container ${index}: Horizontal image, calculated height: ${calculatedHeight}`); 942 } 943 944 console.log(`Container ${index}: containerWidth = ${containerWidth}, calculatedHeight = ${calculatedHeight}`); 945 946 // ã³ã³ããã®é«ããè¨å® 947 container.style.height = `${calculatedHeight}px`; 948 } else { 949 console.log(`Container ${index}: No aspect ratio calculated, trying fallback...`); 950 951 // ãã©ã¼ã«ããã¯: ããã©ã«ãã®ã¢ã¹ãã¯ãæ¯ï¼16:9ï¼ãä½¿ç¨ 952 let containerWidth = container.offsetWidth; 953 if (containerWidth === 0) { 954 const parentContainer = container.closest('.p-case-detail__subimage'); 955 if (parentContainer) { 956 containerWidth = parentContainer.offsetWidth; 957 } 958 if (containerWidth === 0) { 959 containerWidth = window.innerWidth * 0.8; 960 } 961 } 962 963 if (containerWidth > 0) { 964 const fallbackAspectRatio = 9 / 16; // 16:9ã®éæ° 965 const fallbackHeight = containerWidth * fallbackAspectRatio; 966 console.log(`Container ${index}: Using fallback aspect ratio, height = ${fallbackHeight}`); 967 container.style.height = `${fallbackHeight}px`; 968 } else { 969 console.log(`Container ${index}: Container width is 0, cannot calculate height`); 970 } 971 } 972 } else { 973 console.log(`Container ${index}: No img element found`); 974 } 975} 976 977/** 978 * è¤åã¢ãã¡ã¼ã·ã§ã³ã®åæå 979 */ 980function initComplexImageAnimation() { 981 const animatedImages = document.querySelectorAll('.complex-animation-element'); 982 983 if (!animatedImages.length) return; 984 985 // åç»åã«åæç¶æ ãè¨å® 986 animatedImages.forEach(image => { 987 const imgElement = image.querySelector('img'); 988 if (imgElement) { 989 // ã¢ãã¡ã¼ã·ã§ã³å®äºãã©ã°ãåæå 990 image.dataset.animationCompleted = 'false'; 991 } 992 }); 993 994 // Intersection Observerã§ã¢ãã¡ã¼ã·ã§ã³éå§ãç£è¦ 995 const observer = new IntersectionObserver((entries) => { 996 entries.forEach((entry) => { 997 if (entry.isIntersecting) { 998 const image = entry.target; 999 const imgElement = image.querySelector('img'); 1000 1001 if (imgElement && !image.classList.contains('animation-started')) { 1002 image.classList.add('animation-started'); 1003 1004 // CSS transitionã§ã¢ãã¡ã¼ã·ã§ã³éå§ 1005 image.classList.add('animate'); 1006 1007 // ã¢ãã¡ã¼ã·ã§ã³å®äºå¾ã«ãã©ã°ãè¨å® 1008 setTimeout(() => { 1009 image.dataset.animationCompleted = 'true'; 1010 }, 2000); // 2ç§å¾ã«å®äº 1011 } 1012 } 1013 }); 1014 }, { 1015 threshold: 0.5, 1016 rootMargin: '0px' 1017 }); 1018 1019 // åç»åãç£è¦éå§ 1020 animatedImages.forEach(image => { 1021 observer.observe(image); 1022 }); 1023} 1024 1025 1026 1027/** 1028 * ãã©ã©ãã¯ã¹ã¢ãã¡ã¼ã·ã§ã³ã®åæå 1029 */ 1030function initParallaxAnimation() { 1031 let ticking = false; 1032 1033 // ãã©ã©ãã¯ã¹ã¢ãã¡ã¼ã·ã§ã³ãå®è¡ãã颿° 1034 function updateParallax() { 1035 // æ±ç¨ãã©ã©ãã¯ã¹ã¢ãã¡ã¼ã·ã§ã³ 1036 animateImageParallax('.parallax-container', -60, 60); 1037 1038 // ãã®ä»ã®ãã¼ã¸ã®ãã©ã©ãã¯ã¹ã¢ãã¡ã¼ã·ã§ã³ 1039 animateImageParallax('.c-case__item-img', -60, 60); 1040 1041 ticking = false;
1042 } 1043 1044 // ã¹ã¯ãã¼ã«ã¤ãã³ããªã¹ãã¼ 1045 window.addEventListener('scroll', function() { 1046 if (!ticking) { 1047 requestAnimationFrame(updateParallax); 1048 ticking = true; 1049 } 1050 }); 1051} 1052 1053/** 1054 * ã±ã¼ã¹ã¢ã¤ãã ã¢ãã¡ã¼ã·ã§ã³ã®åæå 1055 */ 1056function initCaseItemAnimation() { 1057 const caseItems = document.querySelectorAll('.case-item-animation'); 1058 1059 if (!caseItems.length) return; 1060 1061 // Intersection Observerã§ã¢ãã¡ã¼ã·ã§ã³éå§ãç£è¦ 1062 const observer = new IntersectionObserver((entries) => { 1063 entries.forEach((entry) => { 1064 if (entry.isIntersecting) { 1065 const caseItem = entry.target; 1066 1067 if (!caseItem.classList.contains('animation-started')) { 1068 caseItem.classList.add('animation-started'); 1069 1070 // åè¦ç´ ã«ã¢ãã¡ã¼ã·ã§ã³ã¯ã©ã¹ã追å 1071 const img = caseItem.querySelector('.c-case__item-img'); 1072 const title = caseItem.querySelector('.c-case__item-title'); 1073 const text = caseItem.querySelector('.c-case__item-text'); 1074 1075 if (img) img.classList.add('animate'); 1076 if (title) title.classList.add('animate'); 1077 if (text) text.classList.add('animate'); 1078 } 1079 } 1080 }); 1081 }, { 1082 threshold: 0.3, 1083 rootMargin: '0px' 1084 }); 1085 1086 // åã±ã¼ã¹ã¢ã¤ãã ãç£è¦éå§ 1087 caseItems.forEach(item => { 1088 observer.observe(item); 1089 }); 1090}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.