Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Don't show overwrite animation on click #6883

Merged
merged 2 commits into from
Mar 10, 2014

Conversation

WebsiteDeveloper
Copy link
Contributor

Part of #6862
@redmunds

$(editor).on("overwriteToggle.statusbar", function (event, editor, newstate) {
_updateOverwriteLabel(event, editor, newstate, true);
$(editor).on("overwriteToggle.statusbar", _updateOverwriteLabel);
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like the idea of manipulating the click event handler back and forth like that. What do you think about this solution?

    function _updateOverwriteLabel(event, editor, newstate, doNotAnimate) {
        if ($statusOverwrite.text() === (newstate ? Strings.STATUSBAR_OVERWRITE : Strings.STATUSBAR_INSERT)) {
            // label already up-to-date
            return;
        }

        $statusOverwrite.text(newstate ? Strings.STATUSBAR_OVERWRITE : Strings.STATUSBAR_INSERT);

        if (!doNotAnimate) {
            AnimationUtils.animateUsingClass($statusOverwrite[0], "flash");
        }
    }

    function _updateEditorOverwriteMode(event) {
        var editor = EditorManager.getActiveEditor(),
            newstate = !editor._codeMirror.state.overwrite;

        // update label with no transition
        _updateOverwriteLabel(event, editor, newstate, true);
        editor.toggleOverwrite(newstate);
    }

The click handler first changes the label with no animation, so when the "overwriteToggle" event is received, the label has already been changed, so it is not changed with animation.

@redmunds
Copy link
Contributor

@WebsiteDeveloper Done with review.

@WebsiteDeveloper
Copy link
Contributor Author

@redmunds i added the changes you proposed.
I also tested them a while in production.

@redmunds
Copy link
Contributor

Looks good. Merging.

redmunds added a commit that referenced this pull request Mar 10, 2014
@redmunds redmunds merged commit 3ad6d5f into adobe:master Mar 10, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants