locomotivemtl / locomotive-scroll

🛤 Detection of elements in viewport & smooth scrolling with parallax.
https://locomotivemtl.github.io/locomotive-scroll
MIT License
7.56k stars 1.11k forks source link

Update height after Gravity Forms trigger/submit (with added validation errors) #442

Closed cjjkeesq closed 2 years ago

cjjkeesq commented 2 years ago

I'm using the plugin Gravity Forms for our website. The form I'm using has AJAX enabled and when I click the submit button, the page shifts because of the added validation errors.

Looking at https://docs.gravityforms.com/gform_post_render/ it should be possible to update the scroll container after the gform_post_render event. But It doesn't seem to work with the following code:

jQuery(document).bind('gform_post_render', function(){ console.log("Gravity updated"); scroll.update(); });

I do see the console log, but the scroll container still shifts in a weird way. What am I doing wrong?

djdanj commented 1 year ago

I had this same issue. I disabled the Gravity Forms "Automatic Scrolling On Form Confirmations" using this filter in functions.php:

add_filter( 'gform_confirmation_anchor', '__return_false' );

Docs: https://docs.gravityforms.com/disable-automatic-scroll-form-confirmation/

This allowed scroll.update(); to work correctly e.g.:

jQuery(document).on('gform_post_render', function(event, form_id, current_page){
    scroll.update();
});