I faced this challenge couple of months back while working on a webapp, After researching quiet a bit, The "Shadow DOM "approach suggested in the following article helped.
https://medium.com/@dvoytenko/amp-ios-scrolling-redo-2-the-shadow-wrapper-approach-experimental-3362ed3c2fa2.
var sd = document.body.attachShadow({mode: 'open'});
// Main slot will absorb all undistributed children.
var mainSlot = document.createElement('slot');
var scroller = document.createElement('div');
scroller.style = 'background: lightblue; position: absolute; top:
0; left: 0; right: 0; bottom: 0; overflow-x: hidden; overflow-y: auto; -webkit-overflow-scrolling: touch;';
scroller.appendChild(mainSlot);
sd.appendChild(scroller);
// Selectively, it's also possible to distribute fixed elements separately,
// emulating fixed layer transfer.
var fixedLayer = document.createElement('div');
fixedLayer.style = 'height: 0; width: 0; position: fixed;
overflow:visible;';
sd.appendChild(fixedLayer);
var mainFixedSlot = document.createElement('slot');
mainFixedSlot.setAttribute('name', 'fixed');
fixedLayer.appendChild(mainFixedSlot);
function addToFixedLayer(element) {
//var slotId = String(Math.random());
//var fixedSlot = document.createElement('slot');
//fixedSlot.setAttribute('name', slotId);
//fixedLayer.appendChild(fixedSlot);
//element.setAttribute('slot', slotId);
element.setAttribute('slot', 'fixed');
}
/*Call and pass fixed elemetns to addToFixedLayer method so that they stay
fixed while scrolling */
addToFixedLayer(fixedDivId)
Check this demo https://jsfiddle.net/rsva63ep/