question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

from.remove() when the user does not wait for the transition to be completed (with overlap)

See original GitHub issue

Hello!

I’m using Highway to make overlap transition. Everything works fine but the old page isn’t remove if the user click on a link before the end of the transition.

I didn’t use gasp (or any other transition library), I use keyframes from my CSS and run from.remove() with a setTimeout. Maybe that’s where the problem’s coming from?

//main.js
import Highway from './highway.module.js';
import Overlap from './CustomTransition.js';
(() => {
  const H = new Highway.Core({
    transitions: {
      default: Overlap
    }
  });
})();
//CustomTransition.js
import Highway from './highway.module.js';
 class Overlap extends Highway.Transition {
  in({ from, to, trigger, done }) {      
      from.style.position = 'absolute';
      to.style.animation = "overlapTest 1s";            
      let timeremove = setTimeout(() => from.remove(), 1200)      
      done();
  }
  out({ from, done }) {
    done();    
  }
}
export default Overlap;
/*style.css*/
@keyframes overlapTest {
    from{ transform: translateX(100vw); }
    to{transform: translateX(0); }    
}

I have make a demo with a transition of 1s => https://eloquent-heisenberg-124835.netlify.app/

I have also make a repo : https://github.com/Totokoutonio/Highway_Overlap

Thx for helping!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
Totokoutoniocommented, Aug 21, 2020

@ThaoD5 I have use animationend and it works well!

//CustomTransition.js
import Highway from './highway.module.js';

class Overlap extends Highway.Transition {
  in({ from, to, done }) {      
      let el = document.querySelector('body');
      el.classList.add('transitions-active');      
      to.style.animation = "overlapTest 1s";
      to.addEventListener('animationend', () => {
        from.remove();
        el.classList.remove('transitions-active');
      });
      done();
  }
  out({ from, done }) {
    done();
  }
}

export default Overlap;
/*style.css*/
@keyframes overlapTest {
    from{ transform: translateX(100vw); }    
    to{ transform: translateX(0); }    
}

body.transitions-active{
    pointer-events: none;
}

Thanks a lot, I close this issue.

0reactions
ThaoD5commented, Aug 21, 2020

For a cleaner approach, I would advise to use an event like 'transitionend on the element that has your transition animation, that way you’re not playing with settimeout, but this is a very personal approach. 😃

Glad that solution worked for you !

Read more comments on GitHub >

github_iconTop Results From Across the Web

Remove class added with hover and animationend on mouseout
Thus, it does not wait for animation if a user takes the mouse out of the element before the transition completes. On the...
Read more >
How transitions are created in Final Cut Pro - Apple Support
Transitions require overlapping video from the clips on each side of the edit point. A one-second transition requires one second of video from...
Read more >
Smooth and simple transitions with the View Transitions API
The View Transition API allows page transitions within single-page apps, and will later include multi-page apps.
Read more >
Wait for Page Load in React | Ship Shape
The Solution​​ To delay the animation further, and ensure no overlap with the rest of the page loading, I decided to fully wait...
Read more >
Animation transitions - Unity - Manual
The interruption order works, conceptually, as if transitions are queued and then parsed for a valid transition from the first transition inserted to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found