-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Trigger plotly_relayout event when camera is reset to default or saved (Solves #FI29) #458
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
Changes from 3 commits
d6037c0
8dedb6e
ff1d418
57b2650
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -229,7 +229,7 @@ describe('Test gl plot interactions', function() { | |
}); | ||
|
||
describe('gl3d modebar click handlers', function() { | ||
var modeBar; | ||
var modeBar, relayoutCallback; | ||
|
||
beforeEach(function(done) { | ||
var mockData = [{ | ||
|
@@ -245,8 +245,13 @@ describe('Test gl plot interactions', function() { | |
|
||
gd = createGraphDiv(); | ||
Plotly.plot(gd, mockData, mockLayout).then(function() { | ||
|
||
modeBar = gd._fullLayout._modeBar; | ||
|
||
relayoutCallback = jasmine.createSpy('relayoutCallback'); | ||
|
||
gd.on('plotly_relayout', relayoutCallback); | ||
|
||
delay(done); | ||
}); | ||
}); | ||
|
@@ -342,7 +347,18 @@ describe('Test gl plot interactions', function() { | |
.toEqual({x: 2.5, y: 2.5, z: 2.5}); | ||
|
||
selectButton(modeBar, 'resetCameraDefault3d').click(); | ||
|
||
setTimeout(function() { | ||
|
||
expect(relayoutCallback).toHaveBeenCalled(); // initiator: resetCameraDefault3d | ||
expect(relayoutCallback).toHaveBeenCalledWith({ | ||
scene: { | ||
eye: { x: 1.25, y: 1.25, z: 1.25 }, | ||
center: { x: 0, y: 0, z: 0 }, | ||
up: { x: 0, y: 0, z: 1 } | ||
} | ||
}); | ||
|
||
expect(sceneLayout.camera.eye) | ||
.toEqual({x: 0.1, y: 0.1, z: 1}, 'does not change the layout objects'); | ||
expect(scene.camera.eye) | ||
|
@@ -353,7 +369,18 @@ describe('Test gl plot interactions', function() { | |
.toBeCloseToArray([1.25, 1.25, 1.25], 4); | ||
|
||
selectButton(modeBar, 'resetCameraLastSave3d').click(); | ||
|
||
setTimeout(function() { | ||
|
||
expect(relayoutCallback).toHaveBeenCalled(); // initiator: resetCameraLastSave3d | ||
expect(relayoutCallback).toHaveBeenCalledWith({ | ||
scene: { | ||
eye: { x: 1.25, y: 1.25, z: 1.25 }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This assertion is misleading. Adding console.log(getOrbitCamera(cameraData)) above this line in [[0.1, 0.1, 1], [0, 0, 0], [0, 0, 1]] for the first scene, and [[2.5, 2.5, 2.5], [0, 0, 0], [0, 0, 1]] for the second scene. I think the jasmine spy, holds on to the arguments of the first Moreover, we should make it clear that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @etpinard, I'll try to capture the multi-scene aspect. |
||
center: { x: 0, y: 0, z: 0 }, | ||
up: { x: 0, y: 0, z: 1 } | ||
} | ||
}); // looks like there's no real saved data so it reverts to default | ||
|
||
expect(sceneLayout.camera.eye) | ||
.toEqual({x: 0.1, y: 0.1, z: 1}, 'does not change the layout objects'); | ||
expect(scene.camera.eye) | ||
|
@@ -364,7 +391,9 @@ describe('Test gl plot interactions', function() { | |
.toBeCloseToArray([2.5, 2.5, 2.5], 4); | ||
|
||
done(); | ||
|
||
}, MODEBAR_DELAY); | ||
|
||
}, MODEBAR_DELAY); | ||
}); | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice clean up.