atome 0.5.1.9 → 0.5.2.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +22 -5
  3. data/lib/atome/atome.rb +46 -21
  4. data/lib/atome/extensions/atome.rb +5 -26
  5. data/lib/atome/extensions/geolocation.rb +0 -1
  6. data/lib/atome/extensions/matrix.rb +171 -0
  7. data/lib/atome/extensions/ping.rb +9 -11
  8. data/lib/atome/genesis/generators/atome.rb +14 -2
  9. data/lib/atome/genesis/generators/communication.rb +1 -1
  10. data/lib/atome/genesis/generators/event.rb +32 -3
  11. data/lib/atome/genesis/generators/identity.rb +32 -0
  12. data/lib/atome/genesis/generators/material.rb +21 -0
  13. data/lib/atome/genesis/generators/spatial.rb +1 -0
  14. data/lib/atome/genesis/generators/time.rb +5 -0
  15. data/lib/atome/genesis/generators/utility.rb +20 -2
  16. data/lib/atome/genesis/genesis.rb +4 -4
  17. data/lib/atome/genesis/sparkle.rb +1 -1
  18. data/lib/atome/helpers/callbacks.rb +36 -29
  19. data/lib/atome/helpers/essentials.rb +5 -2
  20. data/lib/atome/helpers/utilities.rb +59 -10
  21. data/lib/atome/kernel/universe.rb +3 -7
  22. data/lib/atome/presets/atome.rb +11 -7
  23. data/lib/atome/renderers/browser/atome.rb +7 -7
  24. data/lib/atome/renderers/browser/browser.rb +6 -2
  25. data/lib/atome/renderers/browser/effect.rb +2 -2
  26. data/lib/atome/renderers/browser/event.rb +25 -19
  27. data/lib/atome/renderers/browser/geometry.rb +2 -2
  28. data/lib/atome/renderers/browser/helpers/animation_helper.rb +69 -0
  29. data/lib/atome/renderers/browser/helpers/browser_helper.rb +0 -1
  30. data/lib/atome/renderers/browser/helpers/color_helper.rb +0 -2
  31. data/lib/atome/renderers/browser/helpers/drag_helper.rb +6 -6
  32. data/lib/atome/renderers/browser/helpers/effect_helper.rb +1 -0
  33. data/lib/atome/renderers/browser/helpers/event_helper.rb +59 -0
  34. data/lib/atome/renderers/browser/helpers/video_helper.rb +10 -3
  35. data/lib/atome/renderers/browser/identity.rb +10 -3
  36. data/lib/atome/renderers/browser/material.rb +28 -5
  37. data/lib/atome/renderers/browser/spatial.rb +36 -5
  38. data/lib/atome/renderers/browser/time.rb +3 -0
  39. data/lib/atome/renderers/browser/utility.rb +20 -11
  40. data/lib/atome/renderers/headless/utility.rb +2 -2
  41. data/lib/atome/renderers/html/atome.rb +5 -5
  42. data/lib/atome/renderers/html/effect.rb +1 -1
  43. data/lib/atome/renderers/html/event.rb +1 -1
  44. data/lib/atome/renderers/html/geometry.rb +2 -2
  45. data/lib/atome/renderers/html/html.rb +1 -1
  46. data/lib/atome/renderers/html/identity.rb +2 -2
  47. data/lib/atome/renderers/html/spatial.rb +5 -5
  48. data/lib/atome/renderers/html/utility.rb +7 -7
  49. data/lib/atome/renderers/server/utility.rb +2 -2
  50. data/lib/atome/version.rb +1 -1
  51. data/lib/atome.rb +7 -3
  52. data/sig/atome.rbs +6 -0
  53. data/sig/atome_js.rbs +1 -0
  54. data/vendor/assets/build/css/style.css +23 -16
  55. data/vendor/assets/build/index.html +4 -2
  56. data/vendor/assets/build/js/third_parties/wad.min.js +9 -0
  57. data/vendor/assets/build/medias/audios/Binrpilot.mp3 +0 -0
  58. data/vendor/assets/build/medias/rubies/examples/_2_solve.rb +24 -2
  59. data/vendor/assets/build/medias/rubies/examples/_audio.rb +178 -0
  60. data/vendor/assets/build/medias/rubies/examples/_dataset.rb +80 -0
  61. data/vendor/assets/build/medias/rubies/examples/_os.rb +29 -0
  62. data/vendor/assets/build/medias/rubies/examples/_test.rb +1 -0
  63. data/vendor/assets/build/medias/rubies/examples/_vie.rb +211 -0
  64. data/vendor/assets/build/medias/rubies/examples/add.rb +25 -0
  65. data/vendor/assets/build/medias/rubies/examples/animation.rb +81 -0
  66. data/vendor/assets/build/medias/rubies/examples/{atome.new.rb → atome_new.rb} +5 -5
  67. data/vendor/assets/build/medias/rubies/examples/bottom.rb +1 -1
  68. data/vendor/assets/build/medias/rubies/examples/center.rb +21 -0
  69. data/vendor/assets/build/medias/rubies/examples/clone.rb +35 -0
  70. data/vendor/assets/build/medias/rubies/examples/color.rb +20 -15
  71. data/vendor/assets/build/medias/rubies/examples/cursor.rb +7 -0
  72. data/vendor/assets/build/medias/rubies/examples/delete.rb +25 -3
  73. data/vendor/assets/build/medias/rubies/examples/drag.rb +3 -2
  74. data/vendor/assets/build/medias/rubies/examples/edit.rb +12 -0
  75. data/vendor/assets/build/medias/rubies/examples/empty_atome.rb +12 -0
  76. data/vendor/assets/build/medias/rubies/examples/hide.rb +7 -0
  77. data/vendor/assets/build/medias/rubies/examples/markers.rb +48 -0
  78. data/vendor/assets/build/medias/rubies/examples/matrix.rb +58 -0
  79. data/vendor/assets/build/medias/rubies/examples/monitoring.rb +22 -11
  80. data/vendor/assets/build/medias/rubies/examples/play.rb +1 -1
  81. data/vendor/assets/build/medias/rubies/examples/read.rb +7 -4
  82. data/vendor/assets/build/medias/rubies/examples/remove.rb +16 -0
  83. data/vendor/assets/build/medias/rubies/examples/right.rb +1 -1
  84. data/vendor/assets/build/medias/rubies/examples/shadow.rb +8 -1
  85. data/vendor/assets/build/medias/rubies/examples/sort.rb +7 -4
  86. data/vendor/assets/build/medias/rubies/examples/style.rb +4 -0
  87. data/vendor/assets/build/medias/rubies/examples/touch.rb +50 -7
  88. data/vendor/assets/build/medias/texts/lorem.txt +1 -0
  89. metadata +28 -5
  90. data/vendor/assets/build/medias/rubies/examples/_animation.rb +0 -46
  91. data/vendor/assets/build/medias/rubies/examples/at.rb +0 -17
@@ -37,7 +37,7 @@ Atome.new(
37
37
  Atome.new(
38
38
  { shape: { renderers: default_render, id: :view, type: :shape, parents: [:user_view], children: [],
39
39
  left: 0, right: 0, top: 0, bottom: 0, overflow: :auto,
40
- color: { renderers: default_render, id: :view_color, type: :color, parents: [:view],
40
+ color: { renderers: default_render, id: :view_color, type: :color, attach: [:view],
41
41
  red: 0.15, green: 0.15, blue: 0.15, alpha: 1 } } }
42
42
  )
43
43
 
@@ -18,13 +18,15 @@ class Atome
18
18
  instance_exec(file, &proc) if proc.is_a?(Proc)
19
19
  end
20
20
 
21
- def time_callback(current_time)
21
+ def time_callback(current_time, markers)
22
22
  @atome[:time] = current_time
23
- return unless @at_time[:time] && (current_time.round(1) > @at_time[:time] && @at_time[:used].nil?)
24
-
25
- proc = @at_time[:code]
26
- instance_exec(current_time, &proc) if proc.is_a?(Proc)
27
- @at_time[:used] = true
23
+ markers.each_value do |marker|
24
+ # check if the current time matches the time of the marker, thanks to chat GPT for the example
25
+ if current_time >= marker[:begin] && current_time < marker[:end]
26
+ code_found = marker[:code]
27
+ instance_exec(current_time, &code_found) if code_found.is_a?(Proc)
28
+ end
29
+ end
28
30
  end
29
31
 
30
32
  def drag_start_callback(page_x, page_y, left_val, top_val)
@@ -54,27 +56,32 @@ class Atome
54
56
  instance_exec(atome, &sort_proc) if sort_proc.is_a?(Proc)
55
57
  end
56
58
 
57
- # def play_start_callback(particle_found, value)
58
- # @atome[particle_found] = value
59
- # play_proc = play_start_proc
60
- # anim_proc = animation_start_proc
61
- # instance_exec({ @atome[particle_found] => value }, &play_proc) if play_proc.is_a?(Proc)
62
- # instance_exec({ @atome[particle_found] => value }, &anim_proc) if anim_proc.is_a?(Proc)
63
- # end
64
- #
65
- # def play_active_callback(particle_found, value)
66
- # @atome[particle_found] = value
67
- # play_proc = play_active_proc
68
- # anim_proc = animation_active_proc
69
- # instance_exec({ @atome[particle_found] => value }, &play_proc) if play_proc.is_a?(Proc)
70
- # instance_exec({ @atome[particle_found] => value }, &anim_proc) if anim_proc.is_a?(Proc)
71
- # end
72
- #
73
- # def play_stop_callback(particle_found, value)
74
- # @atome[particle_found] = value
75
- # play_proc = play_end_proc
76
- # anim_proc = animation_end_proc
77
- # instance_exec({ @atome[particle_found] => value }, &play_proc) if play_proc.is_a?(Proc)
78
- # instance_exec({ @atome[particle_found] => value }, &anim_proc) if anim_proc.is_a?(Proc)
79
- # end
59
+ # animation
60
+ def browser_animate_callback(particle_found, value, animation_hash, original_particle, animation_atome)
61
+ anim_proc = animation_hash[:code]
62
+ # we exec the callback bloc from :animate
63
+ instance_exec({ original_particle => value }, &anim_proc) if anim_proc.is_a?(Proc)
64
+ # we exec the callback bloc from :play
65
+ play_proc = animation_atome.play_active_proc
66
+ instance_exec({ @atome[particle_found] => value }, &play_proc) if play_proc.is_a?(Proc)
67
+ # we animate:
68
+ browser_object.style[particle_found] = value if browser_object
69
+ # we update the atome property
70
+ @atome[original_particle] = value
71
+ end
72
+
73
+ def play_start_callback(_particle_found, _start_value, animation_hash, original_particle, atome_found)
74
+ value = animation_hash[:begin][original_particle]
75
+ value = atome_found.atome[original_particle] if value == :self
76
+ start_proc = @animation_start_proc
77
+ @atome[original_particle] = value
78
+ instance_exec({ original_particle => value }, &start_proc) if start_proc.is_a?(Proc)
79
+ end
80
+
81
+ def play_stop_callback(_particle_found, _end_value, animation_hash, original_particle, _atome_found)
82
+ value = animation_hash[:end][original_particle]
83
+ end_proc = @animation_stop_proc
84
+ @atome[original_particle] = value
85
+ instance_exec({ original_particle => value }, &end_proc) if end_proc.is_a?(Proc)
86
+ end
80
87
  end
@@ -7,13 +7,16 @@ module Essentials
7
7
  animation: { type: :animation },
8
8
  element: { type: :element, renderers: [] },
9
9
  box: { renderers: '', id: '', type: :shape, parents: [], children: [], width: 99, height: 99,
10
+ color: { left: 0, top: 0, red: 0.1, green: 0.9, blue: 0.9, alpha: 1, diffusion: :linear },
10
11
  left: 100, top: 100 },
11
12
  circle: { renderers: '', id: '', type: :shape, parents: [], children: [], width: 99, height: 99,
13
+ color: { left: 0, top: 0, red: 0.1, green: 0.9, blue: 0.9, alpha: 1, diffusion: :linear },
12
14
  left: 100, top: 100, smooth: '100%' },
13
15
  shape: { renderers: '', id: '', width: 100, type: :shape, height: 100, left: 100, top: 100,
14
- color: { left: 0, top: 0, z: 0, red: 0.1, green: 0.9, blue: 0.9, alpha: 1, diffusion: :linear },
16
+ color: { left: 0, top: 0, red: 0.1, green: 0.9, blue: 0.9, alpha: 1, diffusion: :linear },
15
17
  generator: :manual },
16
- text: { type: :text, parents: [:view], children: [], visual: { size: 25 },
18
+ text: { renderers: '', id: '',type: :text, parents: [:view], children: [], visual: { size: 25 },
19
+ color: { left: 0, top: 0, red: 0.3, green: 0.3, blue: 0.3, alpha: 1, diffusion: :linear },
17
20
  data: 'this is a text sample', width: 199, height: 33 },
18
21
  drm: { type: :drm },
19
22
  shadow: {}
@@ -24,22 +24,51 @@ class Atome
24
24
  { date: Time.now, location: geolocation }
25
25
  end
26
26
 
27
- def broadcasting(element, value)
28
- return unless @broadcast[:particles]&.include?(element)
29
-
30
- bloc_found = @broadcast[:bloc]
31
- instance_exec(self, element, value, &bloc_found) if bloc_found.is_a?(Proc)
32
- end
33
-
34
27
  def history(property, value)
35
28
  "historize : #{property} #{value}"
36
29
  end
37
30
 
31
+ def broadcasting(altered_particle, value)
32
+ @broadcast.each_value do |particle_monitored|
33
+ if particle_monitored[:particles].include?(altered_particle)
34
+ code_found=particle_monitored[:code]
35
+ instance_exec(self, altered_particle, value, &code_found) if code_found.is_a?(Proc)
36
+ end
37
+ end
38
+ end
39
+
38
40
  public
39
41
 
40
- def monitor(params, &proc_monitoring)
41
- params[:atomes].each do |atome_id|
42
- grab(atome_id).instance_variable_set('@broadcast', { particles: params[:particles], bloc: proc_monitoring })
42
+ def monitor(params=nil, &proc_monitoring)
43
+ if params
44
+ atome[:monitor] ||= {}
45
+ params[:atomes].each do |atome_id|
46
+ target_broadcaster = grab(atome_id).instance_variable_get('@broadcast')
47
+ monitor_id = params[:id] || "monitor#{target_broadcaster.length}"
48
+ atome[:monitor] [monitor_id]=params.merge({code: proc_monitoring})
49
+ target_broadcaster[monitor_id] = { particles: params[:particles], code: proc_monitoring }
50
+ end
51
+ else
52
+ atome[:monitor]
53
+ end
54
+
55
+ end
56
+
57
+ def store_code_bloc(element, &user_proc)
58
+ # TODO : maybe we have to change tis code if we need multiple proc for an particle
59
+ Object.attr_accessor "#{element}_code"
60
+
61
+ instance_variable_set("@#{element}_code", user_proc)
62
+ end
63
+
64
+
65
+ def particles(particles_found = nil)
66
+ if particles_found
67
+ particles_found.each do |particle_found, value_found|
68
+ atome[particle_found] = value_found
69
+ end
70
+ else
71
+ atome
43
72
  end
44
73
  end
45
74
 
@@ -48,6 +77,26 @@ class Atome
48
77
  real_atome[property] << value
49
78
  end
50
79
 
80
+ def add_to_hash(particle, values, &user_proc)
81
+ # we update the holder of any new particle if user pass a bloc
82
+ store_code_bloc(particle, &user_proc) if user_proc
83
+ values.each do |value_id, value|
84
+ @atome[particle][value_id] = value
85
+ end
86
+ end
87
+
88
+ def add_to_array(particle, value, &_user_proc)
89
+ # we update the holder of any new particle if user pass a bloc
90
+ @atome[particle] << value
91
+ end
92
+
93
+ def add(particles, &user_proc)
94
+ particles.each do |particle, value|
95
+ particle_type = Universe.particle_list[particle]
96
+ send("add_to_#{particle_type}", particle, value, &user_proc)
97
+ end
98
+ end
99
+
51
100
  def refresh
52
101
  collapse
53
102
  end
@@ -4,7 +4,7 @@
4
4
  class Universe
5
5
  @atomes = {}
6
6
  @atome_list = []
7
- @particle_list = []
7
+ @particle_list = {}
8
8
  @renderer_list = %i[html browser headless server]
9
9
  @options = {}
10
10
  @sanitizers = {}
@@ -12,8 +12,8 @@ class Universe
12
12
  class << self
13
13
  attr_reader :atomes, :renderer_list, :atome_list, :particle_list
14
14
 
15
- def add_to_particle_list(particle = nil)
16
- instance_variable_get('@particle_list').push(particle)
15
+ def add_to_particle_list(particle = nil, type)
16
+ instance_variable_get('@particle_list')[particle]=type
17
17
  end
18
18
 
19
19
  def add_optional_method(method_name, &method_proc)
@@ -58,10 +58,6 @@ class Universe
58
58
  # and finally the object is 3 as this the third object created by the main server
59
59
  end
60
60
 
61
- # def change_atome_id(prev_id, new_id)
62
- # @atomes[new_id] = @atomes.delete(prev_id)
63
- # end
64
-
65
61
  def delete(id)
66
62
  @atomes.delete(id)
67
63
  end
@@ -11,6 +11,7 @@ class Atome
11
11
  temp_default = Essentials.default_params[atome_type] || {}
12
12
  temp_default[:id] = generated_id
13
13
  temp_default[:parents] = generated_parents
14
+ temp_default[:clones] = []
14
15
  temp_default[:renderers] = generated_render
15
16
  temp_default.merge(params)
16
17
  end
@@ -22,8 +23,6 @@ class Atome
22
23
  generated_id = params[:id] || "#{atome_type}_#{Universe.atomes.length}"
23
24
  generated_parents = params[:parents] || [id.value]
24
25
  params = atome_common(atome_type, generated_id, generated_render, generated_parents, params)
25
- color_generated = sanitize(:color, { parents: [generated_id], red: 0.3, green: 0.3, blue: 0.3 })
26
- params[:color] = color_generated
27
26
  Atome.new({ atome_type => params }, &bloc)
28
27
  end
29
28
 
@@ -34,14 +33,11 @@ class Atome
34
33
  generated_id = params[:id] || "#{atome_type}_#{Universe.atomes.length}"
35
34
  generated_parents = params[:parents] || [id.value]
36
35
  params = atome_common(atome_type, generated_id, generated_render, generated_parents, params)
37
- color_generated = sanitize(:color, { parents: [generated_id], red: 0.6, green: 0.6, blue: 0.6 })
38
- params[:color] = color_generated
39
36
  Atome.new({ atome_type => params }, &bloc)
40
37
  end
41
38
 
42
39
  def image(params = {}, &bloc)
43
40
  default_renderer = Essentials.default_params[:render_engines]
44
-
45
41
  generated_id = params[:id] || "image_#{Universe.atomes.length}"
46
42
  generated_render = params[:renderers] || default_renderer
47
43
  generated_parents = params[:parents] || id.value
@@ -59,8 +55,6 @@ class Atome
59
55
  generated_id = params[:id] || "#{atome_type}_#{Universe.atomes.length}"
60
56
  generated_parents = params[:parents] || [id.value]
61
57
  params = atome_common(atome_type, generated_id, generated_render, generated_parents, params)
62
- color_generated = sanitize(:color, { parents: [generated_id], red: 0.9, green: 0.9, blue: 0.9 })
63
- params[:color] = color_generated
64
58
  Atome.new({ atome_type => params }, &bloc)
65
59
  end
66
60
 
@@ -85,4 +79,14 @@ class Atome
85
79
  params = temp_default.merge(params)
86
80
  Atome.new({ image: params }, &bloc)
87
81
  end
82
+
83
+ def animation(params = {}, &bloc)
84
+ default_renderer = Essentials.default_params[:render_engines]
85
+ atome_type = :animation
86
+ generated_render = params[:renderers] || default_renderer
87
+ generated_id = params[:id] || "#{atome_type}_#{Universe.atomes.length}"
88
+ generated_parents = params[:parents] || []
89
+ params = atome_common(atome_type, generated_id, generated_render, generated_parents, params)
90
+ Atome.new({ atome_type => params }, &bloc)
91
+ end
88
92
  end
@@ -10,7 +10,7 @@ def parents(_val) end
10
10
 
11
11
  generator = Genesis.generator
12
12
 
13
- generator.build_render_method(:browser_shape) do
13
+ generator.build_render(:browser_shape) do
14
14
  @browser_type = :div
15
15
  id_found = @atome[:id]
16
16
  DOM do
@@ -19,7 +19,7 @@ generator.build_render_method(:browser_shape) do
19
19
  @browser_object = BrowserHelper.browser_document[id_found]
20
20
  end
21
21
 
22
- generator.build_render_method(:browser_color) do |_value|
22
+ generator.build_render(:browser_color) do |_value|
23
23
  @browser_type = :style
24
24
  id_found = @atome[:id]
25
25
  type_found = @atome[:type]
@@ -36,7 +36,7 @@ generator.build_render_method(:browser_color) do |_value|
36
36
  @browser_object = BrowserHelper.browser_document[id_found]
37
37
  end
38
38
 
39
- generator.build_render_method(:browser_shadow) do |_value|
39
+ generator.build_render(:browser_shadow) do |_value|
40
40
  @browser_type = :style
41
41
  id_found = @atome[:id]
42
42
  type_found = @atome[:type]
@@ -58,7 +58,7 @@ generator.build_render_method(:browser_shadow) do |_value|
58
58
  @browser_object = BrowserHelper.browser_document[id_found]
59
59
  end
60
60
 
61
- generator.build_render_method(:browser_image) do |_user_prc|
61
+ generator.build_render(:browser_image) do |_user_prc|
62
62
  @browser_type = :div
63
63
  id_found = @atome[:id]
64
64
  DOM do
@@ -67,7 +67,7 @@ generator.build_render_method(:browser_image) do |_user_prc|
67
67
  @browser_object = BrowserHelper.browser_document[id_found]
68
68
  end
69
69
 
70
- generator.build_render_method(:browser_text) do |_value, _user_proc|
70
+ generator.build_render(:browser_text) do |_value, _user_proc|
71
71
  id_found = @atome[:id]
72
72
  DOM do
73
73
  div(id: id_found).atome.text
@@ -76,7 +76,7 @@ generator.build_render_method(:browser_text) do |_value, _user_proc|
76
76
  @browser_type = :div
77
77
  end
78
78
 
79
- generator.build_render_method(:browser_web) do
79
+ generator.build_render(:browser_web) do
80
80
  @browser_type = :web
81
81
  id_found = @atome[:id]
82
82
  DOM do
@@ -87,7 +87,7 @@ generator.build_render_method(:browser_web) do
87
87
  @browser_object.attributes[:allowfullscreen] = true
88
88
  end
89
89
 
90
- generator.build_render_method(:browser_video) do |_value, _user_proc|
90
+ generator.build_render(:browser_video) do |_value, _user_proc|
91
91
  @browser_type = :div
92
92
  id_found = @atome[:id]
93
93
  DOM do
@@ -8,11 +8,13 @@ require 'atome/renderers/browser/material'
8
8
  require 'atome/renderers/browser/spatial'
9
9
  require 'atome/renderers/browser/atome'
10
10
  require 'atome/renderers/browser/utility'
11
+ require 'atome/renderers/browser/time'
11
12
  require 'atome/renderers/browser/helpers/browser_helper'
12
13
  require 'atome/renderers/browser/helpers/animation_helper'
13
14
  require 'atome/renderers/browser/helpers/color_helper'
14
15
  require 'atome/renderers/browser/helpers/drag_helper'
15
16
  require 'atome/renderers/browser/helpers/effect_helper'
17
+ require 'atome/renderers/browser/helpers/event_helper'
16
18
  require 'atome/renderers/browser/helpers/image_helper'
17
19
  require 'atome/renderers/browser/helpers/shadow_helper'
18
20
  require 'atome/renderers/browser/helpers/shape_helper'
@@ -21,7 +23,9 @@ require 'atome/renderers/browser/helpers/video_helper'
21
23
  require 'atome/renderers/browser/helpers/web_helper'
22
24
 
23
25
  class Atome
24
- attr_accessor :browser_object
26
+ attr_accessor 'browser_object'
25
27
  end
26
28
 
27
- AtomeJS=`atomeJS`
29
+ def atome_js
30
+ `atomeJS`
31
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  generator = Genesis.generator
4
4
 
5
- generator.build_render_method(:browser_smooth) do |value|
5
+ generator.build_render(:browser_smooth) do |value|
6
6
  format_params = case value
7
7
  when Array
8
8
  properties = []
@@ -18,6 +18,6 @@ generator.build_render_method(:browser_smooth) do |value|
18
18
  @browser_object.style['border-radius'] = format_params
19
19
  end
20
20
 
21
- generator.build_render_method(:browser_blur) do |value|
21
+ generator.build_render(:browser_blur) do |value|
22
22
  BrowserHelper.send("browser_blur_#{@browser_type}", @browser_object, value, @atome)
23
23
  end
@@ -2,20 +2,20 @@
2
2
 
3
3
  generator = Genesis.generator
4
4
 
5
- generator.build_render_method(:browser_touch) do |_value, proc|
6
- @browser_object.on :click do |e|
7
- instance_exec(e, &proc) if proc.is_a?(Proc)
8
- end
5
+ generator.build_render(:browser_touch) do |value, proc|
6
+ atome_id = @browser_object.attribute(:id)
7
+ BrowserHelper.send("browser_touch_#{value}", atome_id, proc)
8
+ # end
9
9
  end
10
10
 
11
- generator.build_render_method(:browser_play) do |value, proc|
11
+ generator.build_render(:browser_play) do |value, proc|
12
12
  # first we reinit the 'at' event so the condition will be met again
13
- @at_time[:used] = nil
13
+ # @at_time[:used] = nil
14
14
  @browser_object.currentTime = value if value != true
15
15
  BrowserHelper.send("browser_play_#{@atome[:type]}", value, @browser_object, @atome, self, proc)
16
16
  end
17
17
 
18
- generator.build_render_method(:browser_time) do |value = nil, _proc|
18
+ generator.build_render(:browser_time) do |value = nil, _proc|
19
19
  if value
20
20
  @browser_object.currentTime = value
21
21
  else
@@ -23,23 +23,23 @@ generator.build_render_method(:browser_time) do |value = nil, _proc|
23
23
  end
24
24
  end
25
25
 
26
- generator.build_render_method(:browser_pause) do |_value, proc|
26
+ generator.build_render(:browser_pause) do |_value, proc|
27
27
  instance_exec(@browser_object.currentTime, &proc) if proc.is_a?(Proc)
28
28
  @browser_object.pause
29
29
  end
30
30
 
31
- generator.build_render_method(:on) do |value, proc|
31
+ generator.build_render(:on) do |value, proc|
32
32
  @browser_object.on(value) do |e|
33
33
  instance_exec(e, &proc) if proc.is_a?(Proc)
34
34
  end
35
35
  end
36
36
 
37
- generator.build_render_method(:fullscreen) do |_value, _proc|
37
+ generator.build_render(:fullscreen) do |_value, _proc|
38
38
  atome_id = atome[:id]
39
- AtomeJS.JS.fullscreen(atome_id)
39
+ atome_js.JS.fullscreen(atome_id)
40
40
  end
41
41
 
42
- generator.build_render_method(:mute) do |value, _proc|
42
+ generator.build_render(:mute) do |value, _proc|
43
43
  if value
44
44
  browser_object.muted
45
45
  else
@@ -47,18 +47,24 @@ generator.build_render_method(:mute) do |value, _proc|
47
47
  end
48
48
  end
49
49
 
50
- generator.build_render_method(:browser_at) do |at, proc|
51
- @at_time = { code: proc }.merge(at)
52
- end
53
-
54
- generator.build_render_method(:browser_drag) do |options, proc|
50
+ generator.build_render(:browser_drag) do |options, proc|
55
51
  options.each do |method, params|
56
52
  atome_id = @atome[:id]
57
53
  BrowserHelper.send("browser_drag_#{method}", params, atome_id, self, proc)
58
54
  end
59
55
  end
60
56
 
61
- generator.build_render_method(:browser_sort) do |options, _proc|
62
- AtomeJS.JS.sort(options, @atome[:id], self)
57
+ generator.build_render(:browser_sort) do |options, _proc|
58
+ atome_js.JS.sort(options, @atome[:id], self)
63
59
  end
64
60
 
61
+ # TODO: for now unbind remove all touch event we should remove only the targeted one (store proc and restore it)
62
+ generator.build_render(:browser_unbind) do |options, _proc|
63
+ id_found = self.atome[:id]
64
+ `
65
+ const el = document.getElementById(#{id_found});
66
+ interact('#'+#{id_found}).unset(#{options});
67
+ `
68
+ end
69
+
70
+
@@ -2,10 +2,10 @@
2
2
 
3
3
  generator = Genesis.generator
4
4
 
5
- generator.build_render_method(:browser_width) do |value|
5
+ generator.build_render(:browser_width) do |value|
6
6
  @browser_object.style[:width] = "#{value}px"
7
7
  end
8
8
 
9
- generator.build_render_method(:browser_height) do |value|
9
+ generator.build_render(:browser_height) do |value|
10
10
  @browser_object.style[:height] = "#{value}px"
11
11
  end
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ # for browser rendering
4
+ module BrowserHelper
5
+ def self.anim_convertor(value)
6
+ { left: [:left, "#{value}px"], right: [:right, "#{value}px"], top: [:top, "#{value}px"],
7
+ bottom: [:bottom, "#{value}px"], smooth: ['border-radius', "#{value}px"],
8
+ left_add: ['transform', "translateX(#{value}px)"],
9
+ right_add: ['transform', "translateY(#{value}px)"],
10
+ width: [:width, "#{value}px"], height: [:height, "#{value}px"] }
11
+ end
12
+
13
+ def self.anim_value_analysis(value, particle_found, atome_found)
14
+ case value
15
+ when :self
16
+ # this case mean the user use the current atome so we get the particle value of the atome
17
+ value = atome_found.atome[particle_found]
18
+ when Integer
19
+ value
20
+ else
21
+ # this case mean the user try to pass an id so we get the particle value of the atome
22
+ value = grab(value).atome[particle_found]
23
+ value
24
+ end
25
+ value
26
+ end
27
+
28
+ def self.send_anim_to_js(animation, atome_hash, atome_found, atome_id, animation_atome)
29
+ animated_particle = animation[0]
30
+ start_value = animation[1]
31
+ end_value = animation[2]
32
+ original_particle = animation[3]
33
+ atome_js.JS.animate(animated_particle, atome_hash[:duration], atome_hash[:damping], atome_hash[:ease],
34
+ atome_hash[:mass], atome_hash[:repeat], atome_hash[:stiffness], atome_hash[:velocity],
35
+ start_value, end_value, atome_id, atome_found, atome_hash, original_particle, animation_atome)
36
+ end
37
+
38
+ def self.sanitize_anim_params(value, particle_found, atome_hash, atome_found, atome_id, animation_atome)
39
+ start_value = anim_value_analysis(value, particle_found, atome_found)
40
+ start_value = BrowserHelper.anim_convertor(start_value)[particle_found][1]
41
+ end_value = anim_value_analysis(atome_hash[:end][particle_found], particle_found, atome_found)
42
+ end_value = BrowserHelper.anim_convertor(end_value)[particle_found][1]
43
+ animated_particle = BrowserHelper.anim_convertor(value)[particle_found][0]
44
+ # animation is a stupid array to satisfy rubocop stupidity
45
+ animation = [animated_particle, start_value, end_value, particle_found]
46
+ send_anim_to_js(animation, atome_hash, atome_found, atome_id, animation_atome)
47
+ end
48
+
49
+ def self.anim_pop_motion_converter(atome_hash, atome_found, atome_id, animation_atome)
50
+ atome_hash[:dampingRatio] = atome_hash.delete(:damping)
51
+ atome_hash[:begin].each do |particle_found, value|
52
+ sanitize_anim_params(value, particle_found, atome_hash, atome_found, atome_id, animation_atome)
53
+ end
54
+ end
55
+
56
+ def self.begin_animation(atome_hash, atome_found, atome_id, animation_atome)
57
+ anim_pop_motion_converter(atome_hash, atome_found, atome_id, animation_atome)
58
+ end
59
+
60
+ def self.browser_play_animation(_options, _browser_object, atome_hash, animation_atome, proc)
61
+ atome_hash[:targets] = [:eDen] unless atome_hash[:targets]
62
+ animation_atome.play_active_proc = proc
63
+ atome_hash[:targets].each do |target|
64
+ atome_found = grab(target)
65
+ atome_id = atome_found.atome[:id]
66
+ begin_animation(atome_hash, atome_found, atome_id, animation_atome)
67
+ end
68
+ end
69
+ end
@@ -14,5 +14,4 @@ module BrowserHelper
14
14
  def self.browser_attach_style(parents, _html_object, atome)
15
15
  browser_document[parents].add_class(atome[:id])
16
16
  end
17
-
18
17
  end
@@ -2,7 +2,6 @@
2
2
 
3
3
  # for browser rendering
4
4
  module BrowserHelper
5
-
6
5
  def self.browser_colorize_color(color_updated, atome)
7
6
  `document.getElementById(#{atome[:id]}).sheet.cssRules[0].style.backgroundColor = #{color_updated}`
8
7
  end
@@ -31,5 +30,4 @@ module BrowserHelper
31
30
  def self.browser_bottom_color(_value, _browser_object, _atome)
32
31
  puts 'code to write when implementing gradient'
33
32
  end
34
-
35
33
  end
@@ -5,28 +5,28 @@
5
5
  module BrowserHelper
6
6
  def self.browser_drag_move(params, atome_id, atome, proc)
7
7
  atome.drag_move_proc = proc
8
- AtomeJS.JS.drag(params, atome_id, atome)
8
+ atome_js.JS.drag(params, atome_id, atome)
9
9
  end
10
10
 
11
11
  def self.browser_drag_lock(params, atome_id, atome, _proc)
12
- AtomeJS.JS.lock(params, atome_id, atome)
12
+ atome_js.JS.lock(params, atome_id, atome)
13
13
  end
14
14
 
15
15
  def self.browser_drag_remove(params, atome_id, atome, _proc)
16
16
  params = params != true
17
- AtomeJS.JS.remove(params, atome_id, atome)
17
+ atome_js.JS.remove(params, atome_id, atome)
18
18
  end
19
19
 
20
20
  def self.browser_drag_snap(params, atome_id, atome, _proc)
21
- AtomeJS.JS.snap(params.to_n, atome_id, atome)
21
+ atome_js.JS.snap(params.to_n, atome_id, atome)
22
22
  end
23
23
 
24
24
  def self.browser_drag_inertia(params, atome_id, atome, _proc)
25
- AtomeJS.JS.inertia(params, atome_id, atome)
25
+ atome_js.JS.inertia(params, atome_id, atome)
26
26
  end
27
27
 
28
28
  def self.browser_drag_constraint(params, atome_id, atome, _proc)
29
- AtomeJS.JS.constraint(params.to_n, atome_id, atome)
29
+ atome_js.JS.constraint(params.to_n, atome_id, atome)
30
30
  end
31
31
 
32
32
  def self.browser_drag_start(_params, _atome_id, atome, proc)
@@ -2,6 +2,7 @@
2
2
 
3
3
  # for browser rendering
4
4
  module BrowserHelper
5
+
5
6
  def self.browser_blur_style(_browser_object, value, atome)
6
7
  b_left = "#{atome[:left]}px"
7
8
  b_top = "#{atome[:top]}px"