-
Notifications
You must be signed in to change notification settings - Fork 92
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
fix(all): update panScale for panning sensitivity when size is changed. #209
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7b39e28
test(all): add FullScreen manual test.
e5a63f0
refactor(PanoViewer): refactoring updateViewportDimension
7c19df3
fix(YawPitchControl): update panScale when calling _updateControlScale
32e9643
fix(all): update pan scale when fov or height is changed.
0c2568c
test(YawPitchControl): add test for updatePanScale after fov change
d3b8472
skip: fix lint
93d1626
skip: apply review
37e853b
test(PanoViewer): makes delta smaller to make little rotation
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 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 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 |
---|---|---|
|
@@ -124,8 +124,8 @@ const YawPitchControl = class YawPitchControl extends Component { | |
}, | ||
change: evt => { | ||
if (evt.delta.fov !== 0) { | ||
this._setPanScale(evt.pos.fov); | ||
this._updateControlScale(evt); | ||
this.updatePanScale(); | ||
} | ||
this._triggerChange(evt); | ||
}, | ||
|
@@ -140,12 +140,23 @@ const YawPitchControl = class YawPitchControl extends Component { | |
}); | ||
} | ||
|
||
_setPanScale(fov) { | ||
const areaHeight = parseInt(getComputedStyle(this._element).height, 10); | ||
/** | ||
* Update Pan Scale | ||
* | ||
* Scale(Sensitivity) values of panning is related with fov and height. | ||
* If at least one of them is changed, this function need to be called. | ||
* @param {*} param0 | ||
*/ | ||
updatePanScale(param) { | ||
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. nit updatePanScale(param={}){
const areaHeight = param.height || parseInt(getComputedStyle(this._element).height, 10);
} 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. @mixed I'll apply it! Thank you 👍 |
||
const fov = this.axes.get().fov; | ||
const areaHeight = | ||
(param && param.height) || parseInt(getComputedStyle(this._element).height, 10); | ||
const scale = MC_BIND_SCALE[0] * fov / this._initialFov * PAN_SCALE / areaHeight; | ||
|
||
this.axesPanInput.options.scale = [scale, scale]; | ||
this.axes.options.deceleration = MC_DECELERATION * fov / MAX_FIELD_OF_VIEW; | ||
|
||
return this; | ||
} | ||
|
||
/* | ||
|
@@ -217,6 +228,11 @@ const YawPitchControl = class YawPitchControl extends Component { | |
key === "yawRange" || key === "pitchRange" | ||
)) { | ||
this._updateControlScale(); | ||
|
||
// If fov is changed, update pan scale | ||
if (keys.indexOf("fov") >= 0) { | ||
this.updatePanScale(); | ||
} | ||
} | ||
|
||
if (keys.some(key => key === "fovRange")) { | ||
|
@@ -237,6 +253,7 @@ const YawPitchControl = class YawPitchControl extends Component { | |
fov: nextFov | ||
}, 0); | ||
this._updateControlScale(); | ||
this.updatePanScale(); | ||
} | ||
} | ||
|
||
|
@@ -540,7 +557,8 @@ const YawPitchControl = class YawPitchControl extends Component { | |
// touchDirection is decided by parameter is valid string (Ref. Axes.connect) | ||
this._applyOptions(Object.keys(this.options), this.options); | ||
|
||
this._setPanScale(this.getFov()); | ||
// TODO: Is this code is needed? Check later. | ||
this.updatePanScale(); | ||
|
||
return this; | ||
} | ||
|
This file contains 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 |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>FullScreen Example</title> | ||
<meta name="description" content="PanoViewer"> | ||
<meta name="author" content="egjs"> | ||
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"> | ||
<link rel="stylesheet" href="../css/semantic.min.css"> | ||
<style> | ||
#panoviewer-showcase { | ||
position: relative; | ||
width: 100%; | ||
height: 320px; | ||
margin: 0 auto; | ||
} | ||
|
||
#panoviewer-showcase.fullscreen { | ||
width: 100%; | ||
height: 100%; | ||
} | ||
|
||
#fullscreen-toggle { | ||
position: absolute; | ||
top: 10px; | ||
right: 10px; | ||
z-index: 2; | ||
} | ||
|
||
#fullscreen-container { | ||
position: absolute; | ||
display: none; | ||
left:0; | ||
top:0; | ||
width: 100%; | ||
height: 100%; | ||
} | ||
|
||
#fullscreen-container.activate { | ||
display: block; | ||
background-color:white; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="ui menu"> | ||
<div class="ui container"> | ||
<div class="header item"> | ||
PanoViewer | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="ui main text container"> | ||
<h1 class="ui header">Full Screen</h1> | ||
|
||
<div class="ui segment"> | ||
<button id="fullscreen-toggle" class="ui icon button"> | ||
<i class="expand icon"></i> | ||
</button> | ||
<div id="panoviewer-showcase"></div> | ||
</div> | ||
</div> | ||
<div id="fullscreen-container"></div> | ||
|
||
<!--To use semantic-ui--> | ||
<script src="../lib/jquery-3.3.1.min.js"></script> | ||
<script src="../lib/semantic.min.js"></script> | ||
<script src="../../../node_modules/hammerjs/hammer.js"></script> | ||
<script src="../../../node_modules/@egjs/component/dist/component.js"></script> | ||
<script src="../../../node_modules/@egjs/axes/dist/axes.js"></script> | ||
<script src="../../../dist/view360.js"></script> | ||
<script src="../js/FullScreen.js"></script> | ||
<script> | ||
var isFullScreen = false; | ||
var container = document.getElementById("panoviewer-showcase"); | ||
|
||
var PanoViewer = eg.view360.PanoViewer; | ||
var panoViewer = new PanoViewer(container, { | ||
yaw: 180, | ||
image: "../img/test_equi_4096.jpg" | ||
}); | ||
|
||
document.getElementById("fullscreen-toggle").addEventListener("click", function() { | ||
isFullScreen = !isFullScreen; | ||
isFullScreen ? FullScreen.request() : FullScreen.exit(); | ||
|
||
panoViewer.updateViewportDimensions(); | ||
}); | ||
|
||
window.addEventListener("resize", function() { | ||
panoViewer.updateViewportDimensions(); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
1,008 changes: 1,008 additions & 0 deletions
1,008
test/manual/css/themes/default/assets/fonts/brand-icons.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.
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.
I think that
updateViewportDimensions
can make simple using destructuring assignment.How about it?
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.
@mixed Thank you for suggestion. That makes code more neat!
I'll apply it except the some logical part. Because there's some difference that I've intended.