Skip to content

Commit

Permalink
Merge pull request aframevr#1975 from ryanbetts/bugfix-1959
Browse files Browse the repository at this point in the history
fixed leaveCurrentIntersection not defined and added a test for it (fixes aframevr#1959)
  • Loading branch information
ngokevin authored Oct 13, 2016
2 parents c0da86f + 4f50cda commit 57ba935
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/components/cursor.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ module.exports.Component = registerComponent('cursor', {
if (this.intersectedEl === intersectedEl) { return; }

// Unset current intersection.
if (this.intersectedEl) { this.leaveCurrentIntersection(); }
if (this.intersectedEl) { this.clearCurrentIntersection(); }

// Set new intersection.
this.intersection = intersection;
Expand Down Expand Up @@ -136,7 +136,7 @@ module.exports.Component = registerComponent('cursor', {
// Ignore if the event didn't occur on the current intersection.
if (intersectedEl !== this.intersectedEl) { return; }

this.clearCurrentIntersection(intersectedEl);
this.clearCurrentIntersection();
},

clearCurrentIntersection: function () {
Expand Down
19 changes: 19 additions & 0 deletions tests/components/cursor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ suite('cursor', function () {
var cursorEl = this.cursorEl = document.createElement('a-entity');
this.intersection = {distance: 10.5};
this.intersectedEl = document.createElement('a-entity');
this.prevIntersectedEl = document.createElement('a-entity');
cameraEl.setAttribute('camera', 'active: true');
cursorEl.setAttribute('cursor', '');

Expand Down Expand Up @@ -205,6 +206,24 @@ suite('cursor', function () {
assert.ok(cursorEl.is('cursor-hovering'));
});

test('emits a mouseleave event on the prevIntersectedEl', function (done) {
var cursorEl = this.cursorEl;
var intersection = this.intersection;
var intersectedEl = this.intersectedEl;
var prevIntersectedEl = this.prevIntersectedEl;
prevIntersectedEl.addEventListener('mouseleave', function (evt) {
done();
});
cursorEl.emit('raycaster-intersection', {
intersections: [intersection],
els: [prevIntersectedEl]
});
cursorEl.emit('raycaster-intersection', {
intersections: [intersection],
els: [intersectedEl]
});
});

test('does not set fusing state on cursor if not fuse', function () {
var cursorEl = this.cursorEl;
var intersection = this.intersection;
Expand Down

0 comments on commit 57ba935

Please sign in to comment.