Skip to content

Instantly share code, notes, and snippets.

@dimsemenov
Last active June 10, 2023 15:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dimsemenov/7ab69f4011d03f983b3e40204029f532 to your computer and use it in GitHub Desktop.
Save dimsemenov/7ab69f4011d03f983b3e40204029f532 to your computer and use it in GitHub Desktop.
// Add to your theme functions.php
//
// Moves slider to the root element of the page when fullscreen is entered,
// and back to the original position when fullscreen is exit.
function add_additional_rs_code() {
?>
var sliderEl = $('.royalSlider');
var sliderInstance = sliderEl.data('royalSlider');
var parentEl;
sliderInstance.ev.on('rsEnterFullscreen', function() {
if (!parentEl) {
parentEl = sliderEl.parent();
}
$('body').append(sliderEl);
});
sliderInstance.ev.on('rsExitFullscreen', function() {
if (parentEl) {
parentEl.append(sliderEl);
}
});
<?php
}
add_action('new_rs_after_js_init_code', 'add_additional_rs_code');
@dlv2372
Copy link

dlv2372 commented Jun 10, 2023

Doesnt work

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