atome 0.5.7.1.4 → 0.5.7.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f381b9c8d4123904b8ee97d71b0c6e1f78dc8143eb34b953670a273bd29fad10
4
- data.tar.gz: d517e9cf6a13592fda0352bd5aa55c64ff30ffd4a0daab3776ce420c3ec0b970
3
+ metadata.gz: c05197d3eeae9cee5e96894387b264fa64b3f0436c513d03c9bee7edd7edc7aa
4
+ data.tar.gz: d21606ce307a9c85eca0207d95b502572bf287668c360228230d917672306f53
5
5
  SHA512:
6
- metadata.gz: bd812f2209652f5f4e8b24a7d16214cedfc1e8ae5be2149d7f106393cef7f810908f61fbeb33a7854f0bbaab607e63b7d5c46c72c908e27a9cf799e27dd5380e
7
- data.tar.gz: 77b884af5e674424861d278dcbd803f094d37600d2bf990cfbd14f041c9103e5cfbd392b772b2065485a5e54b2e146741f7f1654ae96272087d9ab9528eaeff5
6
+ metadata.gz: 69e1cc8e30ca124fa5402bd30ea6cb302bbef0b7aa90cad60cbcf9c80cef49bfefc2dc1ba35551f5ecc8d604154fd62f7c21dc3ca6340902d1a6a2c390d18aae
7
+ data.tar.gz: 4a3b520343611c272ea18853bf5449af84e35adbc8153538b1c3a969dcbaaccbe60375ba08ac97eb70e27b8cdf57ba38d0eb1f1d8d5a9ac998d80832f4a44476
data/atome.gemspec CHANGED
@@ -52,7 +52,7 @@ Gem::Specification.new do |spec|
52
52
  spec.require_paths = ['lib']
53
53
 
54
54
 
55
- spec.add_runtime_dependency 'artoo', '~> 1.8.2'
55
+ # spec.add_runtime_dependency 'artoo', '~> 1.8.2'
56
56
  # spec.add_runtime_dependency 'arduino_firmata', '~> 0.3'
57
57
  # spec.add_runtime_dependency 'eVe', '~> 0.1.0'
58
58
  spec.add_runtime_dependency 'eventmachine', '~> 1.2.7'
@@ -90,7 +90,7 @@ Gem::Specification.new do |spec|
90
90
  spec.add_runtime_dependency 'wdm', '>= 0.1.0' if Gem.win_platform?
91
91
 
92
92
  # patch because guard have bad dependency
93
- # spec.add_runtime_dependency 'pry', '>= 0.14.2'
93
+ spec.add_runtime_dependency 'pry', '>= 0.14.2'
94
94
 
95
95
  # Uncomment to register a new dependency of your gem
96
96
  # spec.add_dependency "example-gem", "~> 1.0"
@@ -642,7 +642,53 @@ class Object
642
642
  end
643
643
  end
644
644
 
645
+ def above(item, margin)
646
+ pos = item.to_px(:bottom) + item.height + margin
647
+ if item.display == :none
648
+ 33
649
+ else
650
+ pos
651
+ end
652
+ end
653
+
654
+ def below(item, margin)
655
+ pos = item.to_px(:top) + item.to_px(:height) + margin
656
+ if item.display == :none
657
+ 0
658
+ else
659
+ pos
660
+ end
661
+
662
+ end
663
+
664
+ def after(item, margin)
665
+ left_f = if item.left.instance_of?(Integer)
666
+ item.left
667
+ else
668
+ item.to_px(:left)
669
+ end
645
670
 
671
+ width_f = if item.width.instance_of?(Integer)
672
+ item.width
673
+ else
674
+ item.to_px(:width)
675
+ end
676
+ pos = left_f + width_f + margin
677
+ if item.display == :none
678
+ 0
679
+ else
680
+ pos
681
+ end
682
+ end
683
+
684
+ def before(item, margin)
685
+ pos = item.to_px(:right) + item.width + margin
686
+ if item.display == :none
687
+ 0
688
+ else
689
+ pos
690
+ end
691
+ end
646
692
 
647
693
 
648
694
  end
@@ -687,6 +733,8 @@ class CssProxy
687
733
  bloc.call(parsed)
688
734
  end
689
735
 
736
+
737
+
690
738
  end
691
739
 
692
740
 
@@ -334,11 +334,33 @@ new({ particle: :overflow, category: :event, type: :boolean }) do |params, bloc|
334
334
  params
335
335
 
336
336
  end
337
- new({ particle: :animate, category: :event, type: :hash }) do |params|
337
+
338
+ class Atome
339
+ def animation_callback(proc_sub_category, value=nil)
340
+ # puts "#{p◊roc_sub_category}"
341
+ proc_found = @animate_code[proc_sub_category]
342
+ # puts proc_found
343
+ instance_exec(value,&proc_found) if proc_found.is_a?(Proc)
344
+ end
345
+ end
346
+
347
+ new({ particle: :animate, category: :event, type: :hash }) do |params, proc|
338
348
  if params.instance_of? Hash
339
349
  params = { from: 0, to: 300, duration: 1000 }.merge(params)
340
350
  else
341
351
  params = { from: 0, to: 300, duration: 1000 }
342
352
  end
343
- html.play_animation(params)
353
+ # @animate_code["#{params[:particle]}"] = proc
354
+ if params[:end]
355
+ @animate_code["#{params[:end]}_end"] = proc
356
+ else
357
+ @animate_code||= {}
358
+ @animate_code["#{params[:particle]}"] = proc
359
+ end
360
+
361
+ params
362
+ end
363
+
364
+ new ({ after: :animate }) do |params|
365
+ html.animate(params) unless params[:end] || params[:start]
344
366
  end
@@ -350,18 +350,8 @@ class Atome
350
350
 
351
351
  def js_callback(id, particle, value, sub = nil)
352
352
  current_atome = grab(id)
353
- # # alert current_atome.instance_variable_get('@record_code')
354
353
  proc_found = current_atome.instance_variable_get("@#{particle}_code")[particle.to_sym]
355
- # proc_found= current_atome.instance_variable_get("@record_code")[:record]
356
- # # alert particle.class
357
- # # alert proc_found.class
358
- # proc_found.call
359
354
  instance_exec(value, &proc_found) if proc_found.is_a?(Proc)
360
- # # # puts "params to be exec #{id}, #{particle}, #{value}, #{sub}"
361
- # alpha= grab(:the_big_box)
362
- # proc_found= alpha.instance_variable_get("@record_code")[:record]
363
- # proc_found.call
364
-
365
355
  end
366
356
 
367
357
  # def callback(data)
data/lib/atome/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  # return atome version
4
4
  class Atome
5
- VERSION = '0.5.7.1.4'
5
+ VERSION = '0.5.7.1.6'
6
6
  end
data/lib/atome.rb CHANGED
@@ -37,4 +37,5 @@ require 'atome/utilities/sanitizer'
37
37
  require 'atome/genesis/presets'
38
38
  require 'atome/genesis/sparkle'
39
39
  require 'molecules/init'
40
- require 'molecules/intuition/utillities'
40
+ require 'molecules/intuition/utilities'
41
+ require 'molecules/intuition/tools'
@@ -36,4 +36,5 @@ require_relative './atome/utilities/sanitizer'
36
36
  require_relative './atome/genesis/presets'
37
37
  require_relative './atome/genesis/sparkle'
38
38
  require_relative './molecules/init'
39
- require_relative './molecules/intuition/utillities'
39
+ require_relative './molecules/intuition/utilities'
40
+ require_relative './molecules/intuition/tools'
@@ -0,0 +1,344 @@
1
+ # frozen_string_literal: true
2
+
3
+
4
+
5
+ size = 33
6
+ smooth = 3
7
+ shadow({
8
+ id: :tool_shade,
9
+ left: 3, top: 3, blur: 3,
10
+ invert: false,
11
+ red: 0, green: 0, blue: 0, alpha: 0.6
12
+ })
13
+
14
+ color({ id: :tool_inactive_color, red: 1, green: 1, blue: 1, alpha: 0.12 })
15
+ color({ id: :tool_active_color, red: 1, green: 1, blue: 1, alpha: 0.3 })
16
+ border({ id: :tool_box_border, thickness: 1, red: 1, green: 1, blue: 1, alpha: 0.06, pattern: :solid, inside: true })
17
+ # Tool's style object container below
18
+ element({ aid: :toolbox_style, id: :toolbox_style, data: {
19
+ color: :gray,
20
+ size: size,
21
+ smooth: smooth
22
+ } })
23
+
24
+ class Atome
25
+ class << self
26
+ def init_intuition
27
+ Atome.start_click_analysis
28
+ root = Universe.tools_root
29
+ root.each_with_index do |root_tool, index|
30
+ tools_scheme = Universe.tools[root_tool]
31
+ A.build_tool({ name: root_tool, scheme: tools_scheme, index: index })
32
+ end
33
+ end
34
+
35
+ def selection
36
+ grab(Universe.current_user).selection.collect
37
+ end
38
+
39
+ def activate_click_analysis
40
+
41
+ # the condition below avoid touchdown analysis accumulation
42
+ unless @click_analysis_active
43
+ # this method analyse all object under the touchdown to find the first user objet and return it's id
44
+ @click_analysis = lambda { |native_event|
45
+ # the instance variable below check if we can apply tool (cf: if the atome we don't want to apply tool)
46
+ if Universe.allow_tool_operations
47
+ event = Native(native_event)
48
+ x = event[:clientX]
49
+ y = event[:clientY]
50
+ elements = JS.global[:document].elementsFromPoint(x, y)
51
+ elements.to_a.each do |atome_touched|
52
+ id_found = atome_touched[:id].to_s
53
+ atome_found = grab(id_found)
54
+ unless atome_found && atome_found.tag[:system]
55
+
56
+ # if atome_found
57
+ Universe.active_tools.each do |tool|
58
+ apply_tool(tool, atome_found, event)
59
+ end
60
+ break
61
+ end
62
+ end
63
+ else
64
+ Universe.allow_tool_operations = true
65
+ end
66
+ }
67
+ @click_analysis_active = true
68
+ end
69
+
70
+ end
71
+
72
+ def de_activate_click_analysis
73
+ @click_analysis = nil
74
+ @click_analysis_active = false
75
+ end
76
+
77
+ def start_click_analysis
78
+ @click_analysis_active = false
79
+ JS.global[:document].addEventListener('mouseup') do |native_event|
80
+ Atome.instance_exec(native_event, &@click_analysis) if @click_analysis.is_a?(Proc)
81
+ end
82
+ end
83
+
84
+ def alteration(current_tool, tool_actions, atome_touched, a_event)
85
+ if atome_touched
86
+ storage_allowed = Universe.allow_localstorage
87
+ action_found = tool_actions[:action]
88
+ pre = tool_actions[:pre]
89
+ post = tool_actions[:post]
90
+ params = { current_tool: current_tool, atome_touched: atome_touched, event: a_event }
91
+ action_found.each do |part, val|
92
+ Universe.allow_localstorage = false
93
+ #################################
94
+ touch_found = atome_touched.touch
95
+ touch_procs=atome_touched.instance_variable_get("@touch_code")
96
+ resize_found = atome_touched.resize
97
+ resize_procs=atome_touched.instance_variable_get("@resize_code")
98
+ current_tool.data[:prev_states][atome_touched] = {events: { touch: touch_found, resize: resize_found },
99
+ procs: {touch_code: touch_procs, resize_code: resize_procs } }
100
+ #################################
101
+ current_tool.instance_exec(params, &pre) if pre.is_a? Proc
102
+ Universe.allow_localstorage = storage_allowed
103
+ if current_tool.data[:allow_alteration]
104
+ atome_touched.send(part, val)
105
+ current_tool.data[:treated] << atome_touched
106
+ end
107
+ current_tool.instance_exec(params, &post) if post.is_a? Proc
108
+ end
109
+
110
+ end
111
+ end
112
+
113
+ def creation(current_tool, tool_actions, atome_touched, a_event)
114
+ # we store prev_local_storage prior to lock it to prevent unwanted logs
115
+ # prev_local_storage=Universe.allow_localstorage()
116
+ storage_allowed = Universe.allow_localstorage
117
+ Universe.allow_localstorage = false
118
+
119
+ action_found = tool_actions[:action]
120
+ pre = tool_actions[:pre]
121
+ post = tool_actions[:post]
122
+ params = { current_tool: current_tool, atome_touched: atome_touched, event: a_event }
123
+
124
+ action_found.each do |atome, particle|
125
+ current_tool.instance_exec(params, &pre) if pre.is_a? Proc
126
+ temp_val = particle.merge({ resize: true, drag: true, top: a_event[:pageY].to_i, left: a_event[:pageX].to_i })
127
+ if current_tool.data[:allow_creation]
128
+ # uncomment the line below if you want to attach to current atome
129
+ if atome_touched
130
+ new_atome = atome_touched.send(atome, temp_val)
131
+ else
132
+ new_atome = grab(:view).send(atome, temp_val)
133
+ end
134
+ # current_tool.data[:treated] << new_atome
135
+ current_tool.data[:created] << new_atome
136
+ params.delete(:atome_touched)
137
+ params[new_atome: new_atome]
138
+ Universe.allow_localstorage = [atome]
139
+ Universe.historicize(new_atome.aid, :write, atome, particle)
140
+ end
141
+
142
+ end
143
+ current_tool.instance_exec(params, &post) if post.is_a? Proc
144
+ # we restore prev_local_storage to allow logs of drag and resize ...
145
+ Universe.allow_localstorage = storage_allowed
146
+ end
147
+
148
+ def apply_tool(tool, atome_touched, a_event)
149
+ current_tool = grab(tool)
150
+ tool_actions = current_tool.data
151
+ method_found = tool_actions[:method]
152
+ unless method_found
153
+ method_found = :alteration
154
+ tool_actions[:action] = { noop: true }
155
+ current_tool.data = tool_actions
156
+ end
157
+
158
+ send(method_found, current_tool, tool_actions, atome_touched, a_event)
159
+ end
160
+
161
+ end
162
+
163
+ def noop(_p)
164
+ # this method is used by tools when no treatment is needed
165
+ end
166
+
167
+ def set_action_on_touch(&action)
168
+ @touch_action = action
169
+
170
+ end
171
+
172
+ def remove_get_atome_on_touch
173
+ @touch_action = nil
174
+ end
175
+
176
+ def build_tool(params)
177
+ label = params[:name]
178
+ tool_name = "#{params[:name]}_tool"
179
+ index = params[:index]
180
+ orientation_wanted = :sn
181
+ tool_scheme = params[:scheme]
182
+ color({ id: :active_tool_col, alpha: 1, red: 1, green: 1, blue: 1 })
183
+ color({ id: :inactive_tool_col, alpha: 0.6 })
184
+ grab(:intuition).storage[:tool_open] ||= []
185
+ grab(:intuition).storage[:tool_open] << tool_name
186
+ size = grab(:toolbox_style).data[:size]
187
+ smooth = grab(:toolbox_style).data[:smooth]
188
+ case orientation_wanted
189
+ when :sn
190
+ top = :auto
191
+ bottom = index * (size + 3)
192
+ left = 0
193
+ right = :auto
194
+ when :ns
195
+ when :ew
196
+ when :we
197
+ else
198
+ #
199
+ end
200
+
201
+ # tool creation
202
+ if tool_scheme[:creation]
203
+ action = tool_scheme[:creation]
204
+ method = :creation
205
+ end
206
+ if tool_scheme[:alteration]
207
+ action = tool_scheme[:alteration]
208
+ method = :alteration
209
+ end
210
+
211
+ tool = grab(:intuition).box({ id: tool_name,
212
+ tag: { system: true },
213
+ # orientation: orientation_wanted,
214
+ top: top,
215
+ bottom: bottom,
216
+ left: left,
217
+ right: right,
218
+ width: size,
219
+ height: size,
220
+ smooth: smooth,
221
+ apply: [:tool_inactive_color, :tool_box_border, :tool_shade],
222
+ state: :closed,
223
+ data: { method: method,
224
+ action: action,
225
+ allow_alteration: true,
226
+ allow_creation: true,
227
+ # activation: tool_scheme[:activation],
228
+ # inactivation: tool_scheme[:inactivation], zone: tool_scheme[:zone],
229
+ post: tool_scheme[:post],
230
+ pre: tool_scheme[:pre],
231
+ }
232
+
233
+ })
234
+ tool.vector({ tag: { system: true }, left: 9, top: :auto, bottom: 9, width: 18, height: 18, id: "#{tool_name}_icon" })
235
+ tool.text({ tag: { system: true }, data: label, component: { size: 9 }, color: :grey, id: "#{tool_name}_label" })
236
+ code_for_zone = tool_scheme[:zone]
237
+ tool.instance_exec(tool, &code_for_zone) if code_for_zone.is_a? Proc
238
+ tool.touch(true) do
239
+ # we add all specific tool actions to @tools_actions_to_exec hash
240
+ # we set allow_tool_operations to false to ignore tool operation when clicking on a tool
241
+ Universe.allow_tool_operations = false
242
+ # we create the creation_layer if not already exist
243
+ tick(tool_name)
244
+ # active code exec
245
+ if tick[tool_name] == 1 # first click
246
+ events_allow = [:top, :left, :right, :bottom, :width, :height]
247
+ alterations = tool_scheme[:alteration] ? tool_scheme[:alteration].keys : []
248
+ creations = tool_scheme[:creation] ? tool_scheme[:creation].keys : []
249
+ prev_auth = Universe.allow_localstorage ||= []
250
+ storage_allowed = events_allow.concat(alterations).concat(creations).concat(prev_auth).uniq
251
+ Universe.allow_localstorage = storage_allowed
252
+ # we set edit mode to true (this allow to prevent user atome to respond from click)
253
+ Universe.edit_mode = true
254
+ Universe.active_tools << tool_name
255
+ # init the tool
256
+ tool.data[:treated] = []
257
+ tool.data[:created] = []
258
+ tool.data[:prev_states] = {}
259
+ # generic behavior
260
+ tool.apply(:active_tool_col)
261
+ # activation code
262
+ activation_code = tool_scheme[:activation]
263
+ tool.instance_exec(&activation_code) if activation_code.is_a? Proc
264
+ # below we the particles of selected atomes to feed tools values
265
+ # possibility 1 (pipette like):
266
+ # now we get the values from selected atomes
267
+ Atome.selection.each do |atome_id_to_treat|
268
+ tool.data[:action].each do |particle_req, value_f|
269
+ unless Universe.atome_preset
270
+ value_found = grab(atome_id_to_treat).send(particle_req)
271
+ if value_found
272
+ tool.data[:action][particle_req] = value_found
273
+ else
274
+ end
275
+ end
276
+ end
277
+ end
278
+ # possibility 2 (immediate apply):
279
+ allow_creation = tool.data[:allow_creation]
280
+ allow_alteration = tool.data[:allow_alteration]
281
+ Atome.selection.each do |atome_id_to_treat|
282
+ atome_found = grab(atome_id_to_treat)
283
+ event = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 }
284
+ Atome.apply_tool(tool_name, atome_found, event)
285
+ end unless tool_name.to_sym == :select_tool || !allow_creation || !allow_alteration
286
+
287
+ # activate tool analysis test
288
+ Atome.activate_click_analysis
289
+ else
290
+ Universe.allow_localstorage = false
291
+ # when closing delete tools action from tool_actions_to_exec
292
+ Universe.active_tools.delete(tool_name)
293
+ # we check if all tools are inactive if so we set edit_mode to false
294
+ if Universe.active_tools.length == 0
295
+ Atome.de_activate_click_analysis
296
+ Universe.edit_mode = false
297
+ end
298
+
299
+ inactivation_code = tool_scheme[:inactivation]
300
+ tool.instance_exec(tool.data, &inactivation_code) if inactivation_code.is_a? Proc
301
+ # end if tool_content && tool_content[:inactive]
302
+
303
+ # generic behavior
304
+ # we remove touch and resize binding on newly created atomes
305
+ tool.apply(:inactive_tool_col)
306
+ tool.data[:created].each do |new_atome|
307
+ new_atome.drag(false)
308
+ new_atome.resize(:remove)
309
+ end
310
+ ################################
311
+ # we restore prev touch and resize
312
+ tool.data[:prev_states].each do |atome_f, prev_par|
313
+ puts prev_par
314
+ # params[:events].each do |part_f, val_f|
315
+ # # alert "@#{part_f}, #{part_f}"
316
+ # atome_f.send(part_f, val_f)
317
+ # end
318
+ # alert "--> params : #{params[:events]}"
319
+ # alert "--> procs : #{params[:procs][params[:events]]}"
320
+ # atome_f.touch(false)
321
+ # atome_f.touch(true) do
322
+ # alert :kool
323
+ # end
324
+ # alert params[:procs]
325
+ # params[:procs].each do |var_n, procs_f|
326
+ # # procs_f.each do |action_f, proc|
327
+ # # # puts "#{var_n}==> #{action_f}, #{proc}"
328
+ # # end
329
+ # puts "==> #{var_n}, #{proc_f}"
330
+ # # atome_f.instance_variable_set("@#{var_n}", proc_f)
331
+ # end
332
+ # atome_f.touch(false)
333
+ # alert "#{atome_f.touch} : #{atome_f.instance_variable_get("@touch_code")}"
334
+ end
335
+
336
+ # atome_f.touch(touch_found)
337
+ # atome_f.resize(resize_found)
338
+ # inactivation code
339
+ #################################
340
+ tick[tool_name] = 0
341
+ end
342
+ end
343
+ end
344
+ end
@@ -45,14 +45,14 @@ class HTML
45
45
  def add_font_to_css(params)
46
46
  font_path = params[:path]
47
47
  font_name = params[:name]
48
- str_to_eval = <<STRDELIM
49
- var styleSheet = document.styleSheets[0];
50
- styleSheet.insertRule(`
51
- @font-face {
52
- font-family: '#{font_name}';
53
- src: url('../medias/fonts/#{font_path}/#{font_name}.ttf') format('truetype');
54
- }`, styleSheet.cssRules.length);
55
- STRDELIM
48
+ str_to_eval = <<~STRDELIM
49
+ var styleSheet = document.styleSheets[0];
50
+ styleSheet.insertRule(`
51
+ @font-face {
52
+ font-family: '#{font_name}';
53
+ src: url('../medias/fonts/#{font_path}/#{font_name}.ttf') format('truetype');
54
+ }`, styleSheet.cssRules.length);
55
+ STRDELIM
56
56
  JS.eval(str_to_eval)
57
57
  end
58
58
 
@@ -1303,37 +1303,30 @@ STRDELIM
1303
1303
  end
1304
1304
  end
1305
1305
 
1306
+
1306
1307
  # animation below
1307
1308
  def animate(animation_properties)
1308
- command = <<~JS
1309
- var target_div = document.getElementById('#{@id}');
1310
- window.currentAnimation = popmotion.animate({
1311
- from: #{animation_properties[:from]},
1312
- to: #{animation_properties[:to]},
1313
- duration: #{animation_properties[:duration]},
1314
- onUpdate: function(v) {
1315
- atomeJsToRuby("puts x= "+v)
1316
- atomeJsToRuby("grab('#{@id}').left("+v+")")
1317
- },
1318
- onComplete: function() {
1319
- window.currentAnimation = null;
1320
- atomeJsToRuby("puts :complete")
1321
- }
1322
- });
1309
+ prop= animation_properties[:particle]
1310
+ command = <<~JS
1311
+ var target_div = document.getElementById('#{@id}');
1312
+ window.currentAnimation = popmotion.animate({
1313
+ from: #{animation_properties[ :from]},
1314
+ to: #{animation_properties[:to]},
1315
+ duration: #{animation_properties[:duration]},
1316
+ onUpdate: function(v) {
1317
+ atomeJsToRuby("grab('#{@id}').animation_callback('#{prop}', "+v+")")
1318
+ atomeJsToRuby("grab('#{@id}').#{prop}("+v+")")
1319
+ },
1320
+ onComplete: function(v) {
1321
+ window.currentAnimation = null;
1322
+ atomeJsToRuby("grab('#{@id}').animation_callback('#{prop}_end')")
1323
+ }
1324
+ });
1323
1325
  JS
1324
1326
  JS.eval(command)
1325
1327
  end
1326
1328
 
1327
- def play_animation(properties)
1328
- puts 'change for standard method : action'
1329
- required_keys = [:from, :to, :duration]
1330
- unless properties.is_a?(Hash) && (required_keys - properties.keys).empty?
1331
- raise ArgumentError, 'Properties must be a hash with :from, :to, and :duration keys'
1332
- end
1333
-
1334
- animate(properties)
1335
1329
 
1336
- end
1337
1330
 
1338
1331
  def stop_animation
1339
1332
  JS.eval('if (window.currentAnimation) window.currentAnimation.stop();')
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ b=box
4
+ margin = 12
5
+ b2=box({top: below(b, margin)})
6
+ b3=box({top: below(b2, margin)})
7
+ b4=box({top: below(b3, margin)})
8
+ box({top: below(b4, margin)})
9
+ i=0
10
+ while i< 10 do
11
+ b2=box({top: below(b, margin)})
12
+ i+=1
13
+ end
14
+
15
+ b = circle(left: 66)
16
+ margin = 12
17
+ i = 0
18
+
19
+ while i < 10 do
20
+ b = circle({top: below(b, margin), left: 66})
21
+ i += 1
22
+ end
@@ -87,5 +87,33 @@
87
87
 
88
88
  b=box({id: :the_box})
89
89
 
90
- b.animate({ to: 90 })
90
+ b.animate({ to: 333, particle: :width, duration: 3000}) do |val|
91
+ puts "width +#{val}"
92
+ end
93
+
94
+ b.animate({ to: 456, particle: :left, duration: 5000}) do |val|
95
+ puts "left +#{val}"
96
+ end
97
+
98
+ b.animate({ end: :left}) do |val|
99
+ puts "left ended"
100
+ end
101
+
102
+ b.animate({ to: 69, particle: :smooth, duration: 10000}) do |val|
103
+ puts "smooth +#{val}"
104
+ end
105
+
106
+ b.animate({ end: :smooth}) do |val|
107
+ puts " cool smooth end now!!!"
108
+ end
109
+
110
+ b.animate({ to: 90, particle: :rotate, duration: 10000}) do |val|
111
+ puts "rotate +#{val}"
112
+ end
113
+
114
+ b.animate({ to: 222, particle: :top, duration: 10000}) do |val|
115
+ puts "top +#{val}"
116
+ end
117
+
118
+
91
119