Skip to content

PositionResolver fails to properly detect a Window element on a Electron-based app #188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
iErik opened this issue Sep 15, 2017 · 0 comments

Comments

@iErik
Copy link

iErik commented Sep 15, 2017

If I try to use the infiniteScroll directive on any component of the page, with its option to listen to the window scroll event set to the true, I receive the following error:

Uncaught TypeError: Cannot read property 'clientHeight' of null
    at PositionResolver.height (ngx-infinite-scroll.es5.js?454e:114)
    at PositionResolver.calculatePointsForElement (ngx-infinite-scroll.es5.js?454e:94)
    at PositionResolver.calculatePoints (ngx-infinite-scroll.es5.js?454e:61)
    at Object.mergeMap (ngx-infinite-scroll.es5.js?454e:318)
    at MergeMapSubscriber.eval [as project] (ngx-infinite-scroll.es5.js?454e:174)
    at MergeMapSubscriber._tryNext (mergeMap.js?4a55:120)
    at MergeMapSubscriber._next (mergeMap.js?4a55:110)
    at MergeMapSubscriber.Subscriber.next (Subscriber.js?978a:89)
    at FilterSubscriber._next (filter.js?bcf6:87)
    at FilterSubscriber.Subscriber.next (Subscriber.js?978a:89)
    at SampleTimeSubscriber.notifyNext (sampleTime.js?91e5:81)
    at AsyncAction.dispatchNotification (sampleTime.js?91e5:88)
    at AsyncAction._execute (AsyncAction.js?b38b:111)
    at AsyncAction.execute (AsyncAction.js?b38b:86)
    at AsyncScheduler.flush (AsyncScheduler.js?128d:36)
    at ZoneDelegate.invokeTask (zone.js?03e9:425)
    at Zone.runTask (zone.js?03e9:192)
    at ZoneTask.invokeTask (zone.js?03e9:499)
    at ZoneTask.invoke (zone.js?03e9:488)
    at timer (zone.js?03e9:1896)

I'm not very familiar with the project source code, but I suspect this is happening because of this particular snippet in the source code of the PositionResolver service:

isElementWindow(windowElement: ContainerRef): boolean {
  const isWindow = Object.prototype.toString.call(windowElement).includes('Window');
  return isWindow;
}

This will work on a native browser, but it happens that the first statement in this function will return "[object global]" for the window object of a Electron-based app, thus it will not be treated as a window element and this results in some weird behavior.

@iErik iErik changed the title PositionResolver Service fails to properly detect a Window element on a Electron-based app PositionResolver fails to properly detect a Window element on a Electron-based app Sep 15, 2017
orizens added a commit that referenced this issue Sep 26, 2017
@orizens orizens closed this as completed Sep 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants