Proposal: Exposing native scroll as API

Adam Eisenreich akxe at seznam.cz
Fri Jun 21 14:30:47 UTC 2019


I mean, that there should be an API that would say, how an element would scroll, if it was in place of for example a `<canvas>`. 


```
const scrollArea = new ScrollArea(canvasElement, {
  borderBox: 'unlimited', // Default would be the element
  //viewPort: '100#200'
});

scrollArea.addEventLisener('scrollStart', event => {
  console.log(event.endOffsetPosition);
  console.log(event.currenOffset);
  console.log(event.deltaX);
  // Possibly others
});
scrollArea.addEventLisener('scroll', () => {});
scrollArea.addEventLisener('scrollEnd', () => {});
```
Or, 
```
function step(timestamp) {
  canvas.translate(scrollArea.currentOffset.top, scrollArea.currentOffset.left);
  requestAnimationFrame(step);
}

requestAnimationFrame(step);
```


More information about the es-discuss mailing list