Class: Foliokit::ContentStack
- Inherits:
-
Object
- Object
- Foliokit::ContentStack
- Includes:
- Modules::Element
- Defined in:
- lib/foliokit/content_stack.rb
Instance Method Summary collapse
- #articles ⇒ Object
-
#initialize(element, package) ⇒ ContentStack
constructor
A new instance of ContentStack.
- #renditions(index) ⇒ Object
- #unify? ⇒ Boolean
Constructor Details
#initialize(element, package) ⇒ ContentStack
Returns a new instance of ContentStack.
17 18 19 |
# File 'lib/foliokit/content_stack.rb', line 17 def initialize(element, package) super(element, package) end |
Instance Method Details
#articles ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/foliokit/content_stack.rb', line 38 def articles = [] max_index = asset_renditions.count - 1 device_height = package.manifest.device_height .each do || median_y = .bounds.y + (.bounds.height / 2) index = unify? ? 0 : [median_y / device_height, max_index].min offset_top = index * device_height .bounds.translate(0, -offset_top) [index] ||= [] [index].push() end = [[]] if .empty? unless unify? .push([]) while .length < asset_renditions.count end .each_with_index.map { |, index| Article.new(self, , index) } end |
#renditions(index) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/foliokit/content_stack.rb', line 25 def renditions(index) if unify? asset_renditions.each_with_index.map do |rendition, i| rendition.bounds = Types::Bounds.new(0, package.manifest.device_height * i, rendition.width, rendition.height) rendition end else rendition = asset_renditions[index] rendition.bounds = Types::Bounds.new(0, 0, rendition.width, rendition.height) [rendition] end end |
#unify? ⇒ Boolean
21 22 23 |
# File 'lib/foliokit/content_stack.rb', line 21 def unify? (smooth_scrolling == orientation) || (smooth_scrolling == "true") end |