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

Tooltip Feature for ImageOverlays #1321

Merged
merged 74 commits into from
Jan 17, 2023
Merged

Tooltip Feature for ImageOverlays #1321

merged 74 commits into from
Jan 17, 2023

Conversation

segun-codes
Copy link
Collaborator

@segun-codes segun-codes commented Dec 29, 2022

Fixes #1317

Make sure these boxes are checked before your pull request (PR) is ready to be reviewed and merged. Thanks!

  • PR is descriptively titled 📑 and links the original issue above 🔗
  • tests pass -- look for a green checkbox ✔️ a few minutes after opening your PR -- or run tests locally with grunt test
  • code is in uniquely-named feature branch and has no merge conflicts 📁
  • screenshots/GIFs are attached 📎 in case of UI updates
  • @mention the original creator of the issue in a comment below for help or for a review

The GIFs below show the work done so far. However, the tooltip feature is also enabled in files listeners.html, select.html, local.html, and export.html.
index.html
01

archive.html
02_2

We're happy to help you get this ready -- don't be afraid to ask for help, and don't be discouraged if your tests fail at first!

If tests do fail, click on the red X to learn why by reading the logs.

Please be sure you've reviewed our contribution guidelines at https://publiclab.org/contributing-to-public-lab-software

Thanks!

segun-codes and others added 30 commits December 9, 2022 15:21
@segun-codes
Copy link
Collaborator Author

Hi @jywarren, this PR is now ready for merging. Many thanks!

@segun-codes
Copy link
Collaborator Author

Hi @jywarren, this PR is now ready for merging. Many thanks!

Hi @jywarren, still waiting for you to merge. Many thanks!

.gitignore Outdated
@@ -1,6 +1,7 @@
node_modules
coverage
todo.txt
observation.txt
Copy link
Member

Choose a reason for hiding this comment

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

Ah, is this something we need in the shared .gitignore or just for you? I'm ok either way i guess, I'm just thinking it's not 100% necessary to share.

Copy link
Collaborator Author

@segun-codes segun-codes Jan 16, 2023

Choose a reason for hiding this comment

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

Oh! yeah... I'd would remove these fast, thanks for spotting them @jywarren.

position: absolute;
}

/* .tooltipText {
Copy link
Member

Choose a reason for hiding this comment

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

Should we remove this if you're not using it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Surely, I will remove it fast, thanks!

@@ -61,12 +62,14 @@ <h2 class="modal-title">Welcome to MapKnitter Lite</h2>
<i title="Open Sidebar" id="mapToggle" class="fa fa-bars fa-3x " style="position: absolute; right: 0; top:30px; margin: 1rem; z-index: 900; color: white; cursor: pointer;" aria-hidden="true"></i>

<div id="map" style="width:100%; height:100%; position:absolute; top:0;"></div>
<!-- <div id="imageOverlaytooltip" class="distortableImageTooltip"><span id="tooltiptext" class="tooltiptext"></span></div> -->
Copy link
Member

Choose a reason for hiding this comment

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

And this? Thanks!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, please. I will, thanks!

@@ -127,6 +136,10 @@ function showImages(getUrl) {
axios.get(url)
.then((response) => {
if (response.data.files && response.data.files.length != 0) {
response.data.files.forEach(() => {
imageTooltipText = response.data.metadata.description;
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, wait, if this is defined as a single variable at the scope of the whole page, don't we overwrite it with each image?

Copy link
Member

Choose a reason for hiding this comment

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

I guess we need a way to save this description in a way that associates it with each image? Couldn't we assign a new property to response.data.files?

Hmm. Wait. Originally this was supposed to tell us about the individual image (from the description in #1317). Now i realize it's adding the description of the whole collection, isn't it? Maybe we can simplify things if we skip these four lines, and instead use the filename as the tooltip. Then it's already stored as part of each entry in imageThumbnails fullResImages below, right? That would be significantly simpler code!

Copy link
Collaborator Author

@segun-codes segun-codes Jan 16, 2023

Choose a reason for hiding this comment

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

It appears files in archive.org/details/texas-barnraising/ have same description so the tooltip will show same description for each of the files in the said folder when placed on the tiled layer. However, if you fetch images with individual descriptions (such as in the gif illustration #4 above), then the correct tooltip (i.e., description of image) is displayed for each of the images.

Okay, so great idea, I will use the filename as the tooltip text. Users will only be required to save their images to internet archive using suggestive names . Many thanks!

const imageURL = event.target.previousElementSibling.src;
image = L.distortableImageOverlay(
imageURL,
{tooltipText: imageTooltipText}
Copy link
Member

Choose a reason for hiding this comment

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

If we used the filename, we could just split event.target.previousElementSibling.src with split('/') and take any text after the final / - saving us a lot of complexity above, see?

Copy link
Collaborator Author

@segun-codes segun-codes Jan 16, 2023

Choose a reason for hiding this comment

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

Nice.... I'll give this a shot. Many thanks!

@@ -146,7 +153,7 @@ L.DistortableImageOverlay = L.ImageOverlay.extend({
},

isSelected() {
return this._selected;
return this._selected; // this._selected
Copy link
Member

Choose a reason for hiding this comment

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

Just a comment to be removed here, thanks!

And a few other console.log() statements throughout as well!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, please... I will remove them all. Thanks!

src/DistortableImageOverlay.js Outdated Show resolved Hide resolved
@@ -1,4 +1,6 @@
let map;
let image;
let imageTooltipText;
Copy link
Member

Choose a reason for hiding this comment

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

This can be removed if we follow some of the steps I outlined lower in this file to simplify things...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure... I will, thanks!

@@ -2,6 +2,7 @@ const arr = [];
L.DistortableCollection = L.FeatureGroup.extend({
options: {
editable: true,
tooltipControl: document.createElement('button'),
Copy link
Member

Choose a reason for hiding this comment

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

Hi @segun-codes -- I appreciate this toggling system here, and I know it's really challenging to dig into the guts of this library, and you've done a really really great job writing well-organized, easy to read code here. So congratulations.

However, I am just thinking... weighing complexity vs. benefit in balance, I ultimately think it's not worth it to have a permanent button-management system within the core library code. I have to think of what else people might do with tooltips, if they'd work the same way, if this code would need maintenance in the distant future, and so on... and ultimately you really solved most of the problem of the tooltips potentially interfering with things by making tooltips default off.

I'd like to ask you to keep the tooltip /creation/ code as it is in src/DistortableImageOverlay.js, but to remove the UI code from this file, and the button toggling the tooltips. I think it presents the user with another button which has a function not related to actual mapmaking, and I worry it's just not worth the added complexity, both for code, and for the user having to learn what the button is for.

I hope you understand and agree -- and once more, you've done a stellar job at architecting this UI and managing it, and integrating code into a complex library. I just think the better judgement call is to keep our changes to the core library simple and concise.

Thank you, Segun!!

Copy link
Collaborator Author

@segun-codes segun-codes Jan 16, 2023

Choose a reason for hiding this comment

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

Oh! @jywarren, your line of thought is quite inspiring, I like it. Many thanks! So I guess it's okay to move the button-management system to archive.js, right?

And yeah, I do appreciate your commendations, worth a lot for me.

Copy link
Member

Choose a reason for hiding this comment

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

For now, can you save the button management code in an issue, and we can wait and see if any issues ever come up with the tooltips obscuring or blocking things, and we can make a decision about including the button code later?

That will also keep this PR a bit narrower in scope and still achieve our main goal, but give us flexibility to respond later if we find the tooltips need more work. How does that sound? Thank you!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sounds okay, since it's for experimental purposes for the time being.

Copy link
Collaborator Author

@segun-codes segun-codes Jan 16, 2023

Choose a reason for hiding this comment

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

For now, can you save the button management code in an issue, and we can wait and see if any issues ever come up with the tooltips obscuring or blocking things, and we can make a decision about including the button code later?

That will also keep this PR a bit narrower in scope and still achieve our main goal, but give us flexibility to respond later if we find the tooltips need more work. How does that sound? Thank you!

@jywarren, I have reverted to the earlier implementation (with some improvements) consistent with your advice. Kindly review and perhaps, consider for merging too. Please, view the gif file below. And as advised, here's the new issue #1329.

Illustration 5
Illustration 5

examples/js/archive.js Outdated Show resolved Hide resolved
.gitignore Outdated Show resolved Hide resolved
examples/js/archive.js Outdated Show resolved Hide resolved
@jywarren jywarren merged commit 68498e9 into publiclab:main Jan 17, 2023
@jywarren
Copy link
Member

🎉 🎉 🎉 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Augment ImageOverlay with Brief Relevant Information
3 participants