$(function(){}); $(window).on("load", function () { //START OF calculatePosition(); function calculatePosition() { console.log('calculating...'); var containerWidth = 0; var longestTextWidth = 0; var totalTextHeight = 0; var logoHeight = 0; var textWidth = 0; var fontSize = 16; var textHeight = 0; // calculate the font size for the longest line of text containerWidth = $('.svg-wrapper').get(0).getBoundingClientRect().width; while (longestTextWidth < containerWidth) { fontSize++; $('.svg-text').each(function () { $(this).attr('font-size', fontSize + 'px'); var bbox = this.getBBox(); textWidth = bbox.width; if (textWidth > longestTextWidth) { longestTextWidth = textWidth; } }); //console.log(longestTextWidth, 'longestTextWidth', fontSize + 'px', containerWidth, 'containerWidth'); } fontSize = fontSize - 1; longestTextWidth = 0; $('.svg-text').each(function () { $(this).attr('font-size', fontSize + 'px'); var bbox = this.getBBox(); textWidth = bbox.width; if (textWidth > longestTextWidth) { longestTextWidth = textWidth; } }); //console.log(longestTextWidth, 'longestTextWidth2', fontSize + 'px2', containerWidth, 'containerWidth2'); logoHeight = fontSize; totalTextHeight = 0; $('.svg-text').each(function (index) { var bbox = this.getBBox(); textHeight = bbox.height * 1.2; $(this).attr('y', (index + 1) * fontSize * 1.2); //+logoHeight JESPER totalTextHeight += (textHeight * 1.2); }); // totalTextHeight += logoHeight; //with logo *3 jesper //console.log(totalTextHeight, "total text height", longestTextWidth, "longest text width"); // set the position and font size for all text elements $('.svg-text').each(function (index) { $(this).attr('font-size', fontSize + 'px'); $(this).attr('x', 0); }); // set the position and size of the logo image //$('.svg-img').attr('x', 0); //$('.svg-img').attr('y', 0); //$('.svg-img').attr('width', logoHeight); //$('.svg-img').attr('height', logoHeight); // set the viewBox and size for the SVG element $('.animsvg').attr('viewBox', '0 0 ' + longestTextWidth + ' ' + totalTextHeight); //$('.animsvg').attr('width', longestTextWidth); //$('.animsvg').attr('height', totalTextHeight); ScrollTrigger.refresh(); } //END OF calculatePosition(); var tl = gsap.timeline(); tl.set(".hero-anim", { visibility: "visible" }); tl.addLabel("letsgo"); /*tl.to(".hero-anim .logo", { duration: 1, opacity: 1, autoAlpha:1, y: 0, ease:"power1.out" },"letsgo");*/ tl.from(".svg-text", { duration: 1, opacity: 0, stagger: 0.66, y: 30, ease: "power1.out" }, "letsgo"); const colorArray = ['#34A853', '#FBBC05', '#EA4335', '#4285F4']; let curColor = 0; tl.to(".anim-color", { fill: function () { return gsap.utils.wrap(colorArray, curColor++); }, duration: 0.3, repeatDelay: 1, repeat: 100, repeatRefresh: true }); // scroll to on click $('#learnmore').on('click', function (event) { let offset = 100; window.setTimeout($('html, body').animate({ scrollTop: $('.home-hero').height() - offset }, 500), 500) }); console.log('windowload...'); calculatePosition(); $(window).resize(function () { if (this.resizeTO) clearTimeout(this.resizeTO); this.resizeTO = setTimeout(function () { $(this).trigger('resizeEnd'); }, 750); }); $(window).bind('resizeEnd', function () { calculatePosition(); }); }); /*******************************************************************/ /* ftrtch dino */ /* [type: JS] [file:home-hero] [115.12105] DESIGN*/ /*******************************************************************/ /* 0.2 D>D */ /* db 155 */