Comments (5)
aweome thanks!! nicegui is the best :)
from nicegui.
Thanks for pointing this out, @psy0rz! We fixed it by explicitly handling the timeout.
from nicegui.
well now it works correctly, but on closer inspection: the timer runs on the server and send the javascript code to the client (browser), which in turn return the results.
this means that there will be a bunch of websocket messages 10 times per second, even if the user is not scrolling.
cant we do better? perhaps some javascript promise that gets resolved only when the user scrolls down enough to trigger additional content?
from nicegui.
Well, you're right. The current implementation might be a proof of concept, but not be very efficient.
Here's a rough idea how we could rewrite it using an intersection observer:
ui.add_head_html(r'''
<script>
document.addEventListener('DOMContentLoaded', (event) => {
new IntersectionObserver(entries => emitEvent("bottom")).observe(document.querySelector('.footer'));
});
</script>
''')
def load_more():
with images:
for _ in range(10):
ui.image(f'https://picsum.photos/640/360?{time.time()}').classes('w-32')
with ui.column() as images:
load_more()
ui.on('bottom', load_more)
ui.element().classes('footer')
I just don't like the initial call to load_more()
and that we need to load multiple images so that the footer moves out of the viewport. Otherwise there won't be any intersection to observe. And we need a container for the image so that the footer remains below them.
I wonder if there's an easier way to achieve the same result...
from nicegui.
yes i suspected this would be one of those things that can be done, but will get complex very quickly :)
for now i'm fine with using a timer of 1 second for my application, but it would be nice if the example would be "perfect" in the future.
from nicegui.
Related Issues (20)
- Problem for passing parameter to handler function for dynamic added `ul.html` , `ui.botton`, maybe others. HOT 2
- KeyError in `ui.log` after client disconnected HOT 7
- AG Grids inside hidden tabs don't get mounted HOT 4
- pyinstaller and cpu_bound issue HOT 6
- Leaflet: map flickers between centers after flyTo HOT 8
- Change to MS-Windows style windows is not possible? HOT 2
- 2-way bindings backward direction does not work anymore HOT 1
- Not able to clear input anymore HOT 1
- Accessibility issue with hidden connection warning HOT 3
- Autocomplete for `ui.input` not working on mobile HOT 1
- Need Assistance Calling the Search Filter Function Inside the Search Template in NiceGUI Table
- NiceGUI uses 100% of a CPU core when running inside a container HOT 1
- [Pycharm Problem] Raise asyncio error when reload HOT 1
- local_file_picker Example error in version 1.4.25: HOT 5
- custom vue.js component not updated after modification HOT 3
- non-existing on_pointer parameter in InteractiveImage HOT 1
- `ui.chip` textcolor stays black on dark background HOT 2
- Bump plotly.js to 2.32.0 version supporting zindex HOT 4
- Lifespan state is not passed when a FastAPI app mount a Nicegui app HOT 3
- plotly is missing from docker image HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nicegui.