Sha256: 551990079a412ec503415131f1754b3b0f99d33db9422c1551898395545503b5

Contents?: true

Size: 1.1 KB

Versions: 5

Compression:

Stored size: 1.1 KB

Contents

#  frozen_string_literal: true

a=box({width: 666, height: 777, color: :orange})
b = box({ left: 666, color: :blue, smooth: 6, id: :the_box2, depth: 1 , top: 66})
cc=circle({color: :red, left: 0, top: 0})
clone = ""
b.drag(:start) do
  b.color(:black)
  b.height(123)
  # beware you must use grab(:view) else it'll be attached to the context, that means to 'b' in this case
  clone = grab(:view).circle({ color: :white, left: b.left, top: b.top, depth: 3 })
end

b.drag(:stop) do
  b.color(:purple)
  b.height=b.height+100
  clone.delete(true)
end

b.drag(:locked) do |event|
  dx = event[:dx]
  dy = event[:dy]
  x = (clone.left || 0) + dx.to_f
  y = (clone.top || 0) + dy.to_f
  clone.left(x)
  clone.top(y)
  puts "x: #{x}"
  puts "y: #{y}"
end
cc.drag({ restrict: {max:{ left: 240, top: 190}} }) do |event|
end


c=circle

c.drag({ restrict: a.id }) do |event|

end

t=text({data: 'touch me to unbind drag stop for b (clone will not deleted anymore)', left: 250 })
t.touch(true) do
  b.drag({remove: :stop})
end

tt= text({data: "remove drag on circles", top: 99})

tt.touch(true) do
  cc.drag(false)
  c.drag(false)
end


Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
atome-0.5.7.3.6 vendor/assets/application/examples/drag.rb
atome-0.5.7.3.5 vendor/assets/application/examples/drag.rb
atome-0.5.7.3.3 vendor/assets/application/examples/drag.rb
atome-0.5.7.3.2 vendor/assets/application/examples/drag.rb
atome-0.5.7.3.1 vendor/assets/application/examples/drag.rb