Audio Shortcode Animation – Progress Rail Disappears
-
I’ve animated the Audio Shortcode using max-width but the issue is that the progress rail does not animation with it. Whenever I try to update the width via JQuery it is being overwritten after the fact. Here’s what I am doing to animate my audio shortcode:
1) Add container:
function audio_shortcode_container( $html ) { return "<div class=\"audioContainer\">{$html}</div>"; } add_filter( 'wp_audio_shortcode', 'audio_shortcode_container' );
The CSS which handles the animation:
div.audioContainer { max-width: 80px; overflow: hidden; -webkit-transition: max-width 0.5s; transition: max-width 0.5s; } div.audioContainer.active { max-width: 100%; }
Finally, the JQuery that triggers the animation:
jQuery( document ).ready( function( $ ) { $( 'div.audioContainer' ).click( function() { var containerWidth = $( '#content' ).width(); $( this ).addClass( 'active' ); $( this ).find( 'audio' )[0].play(); $( this ).find( '.mejs-time-rail' ).css( 'width', ( containerWidth - 174 ) + 'px' ); // Gets overwritten $( this ).find( '.mejs-time-total' ).css( 'width', ( containerWidth - 184 ) + 'px' ); // Gets overwritten } ); } );
So, whenever the active class is added it trigger the CSS animation and starts to play the audio file. The problem is ( I believe ) whenever the audio-file is triggered to play the progress bar is updated with a
style
width attribute and supersedes my JQuery style update above.How can I update the progress bar to also show whenever I trigger this animation?
- The topic ‘Audio Shortcode Animation – Progress Rail Disappears’ is closed to new replies.