Skip to content

Instantly share code, notes, and snippets.

@nk-o
Created November 21, 2019 13:38
Show Gist options
  • Save nk-o/f0f2e5bb92a8c52ba38f7cb5308a6092 to your computer and use it in GitHub Desktop.
Save nk-o/f0f2e5bb92a8c52ba38f7cb5308a6092 to your computer and use it in GitHub Desktop.
Documentation Advanced Backgrounds
(function ($) {
var $body = $('body');
// fullwidth gutenberg feature.
function stretchAWB() {
var wndW = $body.width();
$('.nk-awb.alignfull > .nk-awb-wrap').each(function () {
var $this = $(this);
var rect = this.getBoundingClientRect();
var left = rect.left;
var right = wndW - rect.right;
var ml = parseFloat($this.css('margin-left') || 0);
var mr = parseFloat($this.css('margin-right') || 0);
$this.css({
'margin-left': ml - left,
'margin-right': mr - right,
});
});
}
stretchAWB();
$(window).on('resize orientationchange load', stretchAWB);
}(jQuery));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment