Dogstudio / highway

Highway - A Modern Javascript Transitions Manager
https://highway.js.org/
MIT License
1.43k stars 92 forks source link

CustomRenderer not working as expected #78

Closed ajayns closed 4 years ago

ajayns commented 4 years ago

Following the Highway documentation, I've built a basic setup:

import Highway from "@dogstudio/highway";

function init() {
  class CustomRenderer extends Highway.Renderer {
    onLeave() {
      console.log("leave");
    }
    onEnter() {
      console.log("enter");
    }
    onEnterCompleted() {
      console.log("enter complete");
    }
  }

  const H = new Highway.Core({
    renderers: {
      name: CustomRenderer,
    },
  });
}

window.onload = init;

With this setup, any added custom transition works as expected but the custom renderer does not run the hooks at all: none of the messages are being logged from the CustomRenderer.

Additional info: HTML:

<body>
  <main data-router-wrapper>
     <div data-router-view="home">
      ...
ThaoD5 commented 4 years ago

Hello @ajayns ,

Instead of "name" in your renderers, have you tried to put "home" which is the value of your data-router-view of your homeage ? If not this is probably the reason why, when navigating to your homepage, you don't have on those events,

Keep me updated :)

ajayns commented 4 years ago

Oh my bad, that was quite the ignorance from my part. This fixes it.

I know you have mentioned this in your documentation, but users generally like to get code that just works straight from the documentation and like to figure out things progressively. So many examples that can directly be used could prove helpful :)

Thank you for your quick response

ThaoD5 commented 4 years ago

Well noted, we know the documentation could be enhanced, we just need a bit of time to apply that! Thanks for the feedback :)