Share Posted February 22, 2019 Hi guys, I am trying to reproduce this animation in a project - See the Pen bQPBvQ by victorwork (@victorwork) on CodePen 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? See the Pen bQPBvQ by victorwork (@victorwork) on CodePen Link to comment Share on other sites More sharing options...
Share Posted February 22, 2019 Hi @saomartinho! It's probably easier to show some code with notes, so here you go! See the Pen JxQpWq?editors=1010 by sgorneau (@sgorneau) on CodePen Hope this helps! 4 Link to comment Share on other sites More sharing options...
Author Share Posted February 22, 2019 Thanks, it's really this, perfect xD 3 Link to comment Share on other sites More sharing options...
Share Posted February 22, 2019 Glad to help @saomartinho! 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now