This 8 line shim makes elements with position: sticky work as intended in situations where you have scrollable content nested within your app - see this for an example.
Before going any further, this is to be used only in Electron.
You will need to enable the position: sticky flag/blink feature in order for this to work.
You can do this by either adding CSSStickyPosition to the blinkFeatures web preference...
win = new BrowserWindow({
// ...
webPreferences: {
blinkFeatures: 'CSSStickyPosition',
},
});Or you can enable all of the Chrome experimental features (of which position: sticky is one)...
win = new BrowserWindow({
// ...
webPreferences: {
experimentalFeatures: true,
},
});Now all you need to do is import the sticky-shim.js file, and add the sticky-shim class to any elements which have the position: sticky css rule applied. The shim does not automatically add position: sticky, this is so when Electron does support it natively, you can simply remove the shim and the shim class, and all should work as intended.