Class: Foliokit::Overlay::OverlayImagepan

Inherits:
OverlayBase
  • Object
show all
Defined in:
lib/foliokit/overlay/overlay_imagepan.rb

Instance Attribute Summary

Attributes inherited from OverlayBase

#section_index, #state

Instance Method Summary collapse

Methods inherited from OverlayBase

element_base, #initialize, #stateful?

Methods included from Modules::Element

#initialize

Constructor Details

This class inherits a constructor from Foliokit::Overlay::OverlayBase

Instance Method Details

#export(document, options = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/foliokit/overlay/overlay_imagepan.rb', line 14

def export(document, options = {})
  node = super(document, options)
  if source.present?
    src = package.apply_asset(node, "source", source)
    node["style"] ||= ""
    node["style"] = [node["style"], "background-image: url(#{src})"].join(";")
  end

  if initial_viewport.present?
    zoom = source_width.to_f / initial_viewport.width.to_f
    width = bounds.width * zoom
    node["style"] ||= ""
    node["style"] = [node["style"], "background-size: #{width}px"].join(";")
    node["source-width"] = source_width
    node["source-height"] = source_height
  end

  node["touchable"] = true
  node
end

#tagnameObject



10
11
12
# File 'lib/foliokit/overlay/overlay_imagepan.rb', line 10

def tagname
  "div"
end