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

Scroll 'Coy' background with contents #1163

Merged
merged 2 commits into from
Sep 9, 2017
Merged

Scroll 'Coy' background with contents #1163

merged 2 commits into from
Sep 9, 2017

Conversation

nickersonm
Copy link
Contributor

Fix on themes/prism-coy.css: attaches <pre> background (alternating line colors) to <code> contents when in limited-height <pre> that requires scrolling.

Example: http://prismjs.com/ with 'Coy' theme selected; most evident on smallest scroll, such as the SVG logo highlight.

Attaches <pre> background (alternating line colors in 'Coy') to <code> contents when in limited-height <pre> that requires scrolling.
@LeaVerou
Copy link
Member

LeaVerou commented Jul 16, 2017

Hey, thanks! Is there an online demo of this fix anywhere?

@nickersonm
Copy link
Contributor Author

Usage: drag the scroll bar vertically by small amounts.
Main branch: https://jsfiddle.net/d3L8nvjf/
With patched coy-style.css: https://jsfiddle.net/dbksxu0c/1/

However, from reading other prism commits and comments, I realized that this removes the 'curved' dropshadow below the <pre> blocks (which are hidden at narrower sizes- expand the fiddle result window), inserted with :before and :after entities. This is because the dropshadow is on the same layer as the background: the contents of the <pre>, and is also aligned to the <pre>. I have not been able to find a good CSS-only solution to including both.

It would be possible by wrapping the <pre> in a <div> for the positioning (explained here), but that's not desired behavior.

@LeaVerou
Copy link
Member

Thanks for the demo, that was fast!

I realized that this removes the 'curved' dropshadow

Yeah, that would be a problem I’m afraid… :/

Move background from <pre> element to <code> element to preserve <pre> drop-shadows while keeping background attached during scroll.
@nickersonm
Copy link
Contributor Author

Understood. I committed a change to this pull branch that reverts to using the original overflow: auto on the <code> block and moves the background from the <pre> block to the <code>.

It seems to both scroll the background and preserve everything else, but I have not tested it as extensively.

Demo:
Main branch: https://jsfiddle.net/d3L8nvjf/
With patched coy-style.css: https://jsfiddle.net/dbksxu0c/1/ (auto-updated as it uses the raw nickersonm/patch-2 branch CSS)

@Golmote Golmote merged commit 310990b into PrismJS:gh-pages Sep 9, 2017
@Golmote
Copy link
Contributor

Golmote commented Sep 9, 2017

Demo seems to work just fine! Thank you for contributing!

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

Successfully merging this pull request may close these issues.

3 participants