Class: Ruflet::UI::Controls::RufletComponents::InteractiveViewerControl

Inherits:
Control
  • Object
show all
Defined in:
lib/ruflet_ui/ruflet/ui/controls/shared/interactiveviewer_control.rb

Constant Summary collapse

TYPE =
"interactiveviewer".freeze
WIRE =
"InteractiveViewer".freeze
KEYWORDS =
[:align, :alignment, :animate_align, :animate_margin, :animate_offset, :animate_opacity, :animate_position, :animate_rotation, :animate_scale, :animate_size, :aspect_ratio, :badge, :bottom, :boundary_margin, :clip_behavior, :col, :constrained, :content, :data, :disabled, :expand, :expand_loose, :height, :interaction_end_friction_coefficient, :interaction_update_interval, :key, :left, :margin, :max_scale, :min_scale, :offset, :opacity, :pan_enabled, :right, :rotate, :rtl, :scale, :scale_enabled, :scale_factor, :size_change_interval, :tooltip, :top, :trackpad_scroll_causes_scale, :visible, :width, :on_animation_end, :on_interaction_end, :on_interaction_start, :on_interaction_update, :on_size_change].freeze

Constants inherited from Control

Control::HOST_EXPANDED_TYPES, Control::SCHEMA_METADATA_CACHE

Instance Attribute Summary

Attributes inherited from Control

#children, #id, #props, #runtime_page, #type, #wire_id

Instance Method Summary collapse

Methods inherited from Control

#attach_handler, #emit, generate_id, #has_handler?, #merge_props, #on, #to_patch

Constructor Details

#initialize(id: nil, **props) ⇒ InteractiveViewerControl

Returns a new instance of InteractiveViewerControl.



13
14
15
16
17
18
19
20
# File 'lib/ruflet_ui/ruflet/ui/controls/shared/interactiveviewer_control.rb', line 13

def initialize(id: nil, **props)
  compact = {}
  props.each do |key, value|
    raise ArgumentError, "unknown keyword: :#{key}" unless KEYWORDS.include?(key)
    compact[key] = value unless value.nil?
  end
  super(type: TYPE, id: id, **compact)
end

Instance Method Details

#pan(dx, dy: 0, dz: 0, timeout: 10, on_result: nil) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/ruflet_ui/ruflet/ui/controls/shared/interactiveviewer_control.rb', line 22

def pan(dx, dy: 0, dz: 0, timeout: 10, on_result: nil)
  runtime_page&.invoke(
    self,
    "pan",
    args: { "dx" => dx, "dy" => dy, "dz" => dz },
    timeout: timeout,
    on_result: on_result
  )
end

#reset(animation_duration: nil, timeout: 10, on_result: nil) ⇒ Object



32
33
34
35
36
# File 'lib/ruflet_ui/ruflet/ui/controls/shared/interactiveviewer_control.rb', line 32

def reset(animation_duration: nil, timeout: 10, on_result: nil)
  args = {}
  args["animation_duration"] = stringify_hash_keys(animation_duration) unless animation_duration.nil?
  runtime_page&.invoke(self, "reset", args: args.empty? ? nil : args, timeout: timeout, on_result: on_result)
end

#restore_state(timeout: 10, on_result: nil) ⇒ Object



38
39
40
# File 'lib/ruflet_ui/ruflet/ui/controls/shared/interactiveviewer_control.rb', line 38

def restore_state(timeout: 10, on_result: nil)
  runtime_page&.invoke(self, "restore_state", timeout: timeout, on_result: on_result)
end

#save_state(timeout: 10, on_result: nil) ⇒ Object



42
43
44
# File 'lib/ruflet_ui/ruflet/ui/controls/shared/interactiveviewer_control.rb', line 42

def save_state(timeout: 10, on_result: nil)
  runtime_page&.invoke(self, "save_state", timeout: timeout, on_result: on_result)
end

#zoom(factor, timeout: 10, on_result: nil) ⇒ Object



46
47
48
# File 'lib/ruflet_ui/ruflet/ui/controls/shared/interactiveviewer_control.rb', line 46

def zoom(factor, timeout: 10, on_result: nil)
  runtime_page&.invoke(self, "zoom", args: { "factor" => factor }, timeout: timeout, on_result: on_result)
end