All swipe options

Hello to everybody!
I have created a topic related to an issue with a swipe on a double-pane app. Although I haven’t received any suggestion from anybody, I decided to go in another way.
Let’s gather all options which are available in automation with Appium. I suggest writing here your option, how you do it with a small description of tools versions, any specific uses or distinctive feature if any. It’s supposed to write for the old and new versions of Appium, lang-clients etc. Maybe later it would be moved to Tutorials/Docs category.
So who is gonna be first?

I’ll be the first so :smiley: (Nice initiative ;))

([email protected]. [email protected] Working on android 6 and ios 10)
RUBY:

def do_swipe(x1, y1, x2, y2, duration)
  action = Appium::TouchAction.new
  action.swipe({start_x: x1, start_y: y1, offset_x: x2, offset_y: y2, duration: duration}).perform if is_ios?
  action.swipe({start_x: x1, start_y: y1, end_x: x2, end_y: y2, duration: duration}).perform if is_android?
end

def scroll(direction)
  width = Appium::Common.window_size.width
  height = Appium::Common.window_size.height
  x = end_x = width / 4
  y = end_y = height / 4
  offset_x = 2 * x
  offset_y = 2 * y
  case direction
  when "up"
    offset_x = 0
    end_y *= 3
  when "down"
    y *= 3
    offset_y*= -1
    offset_x = 0
  when "right"
    offset_y = 0
    x *= 3
  when "left"
    end_x *= 3
    offset_x *= -1
    offset_y = 0
  else
    puts "Direction not allowed"
  end
  do_swipe(x, y, offset_x, offset_y, 800) if is_ios?
  do_swipe(x, y, end_x, end_y, 800) if is_android?
end

def drag_and_drop(element_to_drop, dropping_zone)
  action = Appium::TouchAction.new
  action.press({element: player1}).wait(1000) if is_ios?
  action.long_press({element: element_to_drop}) if is_android?  
  action.move_to({element: dropping_zone}).release.perform 
end

I hope this helps someone :smiley: