Disable Auto Height

This snippet disables Swiper’s auto height and forces all slides to match the height of the tallest slide.

Instructions

See “Where do I put snippets?” in our documentation for installation instructions.

Code

Filename: gppt-disable-auto-height.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
/**
 * Gravity Perks // Page Transitions // Disable Auto Height
 * https://gravitywiz.com/documentation/gravity-forms-page-transitions/
 *
 * This snippet disables Swiper's auto height and forces all slides to match the height of the tallest slide.
 */
// Update "123" to your form ID
$target_form_id = 123;

add_filter( "gppt_script_args_{$target_form_id}", function( $args, $form ) {
	$args['transitionSettings']['autoHeight'] = false;
	return $args;
}, 10, 2 );

add_filter( "gform_pre_render_{$target_form_id}", function( $form ) {
	add_action( 'wp_head', 'disable_auto_height_styles' );
	return $form;
});

add_action( 'gform_preview_footer', function( $form_id ) use ( $target_form_id ) {
	if ( $form_id == $target_form_id ) {
		disable_auto_height_styles();
	}
});

function disable_auto_height_styles() {
	?>
	<style>
	.gppt-has-page-transitions .swiper-slide {
		height: auto;
		align-self: stretch;
	}
	</style>
	<?php
}

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.