-
-
Notifications
You must be signed in to change notification settings - Fork 104
Add reached-start and reached-end CustomEvents #65
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
base: main
Are you sure you want to change the base?
Add reached-start and reached-end CustomEvents #65
Conversation
6f0bbaf
to
58775bc
Compare
Is there a need for the events if you can check it in the |
The two events implemented this time are of a type that cannot be obtained with the relocate event. The reason is that the page is not redrawn when you try to go to the next page after reaching the last page (or before the first page). The event that says that the page was about to be turned but was interrupted because it was the last (first) page and could not go any further had to be written directly in the logic of |
What's the use case for that? And for the fixed-layout renderer at least, since |
This is how I’m thinking about the use of the Use CaseThe main reason is to support common features in e-book readers—for example, showing a “Please leave a review” message when a user finishes a book, or triggering actions when the user reaches the start or end. These are common patterns in many e-reading apps, and using events is a simple and clean way to handle them. Why Dispatch Events Inside the RendererI understand your point about handling this at the place where If we moved the boundary-checking logic outside (e.g., to Why Use Events Instead of Return Values or ErrorsI did consider other options:
Using events is the most flexible and least disruptive approach. Components that care about these events can listen to them, and others can just ignore them. This keeps the current API unchanged while adding new functionality. Also, the codebase already uses events to communicate state changes, so this follows the existing design pattern. Would you be open to keeping this implementation, or is there anything else I should consider? |
That sounds to me that you'd want to handle it in the application. It's basically the same as, e.g. disabling prev/next buttons at the start/end. So for example, rather than disabling the next button, you'd make it trigger the message if You can also do something more sophisticated, like detecting whether the end is reached by considering semantic information contained in the book (navigation documents, The only problem I see is with touchscreen swiping (which currently is only supported by the paginator), which is internal to the paginator at the moment (though it might be better to move it out or make it public). There's no overscroll, and even if there is, it's unclear how it'd work. Perhaps the cleanest way for this specific use case would be to insert an empty dummy section at the end. You can then show the message when relocating to the section. |
Thank you for your detailed feedback. I'd like to clarify a few points:
If our fundamental approaches to this problem are different, I understand that this PR might not align with the project's direction. I'm happy to reconsider my approach or close this PR if you feel it doesn't fit with your vision for the library. Please let me know your thoughts on how you'd prefer to proceed. |
No, I mentioned it only as an example of what applications might do. It's probably not terribly useful in practice. No—my point is that checking whether it's at the start/end is not really any different from checking whether the user has navigated to any other specific point in the book apart from the start/end. Namely, you would check the location provided by the
Again, this is just an example (I said "e.g."). The point is that it is something that can be done without a separate event. And your use case is quite similar to it, from which I then feel that it can similarly be implemented using just the existing
The fixed-layout renderer does not handle touchscreen events. Probably it's responding to touches from the wheel event. At any rate, my concern was about 1:1 gestures (that is, the page will following your movement, whether it's touchscreen or touchpad), which the fixed-layout renderer does not support. As I said, while the paginator supports 1:1 touch gestures, since there's no overscroll, i.e. if it's at the start/end, swiping will not move the page in that direction at all, that means these events of yours, if they were to be provided for the paginator as well, will never be triggered when using the touchscreen. To recap, the gist of my comment is basically: if it's possible to achieve the desired result with the Look at Epub.js's API, for example. |
I understand. I felt that if I knew whether my status was atStart or atEnd, I could take the next or previous action in that state, so that's how I'll handle the event itself this time. Thank you very much for your time in this discussion. |
I implemented a CustomEvent that is fired when the first or last page is reached and the user tries to go further.