Performance when visible is False
See original GitHub issueTwo examples here, one with 100x100 container on stack ( only 20x20 are visible ) and the other with just 20x20.
here is the code
for 100x100 ( only 20x20 visible )
from jupyflow import Cell, OutputArea
from flet import *
import random
import flet as ft
def main(page: ft.Page):
page.title = "GridView Example"
page.theme_mode = ft.ThemeMode.DARK
# page.padding = 50
page.update()
container_grid = []
for y in range(100):
for x in range(100):
container_grid.append(
Container(
expand=False,
width=50,
height=50,
bgcolor=colors.LIGHT_BLUE_50,
border_radius=0,
margin=0,
padding=0,
top=y * (50 + 1),
left=x * (50 + 1),
clip_behavior=ClipBehavior.NONE,
visible=True if y < 20 and x < 20 else False,
)
)
def on_pan_update(e: ft.DragUpdateEvent):
stack_a.top = stack_a.top + e.delta_y
stack_a.left = stack_a.left + e.delta_x
stack_a.update()
stack_a = Stack(
controls=container_grid
+ [
GestureDetector(
on_pan_update=on_pan_update,
)
],
width=5000,
height=5000,
top=-50,
left=-50,
)
stack_b = Stack(
controls=[stack_a],
width=2000,
height=1500,
)
page.add(stack_b)
page.update()
ft.app(target=main, view=ft.WEB_BROWSER)
for 20x20 visible
from jupyflow import Cell, OutputArea
from flet import *
import random
import flet as ft
def main(page: ft.Page):
page.title = "GridView Example"
page.theme_mode = ft.ThemeMode.DARK
# page.padding = 50
page.update()
container_grid = []
for y in range(20):
for x in range(20):
container_grid.append(
Container(
expand=False,
width=50,
height=50,
bgcolor=colors.LIGHT_BLUE_50,
border_radius=0,
margin=0,
padding=0,
top=y * (50 + 1),
left=x * (50 + 1),
clip_behavior=ClipBehavior.NONE,
visible=True if y < 20 and x < 20 else False,
)
)
def on_pan_update(e: ft.DragUpdateEvent):
stack_a.top = stack_a.top + e.delta_y
stack_a.left = stack_a.left + e.delta_x
stack_a.update()
stack_a = Stack(
controls=container_grid
+ [
GestureDetector(
on_pan_update=on_pan_update,
)
],
width=5000,
height=5000,
top=-50,
left=-50,
)
stack_b = Stack(
controls=[stack_a],
width=2000,
height=1500,
)
page.add(stack_b)
page.update()
ft.app(target=main, view=ft.WEB_BROWSER)
Issue Analytics
- State:
- Created 9 months ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
Performance differences between visibility:hidden and display ...
When the elements display property is changed to other value than none , it triggers a complete document re-flow, which can be a...
Read more >If an element in the Xaml is set to isVisible="False" will it still ...
Hi,. Yes, the invisible elements also impact on your performance. All elements that you add on your xaml are compiled and load on...
Read more >Object cost when visible = false? - Questions - three.js forum
Setting .visible = false will avoid the per-frame cost of rendering the object, as if the object were frustum-culled.
Read more >Performance: alpha=0 VS visible=false - Phaser 2
Just to be clear: An object that has visible = false, or alpha = 0 will still get interpreted by the physics engine...
Read more >Sublayouts always rendering even when Visible=false ...
Sublayouts always rendering even when Visible=false, causing performance issues ; public partial ; class Spotlight ; System.Web.UI.UserControl { ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It’s a library Flet uses to maintain app state (controls tree).
Excuse the
import *
I am just prototyping here.