lib/third_party/tracing/extras/rail/rail_ir_finder.js
function(sortedInputEvents) {
      var protoIRs = [];
      var currentPIR = undefined;
      var prevEvent_ = undefined;
      forEventTypesIn(
          sortedInputEvents, MOUSE_WHEEL_TYPE_NAMES, function(event) {
        // Switch prevEvent in one place so that we can early-return later.
        var prevEvent = prevEvent_;
        prevEvent_ = event;

        if (currentPIR &&
            (prevEvent.start + MOUSE_WHEEL_THRESHOLD_MS) >= event.start) {
          if (currentPIR.irType === ProtoIR.ANIMATION_TYPE) {
            currentPIR.pushEvent(event);
          } else {
            currentPIR = new ProtoIR(ProtoIR.ANIMATION_TYPE,
                MOUSEWHEEL_IR_NAME);
            currentPIR.pushEvent(event);
            protoIRs.push(currentPIR);
          }
          return;
        }
        currentPIR = new ProtoIR(ProtoIR.RESPONSE_TYPE, MOUSEWHEEL_IR_NAME);
        currentPIR.pushEvent(event);
        protoIRs.push(currentPIR);
      });
      return protoIRs;
    }
function(sortedInputEvents) {
      var protoIRs = [];
      var currentPIR = undefined;
      var prevEvent_ = undefined;
      forEventTypesIn(
          sortedInputEvents, MOUSE_WHEEL_TYPE_NAMES, function(event) {
        // Switch prevEvent in one place so that we can early-return later.
        var prevEvent = prevEvent_;
        prevEvent_ = event;

        if (currentPIR &&
            (prevEvent.start + MOUSE_WHEEL_THRESHOLD_MS) >= event.start) {
          if (currentPIR.irType === ProtoIR.ANIMATION_TYPE) {
            currentPIR.pushEvent(event);
          } else {
            currentPIR = new ProtoIR(ProtoIR.ANIMATION_TYPE,
                MOUSEWHEEL_IR_NAME);
            currentPIR.pushEvent(event);
            protoIRs.push(currentPIR);
          }
          return;
        }
        currentPIR = new ProtoIR(ProtoIR.RESPONSE_TYPE, MOUSEWHEEL_IR_NAME);
        currentPIR.pushEvent(event);
        protoIRs.push(currentPIR);
      });
      return protoIRs;
    }
function ( sortedInputEvents ) { var protoIRs = [ ] ; var currentPIR = undefined ; var prevEvent_ = undefined ; forEventTypesIn ( sortedInputEvents , MOUSE_WHEEL_TYPE_NAMES , function ( event ) { // Switch prevEvent in one place so that we can early-return later. var prevEvent = prevEvent_ ; prevEvent_ = event ; if ( currentPIR && ( prevEvent . start + MOUSE_WHEEL_THRESHOLD_MS ) >= event . start ) { if ( currentPIR . irType === ProtoIR . ANIMATION_TYPE ) { currentPIR . pushEvent ( event ) ; } else { currentPIR = new ProtoIR ( ProtoIR . ANIMATION_TYPE , MOUSEWHEEL_IR_NAME ) ; currentPIR . pushEvent ( event ) ; protoIRs . push ( currentPIR ) ; } return ; } currentPIR = new ProtoIR ( ProtoIR . RESPONSE_TYPE , MOUSEWHEEL_IR_NAME ) ; currentPIR . pushEvent ( event ) ; protoIRs . push ( currentPIR ) ; } ) ; return protoIRs ; }
MouseWheel events are caused either by a physical wheel on a physical mouse, or by a touch-drag gesture on a track-pad. The physical wheel causes MouseWheel events that are much more spaced out, and have no chance of hitting 60fps, so they are each turned into separate Response IRs. The track-pad causes MouseWheel events that are much closer together, and are expected to be 60fps, so the first event in a sequence is turned into a Response, and the rest are merged into an Animation. NB this threshold uses the two events' start times, unlike ProtoIR.isNear, which compares the end time of the previous event with the start time of the next.
MouseWheel events are caused either by a physical wheel on a physical mouse or by a touch - drag gesture on a track - pad . The physical wheel causes MouseWheel events that are much more spaced out and have no chance of hitting 60fps so they are each turned into separate Response IRs . The track - pad causes MouseWheel events that are much closer together and are expected to be 60fps so the first event in a sequence is turned into a Response and the rest are merged into an Animation . NB this threshold uses the two events start times unlike ProtoIR . isNear which compares the end time of the previous event with the start time of the next .