Method: Flms::AnimationLayerViewObject#frames_attributes

Defined in:
app/view_objects/flms/animation_layer_view_object.rb

#frames_attributes(scroll_offset = 0) ⇒ Object

Define attributes related to animating the sprited image



14
15
16
17
18
19
20
21
22
23
24
# File 'app/view_objects/flms/animation_layer_view_object.rb', line 14

def frames_attributes(scroll_offset = 0)
  data = { }
  (0...@layer.frame_count).each do |frame_index|
    y_offset = -(frame_index * frame_sprite_height)
    data["data-#{ frame_pixel_start(frame_index, scroll_offset) }"] = "background-position: 0 #{ y_offset }px;"
    data["data-#{ frame_pixel_end(frame_index, scroll_offset) }"] = "background-position: 0 #{ y_offset }px;"
  end
  data[:style] = "width: #{ @layer.image_width }px; height: #{ frame_sprite_height }px;" \
                 "background-image: url(#{ src }); background-size: #{ @layer.image_display_mode };"
  data
end