[FIX] web: properly handle smooth drag and drop for iframe normal scroll

The smooth drag and drop in edit mode (over the website iframe)
currently works correctly. This would not be the case if the scroll was
not on the `#wrapwrap` but left to the `<html>` element. Indeed, special
code handles that case, but that code is actually not needed in case
what is being dragged is outside an iframe and that the smooth
scrolling is performed inside that iframe.

Note: a further commit will move back the scrollbar behavior out of the
`#wrapwrap`, this is thus especially needed.

X-original-commit: 4947ef118c646171fd3358135dcab8f63efa04d2
Part-of: odoo/odoo#102785
This commit is contained in:
qsm-odoo
2022-10-09 18:52:49 +02:00
parent 5d7097d149
commit 0783f7ca71
@@ -262,9 +262,12 @@ const SmoothScrollOnDrag = Class.extend(mixins.ParentedMixin, {
visibleOffset.right += x;
}
// If this.$scrollTarget is the html tag, we need to take the scroll position in to account
// as offsets positions are calculated relative to the document (thus <html>).
if (this.scrollTargetIsDocument) {
// If this.$scrollTarget is the html tag, we need to take the scroll
// position into account as offsets positions are calculated relative to
// the document (thus <html>). Except in the case where what is being
// dragged is out of an iframe and that the scrolling is being done
// inside that iframe.
if (this.scrollTargetIsDocument && !this.iframeOffset) {
const scrollTargetScrollTop = this.$scrollTarget.scrollTop();
const scrollTargetScrollLeft = this.$scrollTarget.scrollLeft();
visibleOffset.top -= scrollTargetScrollTop;