Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For file sharing #37

Open
miherlosev opened this issue Feb 2, 2022 · 4 comments
Open

For file sharing #37

miherlosev opened this issue Feb 2, 2022 · 4 comments

Comments

@miherlosev
Copy link
Owner

No description provided.

@miherlosev
Copy link
Owner Author

master_run.zip

@miherlosev
Copy link
Owner Author

@miherlosev
Copy link
Owner Author

import hammerhead from '../deps/hammerhead';
import delay from '../utils/delay';

const browserUtils = hammerhead.utils.browser;

private _afterSetScroll (scrollPromise: Promise, scrollElement: Element | Document, originalScroll: LeftTopValues): Promise {
if (!ScrollAutomation._isScrollValuesChanged(scrollElement, originalScroll)) {
// @ts-ignore
scrollPromise.cancel();

        return scrollAdapter.PromiseCtor.resolve();
    }

    scrollPromise = scrollPromise.then(() => {
        if (!this._scrollWasPerformed)
            this._scrollWasPerformed = ScrollAutomation._isScrollValuesChanged(scrollElement, originalScroll);
    });

    return scrollPromise;
}

private _setScroll (element: Element, { left, top }: LeftTopValues<number>): Promise<void> {
    const scrollElement = utilsAdapter.dom.isHtmlElement(element) ? utilsAdapter.dom.findDocument(element) : element;

    const originalScroll = {
        left: utilsAdapter.style.getScrollLeft(scrollElement),
        top:  utilsAdapter.style.getScrollTop(scrollElement),
    };

    left = Math.max(left, 0);
    top  = Math.max(top, 0);

    let scrollPromise = scrollAdapter.controller.waitForScroll(scrollElement);

    utilsAdapter.style.setScrollLeft(scrollElement, left);
    utilsAdapter.style.setScrollTop(scrollElement, top);

    if (browserUtils.isSafari && browserUtils.fullVersion >= '15.0') {
        return delay(30).then(() => {
            return this._afterSetScroll(scrollPromise, scrollElement, originalScroll);
        })
    }
    else
        return this._afterSetScroll(scrollPromise, scrollElement, originalScroll);
}

@miherlosev
Copy link
Owner Author

miherlosev commented May 3, 2022

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant