lib/fusuma/plugin/detectors/tap_detector.rb in fusuma-plugin-tap-0.3.0 vs lib/fusuma/plugin/detectors/tap_detector.rb in fusuma-plugin-tap-0.3.1

- old
+ new

@@ -19,11 +19,11 @@ # @return [NilClass] if event is NOT detected def detect(buffers) buffer = buffers.find { |b| b.type == BUFFER_TYPE } gesture_buffer = buffers.find { |b| b.type == 'gesture' } - return if buffer.empty? || !gesture_buffer.empty? || moved?(buffer) + return if buffer.empty? || moved?(tap_buffer: buffer, gesture_buffer: gesture_buffer) holding_time = buffer.events.last.time - buffer.events.first.time direction = if hold?(buffer, holding_time) 'hold' @@ -69,11 +69,13 @@ released_all?(buffer) end # @return [TrueClass, FalseClass] - def moved?(buffer) - buffer.events.any? { |e| e.record.status == 'move' } + def moved?(tap_buffer:, gesture_buffer:) + tap_buffer.events.any? { |e| e.record.status == 'move' } || + # FIXME: Find good parameter for ignoring + gesture_buffer.events.count { |e| tap_buffer.events.first.time < e.time } > 5 end # @return [TrueClass, FalseClass] def released_all?(buffer) touch_num = buffer.events.count { |e| (e.record.status =~ /begin|touch/) }