Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion angular-inview.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function inViewDirective ($parse) {
var elementRect = offsetRect(element[0].getBoundingClientRect(), options.offset);
var isVisible = !!(element[0].offsetWidth || element[0].offsetHeight || element[0].getClientRects().length);
var info = {
inView: isVisible && intersectRect(elementRect, viewportRect),
inView: isVisible && !element[0].classList.contains("ng-hide") && intersectRect(elementRect, viewportRect),
event: event,
element: element,
elementRect: elementRect,
Expand Down
22 changes: 21 additions & 1 deletion angular-inview.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,26 @@ describe("angular-inview", function() {
.then(done);
});

it("should not trigger in-view expression if ng-hide present and set to true", function(done) {
makeTestForHtml(
'<div in-view="spy($inview)" ng-hide="true"></div>'
)
.then(function (test) {
expect(test.spy.calls.count()).toBe(0);
})
.then(done);
});

it("should not trigger in-view expression if ng-hide present and set to false", function(done) {
makeTestForHtml(
'<div in-view="spy($inview)" ng-hide="false"></div>'
)
.then(function (test) {
expect(test.spy.calls.count()).toBe(1);
})
.then(done);
});

it("should change inview status when scrolling out of view", function(done) {
makeTestForHtml(
'<div in-view="spy($inview)"></div>' +
Expand Down Expand Up @@ -306,7 +326,7 @@ describe("angular-inview", function() {
//
// - `element`: An angular element inserted in the test page
// - `scope`: a new isolated scope that can be referenced in the element
// - `spy`: a conveninence jasmine spy attached to the scope as `spy`
// - `spy`: a convenience jasmine spy attached to the scope as `spy`
function makeTestForHtml(html) {
var test = {};
// Prepare test elements
Expand Down