-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possibility to add event listener in the reader #36
Comments
Hello, good question. Yes it is possible in principle, albeit with some limitations due to the sandboxed nature of iframes/webviews. So, the "devil is in the detail". What information do you need in the event payload, and what event targets are you interested in listening for? For example, mouse clicks can occur inside one of the webviews currently rendering publication documents (one or two in the case of fixed layout / pre-paginates EPUBs), but such event can also occur outside of webviews (yet, still inside the rectangular area reserved for the "navigator"). |
Just to clear a doubt: if all you need to know is that a mouse click occurred outside of a chrome/UI control (for example, to dismiss a modal slider panel / interactive dialog), then you should not need to rely on events from the navigator. This would be a UI design anti-pattern. |
Also note that there is a notion of "competition" regarding the consumers of DOM events, and the use of useCapture, preventDefault etc. determines precedence / priority. |
I need to know when someone click on the reader. Not only a link but just click. Like when you had a onclick listener on an element. Because the reader is on a webview, it don't seems to accept listener like onclick. I tried a lot of things but I didn't succed. But maybe you know how to do that ? Maybe I forget something |
So, based on a separate discussion on Slack, if I understand correctly you need to detect "pointing device" / "pointer event" user interaction (mouse click or touch), when it occurs outside of a dedicated higher-z-index / overlay UI control (such as a modal dialog or a slide-out menu), in order to trigger the discard / dismiss / close action on the said control. In that case ; like I said in my original comment(s) ; it would be a UI design anti-pattern (frankly, a hack) to expect specific notifications from webviews (or other nested iframes possibly hiding underneath the UI control's obscured area). As I mentioned before, the "navigator" component does not necessarily consist in a single Electron webview spanning the entire rectangular dimensions of the visible viewport, it can for example consist in two webviews + blank areas around them in order to lay out the document (pages) of fixed-layout publications. Furthermore, there can be nested iframe widgets inside navigator webviews, and these would typically implement combinations of useCapture, preventDefault and stopPropagation in order to handle user interactions inside sandboxed experiences (see also my previous comment regarding "competition" and precedence/priority in event handling, with respect to user interactions built into the navigator logic). So, I think you are trying to solve a (real) UI problem using the wrong technique. For example, Do you see what I mean? |
As mentioned above, there are well-established technical UI design patterns to achieve the "dismiss" actions without explicitly querying events from the underlying DOM objects. For example, the concept of "scrim" is used for dialogs in this UI library: Same with slide-in/out panels (aka drawers): |
Just to clarify please: are you using a UI library, or are you writing UI components from scratch? If the latter, I think you will have to implement all the tricky edge cases (especially layering / z-index / nested modals) for mouse/touch/keyboard interactions. Such as: a popup menu over a modal confirmation dialog over a slider panel over the main UI. EDIT: I intentionally stretched the above example :) The main point is that unless you can guarantee that your UI will only ever generate a single dissmissable modal overlay at any given time, then you are going to deal with layering complications in the event subsystem of your custom/ad-hoc UI lib. |
In the list of https://material.io/develop/web/components/drawers/, the modal drawer is the one we need IMO. As it adds a "layer" upon the navigator view, isn't it simplifying the discussion? Note: "scrim" means "voile léger" in French -> the semi-transparent layer upon the navigator view. |
Is it possible to provide a way to give event listener to the reader ?
For exemple I need to know when I click on the reader but I can't add a listener.
The text was updated successfully, but these errors were encountered: