If you see a coworker slacking off, you merely need to continue your own efforts at your best efforts, not allow your work ethic to steep down to anything less just because someone else's has.

I've witnessed others getting upset and saying things to the effect of: "Well, if they're not going to work hard, then I'm not gonna continue to bust my ass." I answered, "I'm not letting the fact that they're not doing their job affect how hard I work. I just focus on what I can do, not what they aren't."