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

Using syntax-highlighter inside a scrollview #11

Open
ahetawal-p opened this issue Feb 26, 2018 · 7 comments
Open

Using syntax-highlighter inside a scrollview #11

ahetawal-p opened this issue Feb 26, 2018 · 7 comments

Comments

@ahetawal-p
Copy link

Hello,
I need to render multiple SyntaxHighlighter components inside a parent scrollview based on the data I receive.
While embedding even a single SyntaxHighlighter component in a scrollview, the scrolling seems to be messed up. And I come down to a state where I can only scroll within the highlighter but not on my original scrollview. Once reaching this state, I am not able to move anywhere in the scrollview and get stuck.
Any best practices to resolve this, for supporting scrolling views.

Thank you,

@conorhastings
Copy link
Owner

conorhastings commented Feb 27, 2018

To get around this you can pass PreTag={View} as an argument to each Syntaxhighlighter so it respects the outer scrollview

let me know if that works for you

@ahetawal-p
Copy link
Author

Using it like this now

<SyntaxHighlighter
         key={key}
         language={language}
         style={dracula}
         PreTag={View} >
    {codeString}
</SyntaxHighlighter>

But rendering seems to be messed up now. The code string text is getting cut off.

On iOS

screen shot 2018-02-27 at 9 37 24 am

@conorhastings
Copy link
Owner

@ahetawal-p can you post the code string (or a piece of it)

@ahetawal-p
Copy link
Author

ahetawal-p commented Feb 27, 2018

Here is the above code string

public class Utils {


    public boolean isFullCompleteTree(Tree<Integer> t) {
            TreeInfo rootInfo = isFullCompleteTree(t.getRoot());
            return rootInfo.valid;
        }
    public TreeInfo isFullCompleteTree(Node<Integer> node) {
        boolean valid = true;

        if (node == null) {
            return new TreeInfo(true, 0);
        }

        TreeInfo rightInfo = isFullCompleteTree(node.goRight());
        TreeInfo leftInfo = isFullCompleteTree(node.goLeft());

        if ((!rightInfo.valid) || (!leftInfo.valid)) {
            valid = false;
        }
        if (rightInfo.numChildern != leftInfo.numChildern) {
            valid = false;
        }
        return new TreeInfo(valid, rightInfo.numChildern + leftInfo.numChildern
                + 1);
    }
    }

    class TreeInfo {
       public boolean valid;
       public int numChildern;

       public TreeInfo(boolean valid, int numChildern) {
           this.valid = valid;
           this.numChildern = numChildern;
    }

}

@conorhastings
Copy link
Owner

can reproduce, will try to work on it this weekend

@iaravindreddyp
Copy link

iam using syntaxhiglighter inside a scrollview just to use the scrollview callback props, But seems like the control is not with parent scrollview at all. The events are not firing at all in the parent scollview.
I even tried using the prop preTag={View} but that also doesnot seem to help

@ShivamJoker
Copy link

hello any updates :/

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

4 participants