Sha256: 6651d0556580200407ace79f4c5f820c72ec69ff1de7ad2826a59d41996f4e4d

Contents?: true

Size: 486 Bytes

Versions: 1

Compression:

Stored size: 486 Bytes

Contents

module Fusuma
  # manage actions
  class Swipe
    BASE_THERESHOLD = 20

    def initialize(x, y)
      @x = x
      @y = y
    end
    attr_reader :x, :y

    def direction
      return x > 0 ? 'right' : 'left' if x.abs > y.abs
      y > 0 ? 'down' : 'up'
    end

    def enough_distance?
      MultiLogger.debug(x: x, y: y)
      (x.abs > threshold) || (y.abs > threshold)
    end

    def threshold
      @threshold ||= BASE_THERESHOLD * Config.threshold('swipe')
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fusuma-0.2.2 lib/fusuma/swipe.rb