Tagged: x
-
AuthorPosts
-
June 12, 2016 at 11:25 pm #1039002
Hey X Team,
Hope you’re doing well. I have an issue with my accordions. Upon click the page scrolls up or down (depending on which accordion item). This is a pretty sketchy user experience. I’ve read several other feeds and tried to implement different scripts but nothing seems to stop the scrolling, can you help?
Thanks for your time,
NateJune 12, 2016 at 11:26 pm #1039003This reply has been marked as private.June 13, 2016 at 2:08 am #1039129Hi there,
Please add following code in Customize -> Custom -> JavaScript :
jQuery(function($){ var navbarHeight = $('.x-navbar-fixed-top').outerHeight(); var wpadminbarHeight = $('#wpadminbar').outerHeight(); console.log(navbarHeight, wpadminbarHeight); $('.x-accordion-toggle').on('click', function(){ $('html,body').stop(); }); });
Hope that helps.
June 13, 2016 at 9:29 pm #1040694Sorry. The same abnormal scrolling is still happening.
Here’s a page with Accordions: http://bethelcleveland.net/bssm/about/
If you click through them you’ll see the page scrolls up and down.
Thanks for your time,
NateJune 14, 2016 at 5:43 am #1041122Hi Nate,
I can’t replicate the issue on my end.
See Video – http://screencast.com/t/MsEe0AUn
Can you try clearing your browser cache then check again.
Thanks
June 15, 2016 at 9:55 pm #1044475Sorry for not being specific. If you open an accordion item and then, without closing it, open the next accordion item, it doesn’t adjust the browser window so that the title of the newly opened item is at the top of the page. So it feels like the page is scrolling up and down. Is there a way that the open accordion item can be anchored to the top of the page upon click? Sorry for the confusion.
Thanks for your time,
NateJune 16, 2016 at 1:24 am #1044650Hello Nate,
Would you mind updating the code to this:
jQuery(document).ready(function($) { $('.x-accordion-toggle').on('click', function(){ var $this = $(this); setTimeout(function() { $('html, body').animate({ scrollTop: $this.offset().top - $('.x-navbar').outerHeight() }, 300); }, 500); }); });
Do let us know how this goes.
June 18, 2016 at 1:12 pm #1048577Awesome! Thank you so much! This is exactly what I needed.
Also, is there a way I can adjust the hight on the page? The sticky nav cuts off the accordion item title a bit, if it could be slightly lower that would be perfect, either way thanks for your time.
Thanks,
NateJune 19, 2016 at 12:40 am #1048955Hello Nate,
To adjust the height and avoid the sticky nav from getting cut off, please update the JS code and make use of this code instead:
jQuery(document).ready(function($) { $('.x-accordion-toggle').on('click', function(){ var $this = $(this); setTimeout(function() { $('html, body').animate({ scrollTop: $this.offset().top - 120 }, 300); }, 500); }); });
Please notice that I replaced the code
$('.x-navbar').outerHeight()
with an actual number of pixels. If 120 is not enough, you can adjust it to the nearest number that suits best. -
AuthorPosts