Jump to content
Search Community

saomartinho

Members
  • Posts

    4
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

saomartinho's Achievements

4

Reputation

  1. Hi guys, I am trying to reproduce this animation in a project - the goal is that during the ajax request to get the new page, the screen with the black background and the logo and only when the ajax request is finished is that the curtain disappears. I have already tried with .pause () and then use .resume () but it does not work very well in pause times, and there are times when resume is faster. I already tried to divide the timeline, in which one function has the beginning of the animation and in another the end, the first time turns out well, but the following ones do not and I can not quite understand why. any suggestion? here's the code. const entryTransitionPage = new TimelineMax( { paused: true }); entryTransitionPage .fromTo(transitionElementBlue , 1.2, { scaleX: 0 },{ scaleX: 1, transformOrigin:'left', ease: Power4.easeInOut},) .fromTo(transitionElementBlack , 1.2, {scaleX: 0},{scaleX: 1, transformOrigin:'left', ease: Power4.easeInOut}, .2) .fromTo(transitionContent , .6, {xPercent: -100, autoAlpha:0 }, {xPercent: 0, autoAlpha:1, ease: Power4.easeInOut}, .7) .set(transitionElementBlue, { scaleX:0 }) .to(transitionElementBlack , 2, { scaleX: 0, transformOrigin:'right', ease: Power4.easeInOut }) .to(transitionContent , .2, { autoAlpha:0 }, '-=1.2'); const entryPageAnimation = () => { entryTransitionPage.play(0); setTimeout(() => { entryTransitionPage.pause()}, 2000); } const endPageAnimation = () => { entryTransitionPage.resume(); } const changePage = (url) => { entryPageAnimation(); loadPage(url) } const loadPage = (url) => { const xhr = new XMLHttpRequest(); xhr.onerror = () => { throw 'Request failed. HTTP code ' + xhr.status; }; xhr.onload = () => { if (!xhr.status || (xhr.status >= 400)) throw 'Request failed. HTTP code ' + xhr.status; const documentAjax = (new DOMParser()).parseFromString( xhr.response,'text/html'); document.body.className = documentAjax.body.className; const pageContent = documentAjax.getElementById('pageContent'); const newPage = documentAjax.getElementById('pageSelector'); const page = document.getElementById('pageContent'); exitPageAnimation(); setTimeout( () => { window.scrollTo(0, 0); if (newPage) page.innerHTML = newPage.outerHTML; }, 700); } xhr.open('GET', url, true); xhr.send(); } by the way, is there any way to just insert the contents of the new page, just when the transition animation is finished, other than the timeout?
  2. Thank you, that's what I was looking for: D and thanks for the tips.
  3. Hello, I'm doing a website and wanted to implement some page transitions. The goal would be to implement something like this - https://allhero.co.jp/. I already managed to do something similar, the entry animation* is what I intend. The output* is still not what I want because I got stuck in an error that happens during the animation. When I run the first time, it performs as I want, but when I run it again, there is one step it fails to do, and I can not figure out why. The step that does not seem to run is this, and jump straight to the set. transitionPage.to(transitionElement, 1, { left: '200%' }, 2 ); Entry animation* transitionPage.to( transitionElement, .8, { left: 0 } ); transitionLogo.from( transitionElementLogo, .5, { autoAlpha: .1 } ); transitionLogo.from(transitionElementLogo, .6, { scale: 5, transformOrigin:'100% 0' } ); Output animation* transitionPage.to(transitionElement, 1, { left: '200%' }, 2 ); transitionPage.set(transitionElement, { clearProps : 'left'}, '+=2'); transitionLogo.set(transitionElementLogo, { clearProps : 'autoAlpha, scale'}); I'm now starting to work with gsap. Any suggestion?
×
×
  • Create New...