Advertisement
Guest User

Untitled

a guest
Apr 5th, 2020
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.98 KB | None | 0 0
  1. list[_index].func = function()
  2.                 if listElement and listElement.contentBounds and listElement.contentBounds.yMax and
  3.                     listElement.contentBounds.yMin then
  4.                    
  5.                     local _yMin = listElement.contentBounds.yMin
  6.                     local _yMax = listElement.contentBounds.yMax
  7.                    
  8.                     local isWithinRenderDistance = _yMax > -_H * _renderDistance and _yMax < _H *
  9.                         ( _renderDistance + 1 )  or _yMin < _H * ( _renderDistance + 1 ) and
  10.                         _yMin > -_H * _renderDistance
  11.                    
  12.                     local isOutsideRenderDistance = _yMax <= -_H * _renderDistance and _yMin < -_H *
  13.                         _renderDistance or _yMax > _H * _renderDistance + 1 ) and _yMin >= _H * _renderDistance + 1
  14.                    
  15.                     unload = true
  16.                    
  17.                     if isWithinRenderDistance then
  18.                         if not listElement._status then
  19.                             listElement._status = true
  20.  
  21.                             timerThread = timer.performWithDelay(5, function()
  22.                                 if not listElement._isRendering then
  23.                                     listElement._isRendering = true
  24.                                    
  25.                                     if unload then
  26.                                         if listElement._y then
  27.                                             _newElement = createElement(data)
  28.                                             listElement:insert(_newElement)
  29.                                             listElement.y = listElement._y
  30.                                         end
  31.                                     else
  32.                                         if _newElement.loadContent and
  33.                                             type(_newElement.loadContent) == "function" then
  34.                                            
  35.                                             _newElement:loadContent()
  36.                                         end
  37.                                     end
  38.                                 end
  39.                             end)
  40.                         end
  41.                     elseif isOutsideRenderDistance then
  42.                         if listElement._status then
  43.                             listElement._status = false
  44.                            
  45.                             if unload then
  46.                                 if listElement.y and _newElement then
  47.                                     listElement._y = listElement.y
  48.                                     _newElement:destroy()
  49.                                     _newElement = nil
  50.                                 end
  51.                             else
  52.                                 if _newElement.unloadContent and type(_newElement.unloadContent) == "function" then
  53.                                     _newElement:unloadContent()
  54.                                 end
  55.                             end
  56.                         end
  57.                        
  58.                         listElement._isRendering = false
  59.                     end
  60.                 end
  61.                
  62.                 ---collectgarbage()
  63.                 --printMemUsage()
  64.             end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement