npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@marp-team/marpit-svg-polyfill

v2.1.0

Published

Polyfill for inline SVG slides rendered by Marpit

Downloads

14,003

Readme

@marp-team/marpit-svg-polyfill

CircleCI Codecov npm LICENSE

The polyfill for the inline SVG slide rendered by Marpit.

Supported browser

  • WebKit based browser: Safari and iOS browsers (including iOS Chrome, iOS Firefox, iOS Edge, and so on...)

Usage

<!-- Generated HTML by Marpit's inline SVG mode -->
<div class="marpit">
  <svg viewBox="0 0 1280 720" data-marpit-svg="">
    <foreignObject width="1280" height="720">
      <section>...</section>
    </foreignObject>
  </svg>
</div>

<!-- After than, use polyfill through jsDelivr CDN -->
<script src="https://cdn.jsdelivr.net/npm/@marp-team/marpit-svg-polyfill/lib/polyfill.browser.js"></script>

Why need?

WebKit

Marpit's inline SVG slide has a lot of advantages: No requires JavaScript, gives better performance for scaling, and has predicatable DOM structure.

But unfortunately, WebKit browser has not scaled the wrapped HTML correctly. It is caused from a long standing bug 23113, and it does not resolved in the last 15 years.

Note A brand-new SVG engine for WebKit called as "Layer-based SVG engine (LBSE)" is currently under development, and it will finally bring glitch-free scaling without JS. (See also: Status of the new SVG engine in WebKit)

You can test LBSE in Safari Technology Preview by following these steps:

  1. Install Safari Technology Preview
  2. Run defaults write com.apple.SafariTechnologyPreview IncludeInternalDebugMenu 1 in terminal
  3. Open Safari Technology Preview
  4. Turn on "Layer-based SVG engine (LBSE)" from "Debug" menu → "WebKit Internal Features"
  5. Restart app

marpit-svg-polyfill v2.1.0 and later will try to detect whether or not enabled LBSE, and does not apply polyfill if LBSE was available.

Solutions

For Webkit

Scaling

We try to simulate scaling and centering by applying transform / transform-origin style to Marpit <section> elements.

<svg viewBox="0 0 1280 960">
  <foreignObject width="1280" height="960">
    <section style="transform-origin:0 0;transform:matrix(......);">
      ...
    </section>
  </foreignObject>
</svg>

marpit-svg-polyfill uses the result of getScreenCTM() method, so the polyfill will sacrifice "zero-JS slide", the key feature of inline SVG.

Repainting

WebKit browser would not trigger repainting even if modified the contents of slide. It becomes a problem when supporting the live preview feature in Marp tools.

Fortunately, a genius already resolved this problem only in CSS! transform:translateZ(0) would trigger re-painting immidiately when modified contents.

Animation GIF

People like to put GIF animation in the slide. However, GIF in polyfilled slides have glitches. GIF updates only a cropped part somewhere.

Applying transform:translateZ(0.0001px) to each <section> elements within SVG is a magic to resolve that. 🪄

Warning This style brings slightly blurred contents too. Our polyfill prefers to render animated contents correctly.

Contributing

We are following the contributing guideline of marp-team projects. Please read these guidelines this before starting work in this repository.

Author

Managed by @marp-team.

License

This module releases under the MIT License.