jonaskuske / smoothscroll-anchor-polyfill

⚓ Apply smooth scroll to anchor links, polyfill scroll-behavior
https://jonaskuske.github.io/smoothscroll-anchor-polyfill
MIT License
41 stars 3 forks source link

Example/Possible Alternative Blink Recognition? #22

Closed r-i-c-h closed 5 years ago

r-i-c-h commented 5 years ago

I'd rather not add another library just to detect the Blink layout engine.

Possible alternative detection(s) of Blink?...

if ( ((window.chrome || (window.Intl && Intl.v8BreakIterator)) &&
    'CSS' in window) ||
  /webkit\/537\.36.+chrome\/(?!27)/i.test(navigator.userAgent)
) {
  // Blink Engine
  window.__forceSmoothscrollAnchorPolyfill__ = true;
}
jonaskuske commented 5 years ago

Hey,

you're right that having to load another library to detect Blink is not optimal.

Unfortunately I haven't found another reliable way to detect the engine so far. One could probably remove everything that's not needed to detect Blink from browsengine.js to make it a least a little bit more lightweight, but that's out of scope for this package imo (and I don't have the time right now).

Your example evaluates to true in Microsoft Edge (v18, which is EdgeHTML not Blink), so probably needs a couple more checks 😞

Also, I'd rather not ship the detection as part of this package but leave it up to the user, for two reasons:

So if you really need smooth history navigation in Blink-based browsers, I unfortunately can't offer a better solution right now.