mirror of
https://github.com/cyberarm/cyberarm_engine.git
synced 2025-12-16 05:02:34 +00:00
Cache scroll width/height
This commit is contained in:
@@ -411,10 +411,14 @@ module CyberarmEngine
|
|||||||
end
|
end
|
||||||
|
|
||||||
def scroll_width
|
def scroll_width
|
||||||
@children.sum(&:outer_width)
|
return @cached_scroll_width if @cached_scroll_width && is_a?(Container)
|
||||||
|
|
||||||
|
@cached_scroll_width = @children.sum(&:outer_width)
|
||||||
end
|
end
|
||||||
|
|
||||||
def scroll_height
|
def scroll_height
|
||||||
|
return @cached_scroll_height if @cached_scroll_height && is_a?(Container)
|
||||||
|
|
||||||
if is_a?(CyberarmEngine::Element::Flow)
|
if is_a?(CyberarmEngine::Element::Flow)
|
||||||
return 0 if @children.size.zero?
|
return 0 if @children.size.zero?
|
||||||
|
|
||||||
@@ -435,9 +439,9 @@ module CyberarmEngine
|
|||||||
|
|
||||||
pairs_ << a_ unless pairs_.last == a_
|
pairs_ << a_ unless pairs_.last == a_
|
||||||
|
|
||||||
pairs_.sum { |pair| + @style.padding_top + @style.border_thickness_top + pair.map(&:outer_height).max } + @style.padding_bottom + @style.border_thickness_bottom
|
@cached_scroll_height = pairs_.sum { |pair| + @style.padding_top + @style.border_thickness_top + pair.map(&:outer_height).max } + @style.padding_bottom + @style.border_thickness_bottom
|
||||||
else
|
else
|
||||||
@style.padding_top + @style.border_thickness_top + @children.sum(&:outer_height) + @style.padding_bottom + @style.border_thickness_bottom
|
@cached_scroll_height = @style.padding_top + @style.border_thickness_top + @children.sum(&:outer_height) + @style.padding_bottom + @style.border_thickness_bottom
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -173,6 +173,9 @@ module CyberarmEngine
|
|||||||
old_width = @width
|
old_width = @width
|
||||||
old_height = @height
|
old_height = @height
|
||||||
|
|
||||||
|
@cached_scroll_width = nil
|
||||||
|
@cached_scroll_height = nil
|
||||||
|
|
||||||
if is_root?
|
if is_root?
|
||||||
@width = @style.width = window.width
|
@width = @style.width = window.width
|
||||||
@height = @style.height = window.height
|
@height = @style.height = window.height
|
||||||
|
|||||||
Reference in New Issue
Block a user