Initially, I have a main panel hidden and set to slide out when the website is running. The CSS styling for this panel is as follows:
.contentPanel {
top: calc(40% - 1px);
height: 50%;
padding:10px;
font-size:1.2em;
overflow-y: scroll;
overflow-x: hidden;
left: 20%;
width: 75%;
}
.contentPanel{
transition: transform 5000ms cubic-bezier(0.095, 0.725, 0.020, 1.005);
}
As the website starts running, jQuery calculates the window's width and hides the panel by translating it out of view on the X-axis:
$('.contentPanel').css('left',window.innerWidth+"px");
Then, in theory, CSS is supposed to move the panel back to its correct position by adding the .expanded
class:
$('.contentPanel').addClass('expanded');
This should translate the panel back to its original position at 0% on the X-axis:
.expanded {
transform: translate(0%);
}
However, there is a problem where CSS does not take effect because jQuery styles the .contentPanel
directly on its HTML tag, like so:
<div class="contentPanel expanded" style="left: 1366px;">
Even though a translateX(0%) is added in the CSS, nothing appears to happen since the pixel value is given in the HTML attribute.