-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Selection indicator and info box #1419
Conversation
This is "a slightly tweaked version of the JsHtmlSantizer object from https://github.com/mapbox/sanitize-caja"
The icon has 3 modes: 1. Enabled, for untracked objects with known positions. 2. Disabled but with the same icon as enabled, for objects being tracked. 3. Disabled and crossed out, for objects without positions. Note that the selection graphic is able to show un-trackable "scratch" positions, such as access lines, but the camera icon will appear disabled for these kinds of objects.
To provide context for others, this is our solution to HTML Balloon pop-ups you see in other apps like Google Earth and Leaflet. This code is actually based on the original work @hpinkos did in the |
@emackey If an object has no |
Good point, some of the code here, particularly for positioning the selection graphic, is directly based on @hpinkos early work on the balloon branch. Thanks Hannah! I'll add the |
So my last aesthetic related comment is that the selection box is a little big and bulky. Maybe we could make it smaller and not as thick? Another idea would be to just have the 4 corners, with gaps in between them. This is just my personal preference though, I'm fine if other people like it. |
Is there a reason that both the selection indicator and information window are the same widget? I was under the impression that they would be two separate widgets. The "Information" widget, for lack of a better term, is an overlay widget that any app could use to show information while the @shunter I'd be interested in hearing your thoughts on this as well. |
CHANGES.md! |
Can we add a Sandcastle example for how to use this? How many lines of code will it be? An older version was a ton of code; I couldn't even figure out how to do it; @mramato had to send me the code. |
Sure. It's meant to be wired up automatically when using the There was a deliberate design choice to have the new widget(s) not access any internals of dynamic objects, so they are not explicitly tied to the dynamic scene system unless you bring in the mixin. This means you can tie them to something else, but you're then responsible for manually updating positions, visibility, etc., which will be some non-trivial code. |
posY = Math.min(Math.max(position.y + posMin, posMin), posMaxY); | ||
|
||
var positionXPx = toPx(posX); | ||
if (viewModel._positionX !== positionXPx) { |
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.
These checks are unnecessary. Observables already check their new values for equality with the previous value before notifying subscribers.
PAUSE REVIEW.... refactoring into multiple widgets! Sorry! |
Well, now you've at least got a jump start on some comments 😄 |
return selectedObjectObservable(); | ||
}, | ||
set : function(value) { | ||
if (selectedObjectObservable() !== value) { |
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 know that trackedObject
was already the same way, but I wonder if it might be more clear to use a "plain" observable (ko.track
) for viewer.selectedObject
, and then subscribe to that observable to trigger these other changes, rather than using a computed observable that does nothing except trigger side effects.
Unit tests are broken, and the mixin isn't tolerant of the widgets being turned off yet.
@emackey I was running Sandcastle examples on my laptop to make sure everything was kosher and ran into usability issues due to the hard-coded width of the InfoBox. Rather than have it hardcoded to 360, I tweaked the css change
and got rid of the |
@@ -12,6 +12,7 @@ Beta Releases | |||
* Renamed `GeometryPipeline.createAttributeIndices` to `GeometryPipeline.createAttributeLocations`. | |||
* Renamed `attributeIndices` property to `attributeLocations` when calling `Context.createVertexArrayFromGeometry`. | |||
* `PerformanceDisplay` requires a DOM element as a parameter | |||
* Added new `SelectionIndicator` and `InfoBox` widgets, activated by `viewerDynamicObjectMixin`. |
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.
This needs to be updated since they are now part of Viewer
itself. Also, in addition to mentioning viewerDynamicObjectMixin
using them by default, we should add a code snippet here showing how to turn it off to go back to the old behavior.
Also removed an unused variable.
* Gets the visibility of the position indicator. | ||
* @type {Boolean} | ||
*/ | ||
this.showPosition = undefined; |
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'm sure I'm missing something but what is this variable for? I only discovered it by looking at the reference doc and I found it confusing since there's already a showSelection
.
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.
This could be converted to private, it's a combination of showSelection
being true along with position
being defined. The visibility of the indicator binds to this, not to showSelection
alone. Its name is perhaps a little dated, since it pre-dates the selection/info breakup. Maybe isSelectionIndicatorVisible
or something.
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.
It comes into play for things like access lines, that disappear.
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.
That's a little wordy, but isVisible
or isSelectionVisible
is fine with me.
You guys don't want this for b25, right? I'd like to start the release in the next hour or two. |
There's no need to wait for this. As excited as I am to get this feature out, like with any big feature we should have it in master for a while first to shake out any potential issues we missed. |
Sadly I agree, this feature could use some extra time on master before release. Also I would like to have the |
I agree completely. Thanks. |
So other than my width styling suggestion, is there anything else that still needs to be done here? Or are we good to go after b25 ships? |
I think we're good. @mramato can you add that styling to this branch and I'll test it? |
@emackey I'm not sure what's changed, but on a clean checkout of this branch, the InfoxBox is coming up with a transparent background. Are you seeing it too? |
Nevermind, it was something stupid I did. |
Rather than a hardcoded width, we now default to 25% or 360px, whichever is smaller.
@mramato it seems very thin below about 600px wide. Can we do |
I bumped it up to 40% as you asked. We can tweak it later as we start using it more. I agree 25% can be too thin, my thinking was that we should err on the side of thin rather than having the InfoBox obscure too much of the screen. |
On a thin screen, like a phone in portrait mode, we may have to allow the box to fill most of the screen, and provide some kind of mechanism to slide the box out of the way without canceling the selection. Possibly the "x" in the box's upper-right should just remove the box without removing the selection. Not sure how to get the box back if we did that, maybe single-click the selected item again. Seems like we'll have to play with a few options on mobile at some point. |
Selection indicator and info box
This adds a selection indicator and information box to viewerDynamicObjectMixin.
NOTE: This includes #1417, "Description property for CZML." It also introduces Google Caja for HTML sanitization.