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

Chore: Refactor controls for mobile #174

Merged
merged 4 commits into from
Jun 26, 2017
Merged

Chore: Refactor controls for mobile #174

merged 4 commits into from
Jun 26, 2017

Conversation

jeremypress
Copy link
Contributor

Tests to be added

@@ -264,6 +264,10 @@ class Browser {
return document.implementation.hasFeature('http://www.w3.org/TR/SVG11/feature#BasicStructure', '1.1');
}

static hasTouch() {
return 'ontouchstart' in window || (window.DocumentTouch && document instanceof DocumentTouch);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could either use this (from modernizr), or always bind all events, or wait until a touch start as suggest by this article: https://medium.com/@david.gilbertson/the-only-way-to-detect-touch-with-javascript-7791a3346685

* taken from Modernizr: https://github.com/Modernizr/Modernizr/blob/5eea7e2a213edc9e83a47b6414d0250468d83471/feature-detects/touchevents.js#L40
*
* @public
* @return {boolean} is touch supported
Copy link
Contributor

Choose a reason for hiding this comment

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

@return {boolean} Is touch supported (or without the description since @bhh1988 suggested what is returned can often be implied). The JSDoc ESLint verification also doesn't require a return description

Copy link
Contributor Author

@jeremypress jeremypress Jun 21, 2017

Choose a reason for hiding this comment

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

Fixed, but just as a heads up I got a warning when I tried removing the return description.

return !!element && element.classList.contains('bp-controls-btn');
return (
!!element &&
(element.classList.contains('bp-controls-btn') || element.parentNode.classList.contains('bp-controls-btn'))
Copy link
Contributor

Choose a reason for hiding this comment

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

Make string a const

*
* @property {boolean}
*/
controlsFocused = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Since you are inside the Controls class already, this would be better named as isFocused

event.preventDefault();
// If we are not focused in on the page num input, allow hiding after timeout
if (!this.controlsFocused) {
this.blockHiding = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't need the if, both values are boolean, can just use assignment.

*
* @property {boolean}
*/
blockHiding = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

I recommend not using double negatives. Hard to read and easy to make mistakes. shouldNotHide = true might be better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Switching to shouldHide = true for now. This has no negatives by default and basically follows the opposite of isFocused. Makes sense to me but I'm open to other suggestions.

@jeremypress jeremypress merged commit 066a3d4 into box:master Jun 26, 2017
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.

5 participants