Remove a class or change a class when entering edit mode

Hey all - looking for some advice. 9.13 install and am using ScrollReveal to target some classes for a smooth loading experience. However when I enter edit mode, the classes that are targeted are still hidden because edit mode loads faster than the Scroll Reveal Script.

Any way I can do something like “If in Edit Mode, Remove or Hide a class?”

Any help appreciated.

provided you are in control of where the classes appear through code, you can use

$c = Page::getCurrentPage();

if (is_object($c) && !$c->isError()) {
    if ($c->isEditMode()) {
        // do something when in edit mode
    } else {
        // do something when not in edit mode
    }
}
1 Like

The core adds an edit mode class to the page when in edit mode, so you can also do some edit mode specific styling purely in css.

In JS you can test for CCM_EDIT_MODE.

Generally, it is safest to not load or not initialize animations and smooth scrolls in edit mode. They can so easily skew or completely break the edit view.

1 Like

Awesome. Thanks guys.