Can you declare this function as a method of the Panel? I'm thinking `onVisibilityChange`, `handleVisibilityChange` or similar. That will make the constructor much easier to read.