motion-prime/elements/base_element.rb in motion-prime-0.9.6 vs motion-prime/elements/base_element.rb in motion-prime-0.9.7

- old
+ new

@@ -90,20 +90,35 @@ left right min_width min_outer_width max_width max_outer_width width top bottom min_height min_outer_height max_height max_outer_height height]) end def reload! + reset_computed_values compute_options! end + def rerender! + render_target = view.try(:superview) + view.try(:removeFromSuperview) + render(render_target: render_target) + section.try(:on_element_render, self) + end + def update_with_options(new_options = {}) options.merge!(new_options) reload! - view.try(:removeFromSuperview) - render + rerender! end + def update_options(options) + ViewStyler.new(view, view.superview.try(:bounds), options).apply + end + + def update + update_with_options({}) + end + def hide view.hidden = true end def show @@ -116,9 +131,13 @@ view.addGestureRecognizer single_tap view.setUserInteractionEnabled true end protected + def reset_computed_values + @content_height = nil + @content_width = nil + end # Compute options sent inside block, e.g. # element :button do # {name: model.name} # end \ No newline at end of file