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

[BUG] Few panes in single page - pane styles bug #133

Closed
spb-web opened this issue Feb 16, 2021 · 7 comments
Closed

[BUG] Few panes in single page - pane styles bug #133

spb-web opened this issue Feb 16, 2021 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@spb-web
Copy link
Contributor

spb-web commented Feb 16, 2021

We can try using inline styles. Then, when initializing a new pane, new "style" tags will not be created. And to apply the theme, we can use css variables. I would do it if it fits into the development plans.

@spb-web spb-web changed the title pane styles [FEAT] pane styles Feb 16, 2021
@roman-rr
Copy link
Collaborator

@spb-web I think we can just apply additional classes for configurations.

E.g.

.cupertino-pane-wrapper .inversed .darkmode {

}

And create styles at beginning.

Feel free to create pull, i will review and adjust if needs.
And please write here or create pull with some css variables you are think good to use.

@spb-web
Copy link
Contributor Author

spb-web commented Feb 17, 2021

@roman-rr If we use classes and “style” tags for styling, then we will have to add the removal of unused “style” tags when the panel is destroyed. It's easier for me to use inline styles. See an example of this. This is not complete code yet, but it is sufficient.

@Vishal-Isharani
Copy link

Vishal-Isharani commented Feb 17, 2021

@roman-rr @spb-web I'm also facing a wired style issue, where panes styles working weirdly ( no animation or wrong opening positions ).
I have three panes on a single page, two opens from the bottom and one opens from the top ( using inverse mode ).
Ex:-
Pane a: - Open from top
Pane b: Open from bottom
Pane c: Open from bottom.

Now when you open Pane a first and then go for pane b, pane b will work weirdly, and same if you do reverse. But when you open Pane b and pane c in sequence all works fine.

After hours of debugging I found that, Cupertino creates style tags for panes and add them to the head section (which is causing issues here), and when you destroy a pane styles stays there it doesn't get removed.
So for fixing the issues I need to remove them manually. I achieved that by doing the following.

/**
     * close a pane
     * close a pane and removes it from paneMapper holder
     * @param {string} el
     */
    public close(el: string): Promise<string> {
        return new Promise((resolve, reject): void => {
            // get pane
            const pane = this.getInstance(el);
            if (pane) {
                // delete from pane mapper
                this.paneMapper.delete(el);
                // destroy pane
                pane.destroy({ animate: true });

                // let animation complete, than remove the styles
                setTimeout(() => {
                    this.removeStyles();
                    resolve('Pane removed');
                }, this._defaultSettings.animationDuration);
            } else {
                reject('Pane not found');
            }
        });
    }
    
private removeStyles(): void {
        const styles = document.getElementsByTagName('style');
        for (let i = 0; i < styles.length; i++) {
            const style = styles.item(i);
            const isCupertinoPaneStyle = style.innerHTML.trim().startsWith('.cupertino-pane-wrapper');
            if (isCupertinoPaneStyle) {
                style.parentNode.removeChild(style);
            }
        }
    }

I think @spb-web is right we can use inline-styles, which will eliminate above mentioned issue.
Thanks

@roman-rr roman-rr self-assigned this Feb 17, 2021
@roman-rr roman-rr changed the title [FEAT] pane styles [BUG] Few panes in single page - pane styles bug Feb 17, 2021
@roman-rr
Copy link
Collaborator

@Vishal-Isharani @spb-web i will personally work on it on the next 24 hrs.

@roman-rr roman-rr added the bug Something isn't working label Feb 17, 2021
@spb-web
Copy link
Contributor Author

spb-web commented Feb 17, 2021

@roman-rr , #134

@roman-rr
Copy link
Collaborator

@Vishal-Isharani Should be fixed in master branch. But in next few days will be released as 1.2.5 with variables also.

@Vishal-Isharani
Copy link

@Vishal-Isharani Should be fixed in master branch. But in next few days will be released as 1.2.5 with variables also.

That's is some quick @roman-rr,
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants