Good point. I’ll try to convert these to utility functions.
FWIW, The only difference is "- window.scrollX”. I’m also pretty sure that the “older browser fallback” which is a major part of the code is not necessary. getBoundingClientRec() seems to be supported back through IE9.[1] We should probably clean out the “offset” code. Harbs [1]https://caniuse.com/#search=getBoundingClientRect <https://caniuse.com/#search=getBoundingClientRect> > On Jun 1, 2018, at 7:22 PM, Alex Harui <[email protected]> wrote: > > For PAYG, should we have a version of the API that worries about window > scrolling and one that doesn't? If your app is designed not to scroll, I > would think you wouldn't have to pay for this extra code? > > -Alex > > On 6/1/18, 4:26 AM, "[email protected] <mailto:[email protected]>" > <[email protected] <mailto:[email protected]>> wrote: > > This is an automated email from the ASF dual-hosted git repository. > > harbs pushed a commit to branch develop > in repository > https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgitbox.apache.org%2Frepos%2Fasf%2Froyale-asjs.git&data=02%7C01%7Caharui%40adobe.com%7C85aafe13907e4728298508d5c7b28caa%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636634492071894168&sdata=upjYhaXnXu4zo0rSp731%2ByM89crQMlK%2BothTSTXQlqA%3D&reserved=0 > > <https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgitbox.apache.org%2Frepos%2Fasf%2Froyale-asjs.git&data=02%7C01%7Caharui%40adobe.com%7C85aafe13907e4728298508d5c7b28caa%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636634492071894168&sdata=upjYhaXnXu4zo0rSp731%2ByM89crQMlK%2BothTSTXQlqA%3D&reserved=0> > > commit e5328655b9991fe44b92c61d1b18aa7a4cc104b5 > Author: Harbs <[email protected] <mailto:[email protected]>> > AuthorDate: Tue May 29 12:25:55 2018 +0300 > > global point should ignore window scrolling > --- > .../royale/org/apache/royale/utils/PointUtils.as | 28 > +++++++++++++--------- > 1 file changed, 17 insertions(+), 11 deletions(-) > > diff --git > a/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/PointUtils.as > > b/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/PointUtils.as > index 264102c..f96e61c 100644 > --- > a/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/PointUtils.as > +++ > b/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/PointUtils.as > @@ -71,18 +71,24 @@ package org.apache.royale.utils > var x:Number = pt.x; > var y:Number = pt.y; > var element:HTMLElement = local.element as HTMLElement; > + if ( element.getBoundingClientRect ) {// TODO > take scrollbar widths into account > + var rect:Object = > element.getBoundingClientRect(); > + x = x - rect.left - window.scrollX; > + y = y - rect.top - window.scrollY; > + } else { // for older browsers, but > offsetParent is soon to be deprecated from chrome > > - do { > - x -= element.offsetLeft; > - y -= element.offsetTop; > - if (local['parent'] !== undefined) { > - local = local.parent; > - element = local ? local.element as HTMLElement : > null; > - } else { > - element = null; > + do { > + x -= element.offsetLeft; > + y -= element.offsetTop; > + if (local['parent'] !== undefined) { > + local = local.parent; > + element = local ? local.element as > HTMLElement : null; > + } else { > + element = null; > + } > } > + while (element); > } > - while (element); > return new org.apache.royale.geom.Point(x, y); > > } > @@ -119,8 +125,8 @@ package org.apache.royale.utils > > if ( element.getBoundingClientRect ) {// TODO > take scrollbar widths into account > var rect:Object = > element.getBoundingClientRect(); > - x = rect.left + x; > - y = rect.top + y; > + x = rect.left + x + window.scrollX; > + y = rect.top + y + window.scrollY; > } else { // for older browsers, but > offsetParent is soon to be deprecated from from chrome > do { > x += element.offsetLeft; > > -- > To stop receiving notification emails like this one, please contact > [email protected] <mailto:[email protected]>.
