Initial details: In order to display the navigation menu effectively on mobile devices, I have created a fixed menu button. To enhance user experience, I am using the Headroom.js script to reduce the size of the button when scrolling down, preventing it from obstructing the content. This resizing animation is achieved by applying a specific class with the necessary changes.
In my original approach, I altered the appearance of the button by adjusting the height/width
of the parent element and the padding
of the child element through CSS (along with css transition).
The newer method involves modifying the button size using transform: scale()
. Additionally, I slightly move the element by incorporating translate3d(20px,20px,0)
in this technique. Although the transform: scale()
method provides a smoother scroll feel (possibly due to a placebo effect), analyzing Chrome Dev Tools' timeline does not offer definitive results.
Henceforth, I seek guidance on evaluating the preferred method. Is Chrome Dev Tools' timeline the optimal tool for assessment, or are there more effective approaches? Which aspects of the timeline should influence decision-making? Based on your interpretation of images and tests, which method theoretically performs better?
Below are two examples displayed on the timeline for each method: Original method using height/width alteration and padding adjustment: https://i.sstatic.net/ag14O.png
Method employing transform: scale()
for size adjustments:
https://i.sstatic.net/3Lfm3.png
Experiment with both methods using fiddles provided here:
Link to original method changing height/width and padding: Original method
Link to new method utilizing transform:scale
: New method
Please disregard any layout imperfections, especially concerning the button's appearance. The unattractive image within the menu button serves the purpose of showcasing an embedded image on my actual page and its potential impact on performance. Inclusion of background images also reflects the webshop nature of the site, exposing potential performance implications.
CSS snippet for the additional class implementing changes in the original method:
.mobile-nav.headroom--unpinned {
height: 40px;
width: 40px;
}
.headroom--unpinned .mobile-content{
padding-top:4px;
}
CSS code for the added class utilizing transform:scale()
:
.mobile-nav.headroom--unpinned {
transform:scale(.5) translate3d(20px,20px,0);
}
To summarize my inquiries:
How can I determine the most efficient method in terms of performance, and which approach do you believe yields superior outcomes?