Skip to content
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

Gallery::Imagery Layers Split #5948

Merged
merged 7 commits into from
Nov 2, 2017
Merged
Changes from 3 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
48 changes: 31 additions & 17 deletions Apps/Sandcastle/gallery/Imagery Layers Split.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
left: 50%;
top: 0px;
background-color: #D3D3D3;
width: 2px;
width: 5px;
height: 100%;
z-index: 9999;
}
Expand Down Expand Up @@ -68,27 +68,41 @@
var slider = document.getElementById('slider');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really relevant to your changes, but can you add infoBox: false as an option when creating the viewer? It will keep the infobox from popping up without any information.

viewer.scene.imagerySplitPosition = (slider.offsetLeft) / slider.parentElement.offsetWidth;

var dragStartX = 0;
var handler = new Cesium.ScreenSpaceEventHandler(slider);

document.getElementById('slider').addEventListener('mousedown', mouseDown, false);
window.addEventListener('mouseup', mouseUp, false);
var bMoveActive = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please call this just moveActive, (or maybe slideActive).


function mouseUp() {
window.removeEventListener('mousemove', sliderMove, true);
}
function move(movement){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting should be consistant with the rest of the code base.
function move(movement){ -> function move(movement) {
if(!bMoveActive){ -> if (!bMoveActive) {

if(!bMoveActive){
return;
}

function mouseDown(e) {
var slider = document.getElementById('slider');
dragStartX = e.clientX - slider.offsetLeft;
window.addEventListener('mousemove', sliderMove, true);
var nMove = movement.endPosition.x ;//- movement.startPosition.x;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nMove -> movementAmount or something more descriptive

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the extra comment

var splitPosition = (slider.offsetLeft + nMove) / slider.parentElement.offsetWidth;
slider.style.left = 100.0 * splitPosition + "%";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we use single quotes ' throughout our js

viewer.scene.imagerySplitPosition = splitPosition;
}

function sliderMove(e) {
var slider = document.getElementById('slider');
var splitPosition = (e.clientX - dragStartX) / slider.parentElement.offsetWidth;
slider.style.left = 100.0 * splitPosition + "%";
viewer.scene.imagerySplitPosition = splitPosition;
}
handler.setInputAction(function(movement) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to include the movement parameter in the function if you're not going to use it.

bMoveActive = true;
}, Cesium.ScreenSpaceEventType.LEFT_DOWN);
handler.setInputAction(function(movement) {
bMoveActive = true;
}, Cesium.ScreenSpaceEventType.PINCH_START);

handler.setInputAction(function(movement) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be shoehorned to

handler.setInputAction(move, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
handler.setInputAction(move, Cesium.ScreenSpaceEventType.PINCH_MOVE);

move(movement);
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
handler.setInputAction(function(movement) {
move(movement);
}, Cesium.ScreenSpaceEventType.PINCH_MOVE);

handler.setInputAction(function(movement) {
bMoveActive = false;
}, Cesium.ScreenSpaceEventType.LEFT_UP);
handler.setInputAction(function(movement) {
bMoveActive = false;
}, Cesium.ScreenSpaceEventType.PINCH_END);


//Sandcastle_End
Expand Down