Skip to content

scope.whenNotVisible is not a function #1

Closed
@jagged3dge

Description

@jagged3dge

Problem: scope.whenNotVisible is not a function is thrown if the when-not-visible attribute is omitted in the template markup.

Thank you for making this lovely gem of a directive. Much lighter than in-view too :)
However, here's a snag that I hit. I have this markup:

<div class="community-posts" when-visible="loadPosts">
  <!-- community post content here -->
</div>

and here's my relevant code from the controller:

var loadPosts = function ($el) {
  var posts = [{id: 1, content: 'foo bar'}, {id: 2, content: 'bar foo'}];
  return posts;
};
$scope.loadPosts = loadPosts;

But when I view the page, it throws this error in the console:

TypeError: scope.whenNotVisible is not a function

This line is where the debugger points to:

determineWhereElementIsInViewport(el, viewportHeight,
            scope.whenVisible(), scope.whenNotVisible(), delayPercent, scope);

This most likely has to do with how the reference to the whenVisible and whenNotVisible functions are passed around in the directive. If the when-not-visible attribute is omitted, scope.whenNotVisible itself remains undefined causing this error being thrown.

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