lib/fusuma/plugin/detectors/rotate_detector.rb in fusuma-2.0.5 vs lib/fusuma/plugin/detectors/rotate_detector.rb in fusuma-2.1.0

- old
+ new

@@ -22,11 +22,17 @@ .select_by_events { |e| e.record.gesture == GESTURE_RECORD_TYPE } updating_events = gesture_buffer.updating_events return if updating_events.empty? - updating_time = 100 * (updating_events.last.time - updating_events.first.time) - oneshot_angle = gesture_buffer.sum_attrs(:rotate) / updating_time + oneshot_angle = if updating_events.size >= 10 + updating_time = 100 * (updating_events[-1].time - updating_events[-10].time) + last_10 = gesture_buffer.class.new(updating_events[-10..-1]) + last_10.sum_attrs(:rotate) / updating_time + else + updating_time = 100 * (updating_events.last.time - updating_events.first.time) + gesture_buffer.sum_attrs(:rotate) / updating_time + end return if updating_events.empty? finger = gesture_buffer.finger