Method: Flms::KeyframeViewObject#pinning
- Defined in:
- app/view_objects/flms/keyframe_view_object.rb
#pinning(width, height, free_height = false) ⇒ Object
Generate position styling so that the layer remains fully in the viewport. (Pinned to top-left if positioned top-left, pinned center if centered, etc.)
48 49 50 51 52 53 54 55 56 |
# File 'app/view_objects/flms/keyframe_view_object.rb', line 48 def pinning(width, height, free_height = false) # (Round calculated values here so we can prevent floating-point errors from # giving us unpredictable results in specs) width_style = "#{ style_for_attribute(:width, (@keyframe.scale * width).round(2)) }; " height_style = free_height ? '' : "#{ style_for_attribute(:height, (@keyframe.scale * height).round(2)) }; " margin_left_style = "margin-left#{easing_function}: #{ ((@keyframe.position_x * @keyframe.scale * -width * 100) + @keyframe.margin_left_percent) }%; " margin_top_style = "margin-top#{easing_function}: #{ ((@keyframe.position_y * @keyframe.scale * -height * 100) + @keyframe.margin_top_percent) }%;" "#{width_style}#{height_style}#{margin_left_style}#{margin_top_style}" end |