Skip to content

Body can't be used as scroll-container #150

@dvdrhr

Description

@dvdrhr

Hi,

what is the reason for the following if-else-block?

// define scroll context
if (el === d.body) {
  scrollable = w;
  startX = w.scrollX || w.pageXOffset;
  startY = w.scrollY || w.pageYOffset;
  method = original.scroll;
} else {
  scrollable = el;
  startX = el.scrollLeft;
  startY = el.scrollTop;
  method = scrollElement;
}

If i'm not totally wrong it prevents us from using the body as scroll container. But i need the body to be the scroll-container because i dynamically remove some DOM elements while runtime what leads to a flickering behaviour in safari / edge when document is the outer scrolling container. Using an inner div as scroll-container doesn't work either because this breaks the mobile browsers feature of hiding the url-bar on scroll... using the body is the only possibility :)

So... is there a good reason for always using the window as scroll container instead of the body (like the code above does) or is it save to remove this if-block?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions