Should this JS be toggling a class rather than manipulating CSS properties directly?