Method: CDK::SCROLLER#setPosition

Defined in:
lib/cdk/components/scroller.rb

#setPosition(item) ⇒ Object



157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/cdk/components/scroller.rb', line 157

def setPosition(item)
  if item <= 0
    self.KEY_HOME
  elsif item > @list_size - 1
    @current_top = @max_top_item
    @current_item = @list_size - 1
    @current_high = @view_size - 1
  elsif item >= @current_top && item < @current_top + @view_size
    @current_item = item
    @current_high = item - @current_top
  else
    @current_top = item - (@view_size - 1)
    @current_item = item
    @current_high = @view_size - 1
  end
end