Criticality of trapping in a dynamic epidemic model