-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Improve touch tap performance #412
Conversation
@@ -89,6 +90,7 @@ const defaultProps = { | |||
|
|||
renderDay: null, | |||
renderCalendarInfo: null, | |||
calculateToday: true, |
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.
ideally boolean props always default to false
, such that absence and false
are the same - the main exception is when the default is intended to be flipped later in a semver-major bump. If that's not the case here, could this be renamed so that it can default to false
?
76c19cf
to
1988d19
Compare
@majapw I removed the |
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.
Let's maybe conditionally send down some of the other modifiers as well, but let's separate out the calculateToday
change into a separate PR like we discussed today.
// while start date has been set, but end date has not been | ||
'hovered-span': day => this.isInHoveredSpan(day), | ||
'after-hovered-start': day => this.isDayAfterHoveredStartDate(day), | ||
'last-in-range': day => this.isLastInRange(day), | ||
|
||
// once a start date and end date have been set | ||
'selected-start': day => this.isStartDate(day), |
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.
What if we did something similar for the selection related ones?
selected-start
requires START_DATE
to exist,
selected-end
and blocked-minimum-nights
require END_DATE
,
selected-span
and last-in-range
require both,
we could apply those conditionals within the touch params as well.
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.
Looks great to me.
Hey, I came across this part of the code, white trying to make a |
Hi @palashkaria, this code doesn't even exist anymore in Spreading (leading |
Hey, @majapw I see that now you do modifiers in CWRP, right? I was probably looking at an old version. Thanks for the quick explaination. |
to: @majapw @lencioni
This PR skips expensive modifier calculations that slow down render performance. These modifiers are computed for every calendar day, which becomes problematic on mobile if we're showing more months.
I instrumented the time spent in each modifier and tested on my Pixel. The total time is ~400ms. 70ms were spent for the
today
check, and 60ms were spent in the hover checks. I've disabled hover for mobile and added the optional to skip thetoday
check.The
calculateToday
prop isn't the cleanest approach, but I think the perf problem is serious enough to address immediately as we work on a more general fix. On this note, I've discussed an approach with Maja of computing these modifiers strictly at the top level instead of lazily at the leaves. This will allow optimizations like only computing today once and only recomputing affected date ranges.