瀏覽代碼

fix visibility for elements

Falko Schindler 4 年之前
父節點
當前提交
7152ccb6da
共有 2 個文件被更改,包括 3 次插入3 次删除
  1. 2 2
      examples.py
  2. 1 1
      nicegui/elements/element.py

+ 2 - 2
examples.py

@@ -61,8 +61,8 @@ with ui.row():
                 ui.slider(min=1, max=3).bind_value(model.value)
                 ui.label().bind_text(model.value)
         with ui.row().add_classes('items-center'):
-            on = ui.icon('visibility')
-            ui.checkbox('visible', value=True).bind_value_to(on.visible)
+            v = ui.checkbox('visible', value=True)
+            ui.icon('visibility').bind_visibility_from(v.value)
 
     with ui.card():
         ui.label('Matplotlib', 'h5')

+ 1 - 1
nicegui/elements/element.py

@@ -33,7 +33,7 @@ class Element:
     def visible(self, visible: bool):
 
         self.visible_ = visible
-        self.view.set_class('visible' if visible else 'invisible')
+        (self.view.remove_class if self.visible_ else self.view.set_class)('hidden')
 
     def bind_visibility_to(self, target, forward=lambda x: x):