Observations of enhanced fast-ion losses during edge localized modes (ELMs) have been reported in the ASDEX Upgrade tokamak, revealing losses above the injection energy. This suggests that fast ions can be accelerated and lost due to the ELMs. Recent analysis of the ELM-induced losses suggests that the fast ions are lost due to a resonant interaction with the electromagnetic perturbation during the ELM crash. The fast-ion transport and acceleration during ELMs is modelled using electromagnetic fields computed using the hybrid kinetic-MHD code MEGA, while fast-ion full orbits are tracked with the ASCOT code. Time-evolving 3D electromagnetic fields have been implemented in ASCOT to compute fast-ion orbits in the presence of fast MHD events such as ELMs. The simulations successfully reproduce a field-aligned pattern of the losses on the tokamak wall and the formation of an accelerated population in the lost fast-ion distribution, while they predict an accelerated population in the confined distribution. A parametric study of the fast-ion constants of motion suggests a resonant interaction between the fast-ions and the electromagnetic fields arising during the ELM crash. In the case of fast-ion acceleration, the perpendicular electric perturbation, with scales smaller than the fast-ion gyroradius, breaks magnetic moment conservation and resonantly modifies the fast-ion energy.