promise example

you don't put anything in resolve, maybe a console log in the reject.

by Adam Kinnucane

JavaScript

private _lockBodyPosition() {
        document.getElementsByTagName('BODY')[0].classList.add(this._selectors.stopScrolling);

        const positionLockedPromise = new Promise((resolve, reject) => {
            this._indicateSectionContainerIsLocked();
            if (this._sectionsWrapper.classList.contains(this._selectors.lockPosition)) {
                resolve();
            } else {
                reject();
            }
        });

        positionLockedPromise.then(() => {
            this._getSectionTitleScrollPosition();
        });
    }