Skip to content

Instantly share code, notes, and snippets.

@aliaghdam
Last active February 5, 2022 09:34
Show Gist options
  • Star 17 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
  • Save aliaghdam/414d6e7f916c056a121a98ba64d0b7c0 to your computer and use it in GitHub Desktop.
Save aliaghdam/414d6e7f916c056a121a98ba64d0b7c0 to your computer and use it in GitHub Desktop.
WordPress Visual Composer full width row ( stretche row ) fix for RTL
jQuery(document).ready(function() {
function bs_fix_vc_full_width_row(){
var $elements = jQuery('[data-vc-full-width="true"]');
jQuery.each($elements, function () {
var $el = jQuery(this);
$el.css('right', $el.css('left')).css('left', '');
});
}
// Fixes rows in RTL
jQuery(document).on('vc-full-width-row', function () {
bs_fix_vc_full_width_row();
});
// Run one time because it was not firing in Mac/Firefox and Windows/Edge some times
bs_fix_vc_full_width_row();
});
@fritexvz
Copy link

@serguk89 Thank you for the code. It finally working!
@WWGate Thank you for media CSS, working.

I am using WordPress 5.3.2 and WPBakery Page Builder 6.1.0, on Nginx (LEMP) with PHP 7.3 including plugins W3 Total Cache (page, browser, object, database + cloudflare setup) & Autooptimize (JS, HTML, CSS) and and CloudFlare Free Plan.

Do not know why it stopped working after upgrading WPBakery to the latest one, also switching on the better server -.-

Thanks again, solved my problem after a research and going crazy about it :D

@anasalpure
Copy link

anasalpure commented Dec 1, 2020

Hello
i tryed to improve this code

function bs_fix_vc_full_width_row() {
        if(jQuery('[data-vc-full-width="true"]:first').css( 'left' ) == 'auto') return;
        let rightAuto = jQuery('[data-vc-full-width="true"]:first').css( 'right' ) == 'auto' ;
        if( jQuery('html').attr('dir') == 'rtl' && !rightAuto){
            jQuery('[data-vc-full-width="true"]').each( function(i,v){
                jQuery(this).css('right' , jQuery(this).css('left') ).css( 'left' , 'auto');
            });
        }
    }

@laravelspa
Copy link

Hello
Only this code worked for me correctly

function bs_fix_vc_full_width_row(){
	 var $elements = jQuery('[data-vc-full-width="true"]');
	 jQuery.each($elements, function () {
		 var $el = jQuery(this);
		 $el.css('left', $el.css('right')).css('right', 'auto');
	 });
 }

@sindrome71
Copy link

You're the best @aliaghdam , saved my project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment