html
1 <nav class="menu js-menu-items-wrapper"> 2 <ol class="js-menu-items-list"> 3 <li class="menu-item js-menu-item is-active" data-morph="M 418.1,159.8 C 460.9,222.9 497,321.5 452.4,383.4 417.2,432.4 371.2,405.6 271.3,420.3 137.2,440 90.45,500.6 42.16,442.8 -9.572,381 86.33,289.1 117.7,215.5 144.3,153.4 145.7,54.21 212.7,36.25 290.3,15.36 373.9,94.6 418.1,159.8 Z"><a href="#0">Home</a></li> 4 <li class="menu-item js-menu-item" data-morph="M 402.7,215.5 C 433.9,280.4 488.1,367.2 447.7,426.8 410.1,482.2 316.7,460.2 249.7,460.6 182.8,461.1 88.08,485.5 51.26,429.5 10.29,367.3 73.19,279.4 106.9,213 141.8,144 176.6,33.65 253.9,33.7 332.2,33.75 368.8,144.9 402.7,215.5 Z"><a href="#0">about</a></li> 5 <li class="menu-item js-menu-item" data-morph="M 451.5,185.8 C 441.5,266.2 339.6,305 272.3,350.2 207.7,393.6 226.7,444.7 182.6,447.9 132.8,451.4 83.97,399.9 66.37,353.1 34.6,268.4 41.16,141.8 112,85.44 186.1,26.329999999999984 313.8,54.099999999999994 396,101.4 425.2,118.2 455.6,152.4 451.5,185.8 Z"> 6 <a href="#0">Widgets</a> 7 <ol class="sub-menu"> 8 <li class="menu-item"><a href="#0">Big Widgets</a></li> 9 <li class="menu-item"><a href="#0">Bigger Widgets</a></li> 10 <li class="menu-item"><a href="#0">Huge Widgets</a></li> 11 </ol> 12 </li> 13 <li class="menu-item js-menu-item" data-morph="M 378.1,121.2 C 408.4,150 417.2,197.9 411,245.8 404.8,293.7 383.5,341.7 353.4,370.7 303.2,419.1 198.7,427.7 144.5,383.8 86.18,336.5 67.13,221.3 111.9,161 138.6,125 188.9,99.62 240.7,90.92 292.4,82.24 345.6,90.32 378.1,121.2 Z"> 14 <a href="#0">Kabobs</a> 15 <ol class="sub-menu"> 16 <li class="menu-item"><a href="#0">Shishkabobs</a></li> 17 <li class="menu-item"><a href="#0">BBQ kabobs</a></li> 18 <li class="menu-item"><a href="#0">Summer kabobs</a></li> 19 </ol> 20 </li> 21 <li class="menu-item js-menu-item" data-morph="M 189,80.37 C 232.6,46.67 352.5,67.06 350.9,124.1 349.5,173.4 311.7,168 312.4,248.1 312.9,301.1 382.5,319.2 368.5,379.1 349.4,460.6 137.7,467.5 117.6,386.3 98.68,309.7 171.5,292.2 183.6,240.1 195.7,188.2 123.8,130.7 189,80.37 Z"><a href="#0">Contact</a></li> 22 </ol> 23 <div class="menu-shape js-shape"> 24 <svg id="circle" viewBox="0 0 500 500"> 25 <defs> 26 <linearGradient id="main-gradient" x1="0%" y1="0%" x2="100%" y2="0%"> 27 <stop offset="10%" style="stop-color:#6426CB;"/> 28 <stop offset="100%" style="stop-color:#F34EA4;"/> 29 </linearGradient> 30 </defs> 31 <path id="object" class="js-items-shape-path" fill="url(#main-gradient)" 32 d="M 418.1,159.8 C 460.9,222.9 497,321.5 452.4,383.4 417.2,432.4 371.2,405.6 271.3,420.3 137.2,440 90.45,500.6 42.16,442.8 -9.572,381 86.33,289.1 117.7,215.5 144.3,153.4 145.7,54.21 212.7,36.25 290.3,15.36 373.9,94.6 418.1,159.8 Z"></path> 33 </svg> 34 </div> 35</nav> 36 37<p class="info js-info">Please refresh your page...</p> 38 39<div class="link"> 40 <a href="https://codepen.io/microfront/pens/public/" target="_blank"> <span class="fa fa-codepen"></span>my other Pens</a> 41</div>
jQuery
1 function hoverAnimation() { 2 var menuItemsShape = $(".js-shape"), 3 linksWrapper = $(".js-menu-items-wrapper"), 4 linksItems = $(".js-menu-item"), 5 activeItem = $(".js-menu-item.is-active"), 6 activeItemPosition = activeItem.position().top, 7 menuItemsShapePath = $(".js-items-shape-path"), 8 info = $(".js-info"); 9 10 TweenMax.set(menuItemsShape, { 11 y: activeItemPosition 12 }); 13 14 linksItems.on({ 15 mouseenter: function() { 16 _self = $(this); 17 var selfParent = _self.closest(linksWrapper), 18 targetCircle = selfParent.find(menuItemsShape), 19 circlePosition; 20 21 if ($(window).width() < 800) { 22 circlePosition = _self.position().top; 23 TweenMax.to(targetCircle, 0.6, { 24 y: circlePosition, 25 ease: Power2.easeOut 26 }); 27 } else { 28 circlePosition = _self.position().left; 29 TweenMax.to(targetCircle, 0.6, { 30 x: circlePosition, 31 ease: Power2.easeOut 32 }); 33 } 34 35 TweenMax.to(menuItemsShapePath, 1, { morphSVG: this.dataset.morph }); 36 } 37 }); 38 39 linksWrapper.on({ 40 mouseleave: function() { 41 _self = $(this); 42 var selfParent = _self.closest(linksWrapper), 43 activeLink = selfParent.find(activeItem), 44 targetCircle = selfParent.find(menuItemsShape), 45 activeLinkPosition = activeLink.position().top; 46 47 if ($(window).width() < 800) { 48 TweenMax.to(targetCircle, 0.6, { 49 y: activeLinkPosition, 50 ease: Power2.easeOut 51 }); 52 } else { 53 TweenMax.to(targetCircle, 0.6, { 54 x: activeLinkPosition - 32, 55 ease: Power2.easeOut 56 }); 57 } 58 59 TweenMax.to(menuItemsShapePath, 1, { morphSVG: menuItemsShapePath }); 60 } 61 }); 62 63 $(window).resize(function() { 64 info.show(); 65 }); 66} 67 68hoverAnimation(); 69
エラー文
Uncaught ReferenceError: TweenMax is not defined nav.js:10
at hoverAnimation (nav.js:10)
at nav.js:68
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。