Mobile FPS suffering due to slide-out drawer performance issues

My application features a drawer menu that functions smoothly on desktop, but experiences issues on mobile devices with noticeable lag.

Within the header, I have implemented a boolean value that toggles between true and false upon clicking the hamburger icon. This action adds an 'out' class to the '.container', causing it to slide out. The drawer is positioned absolutely on the page's top right corner. When the 'out' class is applied to the container, it shifts 280px to the right, revealing the drawer.

Below is a simplified version of the HTML and CSS code:

<div class="landing-page-container" ng-class="isMenuOut ? 'out' : ''">
<header/>
<main/>
<footer/>
</div>

<sidebar>

CSS:

.home-slide-menu{
  width: 280px;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: -1;
  overflow:hidden;
}

.landing-page-container{
  right:0;
  position: relative;
  transition: right 0.2s ease-in 0s;
}

.landing-page-container.out{
  right:280px;
  overflow: hidden;
}

If the provided details are insufficient for troubleshooting, please do let me know. Any red flags or additional information needed would be greatly appreciated for resolving this issue efficiently.

Answer №1

To achieve smooth animations, it is recommended to utilize 3D transforms.

When it comes to displaying content on the screen, the calculations can be handled by either the CPU or the GPU (graphics card). It is advisable to rely on the GPU for display tasks, especially for animation purposes.

How can you make sure your animations are hardware-accelerated by the GPU? By using translate3d! When you apply a transform using translate3d, the element is processed by the GPU in Webkit-based browsers such as Chrome and Safari (commonly used on devices like iPhones and iPads).

Here is an example showcasing this concept:

https://jsfiddle.net/asmsomtw/

Key CSS Code from the fiddle

/* Transition effect and timing */
div {
    transform: translate3d(0, 0%, 0);
    transition: transform 500ms ease-in;
}

/* Applying transform when toggling class to hide the drawer */
.hide {
    transform: translate3d(-100%, 0, 0);
}

Test this approach on your devices experiencing performance issues and try changing the values to right similar to your original implementation to observe any differences.

Remember not to overuse the GPU; choose wisely when opting for hardware acceleration.

Answer №2

Experience a smoother movement by experimenting with a 2D transform

-ms-transform: translate(-280px,0); /* IE 9 */
-webkit-transform: translate(-280px,0); /* Safari */
transform: translate(-280px,0); /* Standard syntax */

Answer №3

Have you considered using TweenMax? This JavaScript animation library is known for its compatibility with Angular and its focus on performance. Check it out here:

Even Google has recommended TweenMax: https://developers.google.com/web/fundamentals/look-and-feel/animations/css-vs-javascript?hl=en

Here's an example of how you can use TweenMax in Angular to achieve a similar effect:

function(){
    TweenMax.to(someDomElementAsVariable, 0.3, {
        right:"350px"
    });
};

This function will animate the 'right' property of someDomElementAsVariable to 350px over a duration of 0.3 seconds.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Positioning of DIV elements in relation to each other

I'm currently enrolled in Codecademy's HTML & CSS course and I'm finding the topic of positioning a bit perplexing. Here is an example of my HTML file: <!DOCTYPE html> <html> <head> <style> div { pos ...

Navigating to a specific route upon the arrival of a push notification (Angular, Ionic, ngcordova)

Imagine this situation. I am working with an ionic / angular app and implementing the ngcordova plugin for push notifications. Picture this: a push notification comes in while the app is running in the background. The user checks the notification in the ...

There are no warnings or errors when running Yeoman grunt build, however, the dist folder that is generated is not functioning

When working on an Angular application, I typically run either grunt build or grunt serve:dist to generate my production files and deploy them to a remote server. Despite everything appearing fine with no warning messages in the Yeoman logs and yo doctor g ...

Troubleshooting Autocomplete User Interface Problems

I am currently working on a website user interface and I have encountered an issue specifically in IE7. When searching for a company, the display is not showing up correctly, as demonstrated in the image below. This problem only occurs in IE7, it works fi ...

Angular is unable to POST to Rails server with the content-type set as application/json

Currently, I am attempting to send a POST request with Content-Type: application/json from Angular to my Rails backend. However, an error is being displayed in the console: angular.js:12578 OPTIONS http://localhost:3000/api/student_create 404 (Not Found ...

Enhancing the Security of Spring Rest Services: A Guide to Implementing Spring Security with AngularJS

I currently have a setup with a Spring MVC Server Backend hosting Rest-Services and an AngularJS WebFrontend. I'm looking to enhance the security of my spring mvc rest services, but I want to implement it using Java config. However, I am unsure about ...

Discovering the property name of an object in Angular using $watch

Is there a way to monitor an object for changes in any of its properties, and retrieve the name of the property that changed (excluding newValue and oldValue)? Can this be accomplished? ...

Using Javascript to Manuever an Element via Arrow Inputs

Currently, I am in the process of developing a Tetris game with a rotating Tetris piece controlled by pressing the space bar. My next objective is to enable the movement of objects to the left and right using the arrow keys. After exploring various simila ...

Identifying when an image has finished loading without utilizing a directive specifically assigned to the image element

There is a plethora of examples in SO demonstrating how to utilize an angular directive to detect when an image has been loaded. These examples typically showcase a directive that is directly added to the img element like this: <img ng-src="myimage.jpg ...

Are all elements still displaying the menuBar style? Using the PHP include function, <?php include... ?>

Here is the Menu Bar code I am using: <!DOCTYPE html> <html> <link href = menuBarStyle.css rel = "stylesheet"> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"> <div class = "menu"> ...

Change a 24-hour time variable to 12-hour time using AngularJS/jQuery technology

I have a value retrieved from the database in a 24-hour time string format. I am seeking a solution to convert this string into a 12-hour clock time using either AngularJS or jQuery. Currently, I am unable to make any changes to the back-end (JAVA) or the ...

Angular Protractor testing: achieving precise column name matching

I am new to writing protractor tests and currently navigating my way through it. The angular code I am trying to test looks like this: <tr ng-repeat="identifier in contentIdentifiers"> <td>{{identifier.contentIdentifier}}</td> & ...

What is the best way to showcase a div on top of all other elements in an HTML page?

As a newcomer to html and css, I have successfully created a div that contains city names. The issue I am currently facing is when I click on a button to display the div, it gets hidden behind the next section of my page. Take a look at the image below for ...

Can you use ng-show within ng-if in Angular?

How can I make this input only show a property is true per the ng-if? The current code looks like this: <input type="button" class="naviaBtn naviaBlue" ng-if="ppt.Globals.hasDebitCard" ng-click="alertShow = (alertShow == 2 ? -1 : 2)" value="outstandin ...

Tips for positioning an element in the center of a page using Bootstrap both horizontally and vertically

[Pardon my English] I recently managed to center my "logo" both horizontally and vertically. However, I am looking to have my logo shrink a bit when resizing the browser. Any suggestions on how to achieve this using bootstrap? Index.html <section> ...

Experiencing delays with AngularJS $http responses

I have this code snippet which is causing an issue: $http.get('/api/users'). success(function(data) { $scope.authors = data; }). error(function() { console.log('API error - configuration.') }); Further down in the code: for ( ...

ng-hide and ng-switch slow down content visibility

I am implementing a feature to display and hide a clear button based on whether the searchQuery is empty or not. The issue I am facing is that there is a noticeable delay in removing the clear button after the user either clicks it or deletes all input. I ...

Acquiring a fresh scope in Angular via a different component

In my project, I am developing an app using a component-based approach with Angular 1.5.5. As part of this development, I am utilizing d3js to create some elements with the class .floating-node. For each of these nodes, I am creating a new $scope and appe ...

Guide to centering a Material UI Table on a webpage

Is it possible to center the <Table> within a fixed width <div>, and have a scrollbar appear when the browser is resized, while maintaining the fixed width of the <Table>? Thanks in advance. This is my current setup: <div> ...

How come there is such a large space for clicking between my logo and the navigation bar, and what can be done to eliminate it?

* { box-sizing: border-box; padding: 0; margin: 0; } ul { list-style-type: none; } .nav-links, .logo { text-decoration: none; color: #000; } .logo { max-width: 80%; width: 20%; height: 20%; } .navbar img { width: 10%; height: auto; di ...