Tagged: ismael
-
AuthorPosts
-
April 30, 2017 at 9:55 am #785213
Hello
In this page: https://www.domodeco.fr/carnet-d-adresses I have 15 filter buttonsThe problem is that page on mobile is not user frindly because when you touch on the filter to display the results the user do not see the results, or do not see that something has changed in the page, because the changes are out of the mobile view.
What JS do I have to add to make like this: if button filter clicked then scroll down to div.grid-sort-container
And it must works both on desktop and mobile… so I think for destktop it will be something like:
jQuery('body').on('click', '.inner_sort_button', function() { jQuery("html, body").animate({ scrollTop: jQuery('.grid-sort-container').offset().top}, 'slow');
and for mobile:
if('ontouchend' in document) { jQuery("html, body").animate({ scrollTop: jQuery('.grid-sort-container').offset().top}, 'slow');
Those code I give are jsut ideas of course….
Thanks
May 2, 2017 at 5:40 am #786128Hey pako69,
Thank you for using Enfold.
Please try this script in the functions.php file:
function ava_custom_script_fix(){ ?> <script> (function($){ function e() { $('.sort_by_cat a').on('click', function() { $('html, body').animate({ scrollTop: $(".grid-sort-container").offset().top }, 1000); }); } e(); })(jQuery); </script> <?php } add_action('wp_footer', 'ava_custom_script_fix');
Best regards,
IsmaelMay 2, 2017 at 7:48 am #786195Ismael: you rock!
A big thank :)> Sure this is a simple tip that should be somewhere in your FAQs/Tips, don’t you think ?
May 2, 2017 at 8:21 am #786212And If someone is looking for the same thing but with a Masonry elements:
> Note the ‘- 70’ is specific because I’m using the fixed headerfunction ava_custom_script_fix(){ ?> <script> (function($){ function e() { $('.av-sort-by-term a').on('click', function() { $('html, body').animate({ scrollTop: $(".av-masonry-container").offset().top - 70 }, 1000); }); } e(); })(jQuery); </script> <?php } add_action('wp_footer', 'ava_custom_script_fix');
- This reply was modified 7 years, 7 months ago by pako69.
May 2, 2017 at 11:58 am #786283 -
AuthorPosts
- You must be logged in to reply to this topic.