-
-
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
Merged
etpinard
merged 4 commits into
plotly:master
from
monfera:29-emit-relayout-events-on-3d-camera-reset
Apr 21, 2016
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d6037c0
#29 add plotly_relayout event emission when camera is reset to defaul…
monfera 8dedb6e
#29 add test cases (they're in the CI excluded file but they pass fin…
monfera ff1d418
#29 different camera format, and ensuing code unification
monfera 57b2650
#29 ensure one call per scene, checking against correct callback argu…
monfera File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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,26 @@ describe('Test gl plot interactions', function() { | |
.toEqual({x: 2.5, y: 2.5, z: 2.5}); | ||
|
||
selectButton(modeBar, 'resetCameraDefault3d').click(); | ||
|
||
setTimeout(function() { | ||
|
||
expect(relayoutCallback).toHaveBeenCalledTimes(2); // initiator: resetCameraDefault3d; 2 scenes | ||
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(relayoutCallback).toHaveBeenCalledWith({ | ||
scene2: { | ||
center: { x: 0, y: 0, z: 0 }, | ||
eye: { x: 1.25, y: 1.25, z: 1.25 }, | ||
up: { x: 0, y: 0, z: 1 } | ||
} | ||
}); | ||
relayoutCallback.calls.reset(); | ||
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. nice move. |
||
|
||
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 +377,25 @@ describe('Test gl plot interactions', function() { | |
.toBeCloseToArray([1.25, 1.25, 1.25], 4); | ||
|
||
selectButton(modeBar, 'resetCameraLastSave3d').click(); | ||
|
||
setTimeout(function() { | ||
|
||
expect(relayoutCallback).toHaveBeenCalledTimes(2); // initiator: resetCameraLastSave3d; 2 scenes | ||
expect(relayoutCallback).toHaveBeenCalledWith({ | ||
scene: { | ||
center: { x: 0, y: 0, z: 0 }, | ||
eye: { x: 0.1, y: 0.1, z: 1 }, | ||
up: { x: 0, y: 0, z: 1 } | ||
} | ||
}); | ||
expect(relayoutCallback).toHaveBeenCalledWith({ | ||
scene2: { | ||
center: { x: 0, y: 0, z: 0 }, | ||
eye: { x: 2.5, y: 2.5, z: 2.5 }, | ||
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) | ||
|
@@ -364,7 +406,9 @@ describe('Test gl plot interactions', function() { | |
.toBeCloseToArray([2.5, 2.5, 2.5], 4); | ||
|
||
done(); | ||
|
||
}, MODEBAR_DELAY); | ||
|
||
}, MODEBAR_DELAY); | ||
}); | ||
}); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.