Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Seamless Navigation with Portal

Seamless Navigation with Portal

adriantirusli

December 06, 2019
Tweet

More Decks by adriantirusli

Other Decks in Programming

Transcript

  1. Apa saja opsi yang ada untuk mendapatkan UX yang baik?

    7 chrome dev summit extended 2019
  2. 18

  3. 19

  4. 20 Cek apabila browser support <portal> // Check if <portal>

    is available if(!('HTMLPortalElement' in window)) { return; }
  5. 21 Buat <portal> deh // Check if <portal> is available

    if(!('HTMLPortalElement' in window)) { return; } // Create and append the element portal.src = 'another-example.html'; portal.style = '...'; document.body.appendChild(portal); const portal = document.createElement('portal');
  6. 22 Buat <portal> deh // Check if <portal> is available

    if(!('HTMLPortalElement' in window)) { return; } // Create and append the element const portal = document.createElement('portal'); portal.style = '...'; document.body.appendChild(portal); portal.src = 'another-example.html';
  7. 23 Buat <portal> deh // Check if <portal> is available

    if(!('HTMLPortalElement' in window)) { return; } // Create and append the element const portal = document.createElement('portal'); portal.src = 'another-example.html'; document.body.appendChild(portal); portal.style = '...';
  8. 24 Buat <portal> deh // Check if <portal> is available

    if(!('HTMLPortalElement' in window)) { return; } // Create and append the element const portal = document.createElement('portal'); portal.src = 'another-example.html'; portal.style = '...'; document.body.appendChild(portal);
  9. 25

  10. 26

  11. 29

  12. 30

  13. 33 Menambahkan animasi saat transisi portal.addEventListener('click', _ => { //

    portal.activate() // animate before activate // it can be CSS transition, // keyframes or even JavaScript fancyAnimation(portal); });
  14. 34 Menambahkan animasi saat transisi const fancyAnimation = portal =>

    { portal.style.transform = ` scale(1.0) translateX(-20px) translateY(20px) `; portal.style.transition = 'transform 0.4s'; }
  15. 35 Menambahkan animasi saat transisi // If you were using

    CSS transition... portal.addEventListener('transitionend', evt => { // check if it's the right transition // you want to trigger activation if (evt.propertyName == 'transform') { // Activate the portal portal.activate(); } });
  16. 37 Event portalactivate akan aktif setelah halaman diaktifkan // Listen

    to the portalactivate event // Retrieve the previous page as a <portal> // - The JavaScript state // - UI state // are all saved const portal = evt.adoptPredecessor(); // Append the <portal> to the document document.body.append(portal); } window.addEventListener('portalactivate', evt => {
  17. 38 Event dilengkapi dengan elemen predecessor <portal> // Listen to

    the portalactivate event window.addEventListener('portalactivate', evt => { // Retrieve the previous page as a <portal> // - The JavaScript state // - UI state // are all saved // Append the <portal> to the document document.body.append(portal); } const portal = evt.adoptPredecessor();
  18. 39 Back and forth antara 2 halaman tadi // Listen

    to the portalactivate event window.addEventListener('portalactivate', evt => { // Retrieve the previous page as a <portal> // - The JavaScript state // - UI state // are all saved const portal = evt.adoptPredecessor(); // Append the <portal> to the document }); document.body.append(portal);
  19. Accessibility ◎ Google akan membahas lebih lanjut mengenai accessibility dan

    semantic pada <portal> untuk versi origin trial ◎ Disarankan untuk menggunakan prefers-reduced-motion saat menggunakan animasi .portal-transition { transition: transform 1s opacity 2s; } @media (prefers-reduced-motion: reduce) { .portal-transition { transition: transform 0.001s opacity 2s; } } 40
  20. Hindari overloading halaman menggunakan <portal> ◎ Menggunakan lazy loading saat

    on scroll gabungkan dengan Intersection Observer. ◎ Lebih baik memanfaatkan <portal> untuk interaksi user yang kuat seperti click. ◎ Menggunakan skeleton page saat loading content pertama kali. 41
  21. Hindari overloading halaman menggunakan <portal> ◎ Menggunakan lazy loading saat

    on scroll gabungkan dengan Intersection Observer. ◎ Memanfaatkan <portal> untuk interaksi yang kuat seperti click. ◎ Menggunakan skeleton page saat loading keseluruhan content. 42