Flux fractionalization transition in two-dimensional dimer-loop models