Skip to content

Conversation

@jspurlin
Copy link
Contributor

Pull request checklist

  • Addresses an existing issue: Fixes #0000
  • Include a change request file using $ npm run change

Description of changes

We've gotten reports that the existing expand on hover behavior can feel sluggish. After digging in we were delaying expand/collapse (and focus) updates for on mousemove (if the element was not already focused).

This PR makes it to where we no longer reset the delay on mousemove if there is already a pending action (from mouseenter/mousemove/mouseleave)

Before:
oldhoverupdatebehavior

After:
newhoverupdatebehavior

Focus areas to test

Verified that the hover behavior is more snappy while not suffering any negative side affects

…another pending mouse enter/move/leave to improve the snappiness of the updates
@jspurlin jspurlin requested a review from joschect as a code owner April 17, 2018 18:30

if (!this._isScrollIdle || targetElement === this._targetWindow.document.activeElement as HTMLElement) {
if (!this._isScrollIdle ||
this._enterTimerId !== undefined ||
Copy link
Collaborator

Choose a reason for hiding this comment

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

this._enterTimerId !== undefined [](start = 6, length = 32)

You actually do not need to do this. The following line of code will have the same affect and save you a few characters.

this._enterTimerId ||

Copy link
Contributor Author

Choose a reason for hiding this comment

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

While it shouldn't be zero if it is a valid id, I couldn't find anything that technically says zero is not a valid return value. I don't want to make any assumptions which might make this code more brittle

Copy link
Collaborator

Choose a reason for hiding this comment

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

OK sure. Your choice. I am certain it cannot be Zero. I know this because I have written such code more than once and never faced issues. That code has run for many years now.

https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout
he returned timeoutID is a positive integer value which identifies the timer created by the call to setTimeout();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

According to IEEE 754-2008 zero can be signed and is positive by default (and can sometimes be negative), that being said it doesn't make sense to risk it

@manishgarg1
Copy link
Collaborator

if (this._enterTimerId !== undefined) {

Same here, the following line will do the right thing for this code and save some bytes.

If (this._enterTimerId)


Refers to: packages/office-ui-fabric-react/src/components/ContextualMenu/ContextualMenu.tsx:810 in 0b996e5. [](commit_id = 0b996e5, deletion_comment = False)

@manishgarg1
Copy link
Collaborator

if (this._enterTimerId !== undefined) {

same as agove. In fact if there was a private method to clear the timout, we will same a bunch of repetitive.


Refers to: packages/office-ui-fabric-react/src/components/ContextualMenu/ContextualMenu.tsx:844 in 0b996e5. [](commit_id = 0b996e5, deletion_comment = False)

@manishgarg1 manishgarg1 self-assigned this Apr 17, 2018
Copy link
Contributor

@ddlbrena ddlbrena left a comment

Choose a reason for hiding this comment

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

:shipit:

@jspurlin jspurlin closed this Apr 18, 2018
@jspurlin jspurlin reopened this Apr 18, 2018
@jspurlin jspurlin merged commit 9cc47f5 into microsoft:master Apr 18, 2018
@microsoft microsoft locked as resolved and limited conversation to collaborators Aug 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants