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

(CHROME) Added onclick handler to freeze current measurement. #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cferriss
Copy link

Added freeze ability so we can compare/screenshot multiple measurements
at the same time.

Single click will freeze/lock current lines/tooltip, and allow you continue to other areas with a new set of lines/tooltip.

Chrome only.

Added freeze ability so we can compare/screenshot multiple measurements
at the same time
@cferriss
Copy link
Author

image

@mrflix
Copy link
Owner

mrflix commented Mar 14, 2017

Now thats a cool idea!

Great code! I think the only thing I would have done differently would be that I'd add a class is-frozen instead of switching the classes. That wouldn't require touching the CSS.
forEach on nodes - nice! Didn't know about it yet! Though its Firefox 50 only so maybe it makes still sense to replace it with for()? (the current version is 51 and the extension as it is right now works with Firefox too).
Question: I've never used removeChild. I usually remove the elements itself by using .remove(). Is there an advantage?

How do you remove all frozen dimensions? Alt+D twice?

@cferriss
Copy link
Author

Thanks!

is-frozen CSS: I was trying to avoid multiple class lookups on each mouse move event, but I think the following lookups wouldn't be too expensive: body.querySelector('.fn-dimensions:not(.is-frozen)') and body.querySelector('.fn-dimensions.is-frozen'). I agree with your thoughts, i'll change it.

forEach: This works because we are iterating over an array of nodes, so it behaves like any typical JS array. The native forEach extension has been available for awhile: Array.forEach definition. Unless i misunderstood your comment, i think we are OK to use it.

removeChild: I used this over .remove() to stay consistent with the default element removal in the same method, Ln 118. I don't see an advantage one way or the other here.

Removing frozen dimensions: The only removal logic i put in place is when you toggle the extension off. Any specific key combo you would prefer if I add additional listeners in place?

Julian-Alberts pushed a commit to Julian-Alberts/dimensions that referenced this pull request Apr 24, 2021
Added freeze ability so we can compare/screenshot multiple measurements
at the same time
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.

2 participants