Tagged: x
-
AuthorPosts
-
March 28, 2016 at 12:20 pm #855336
Dear Support,
is there a way to open the accordion item on hoverintent state?
Got this code from JQueryUi site, but don’t know how to incorporate this. hope you can help.<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>jQuery UI Accordion - Open on hoverintent</title> <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css"> <script src="//code.jquery.com/jquery-1.10.2.js"></script> <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script> <link rel="stylesheet" href="/resources/demos/style.css"> <script> $(function() { $( "#accordion" ).accordion({ event: "click hoverintent" }); }); /* * hoverIntent | Copyright 2011 Brian Cherne * http://cherne.net/brian/resources/jquery.hoverIntent.html * modified by the jQuery UI team */ $.event.special.hoverintent = { setup: function() { $( this ).bind( "mouseover", jQuery.event.special.hoverintent.handler ); }, teardown: function() { $( this ).unbind( "mouseover", jQuery.event.special.hoverintent.handler ); }, handler: function( event ) { var currentX, currentY, timeout, args = arguments, target = $( event.target ), previousX = event.pageX, previousY = event.pageY; function track( event ) { currentX = event.pageX; currentY = event.pageY; }; function clear() { target .unbind( "mousemove", track ) .unbind( "mouseout", clear ); clearTimeout( timeout ); } function handler() { var prop, orig = event; if ( ( Math.abs( previousX - currentX ) + Math.abs( previousY - currentY ) ) < 7 ) { clear(); event = $.Event( "hoverintent" ); for ( prop in orig ) { if ( !( prop in event ) ) { event[ prop ] = orig[ prop ]; } } // Prevent accessing the original event since the new event // is fired asynchronously and the old event is no longer // usable (#6028) delete event.originalEvent; target.trigger( event ); } else { previousX = currentX; previousY = currentY; timeout = setTimeout( handler, 100 ); } } timeout = setTimeout( handler, 100 ); target.bind({ mousemove: track, mouseout: clear }); } }; </script> </head> <body> <div id="accordion"> <h3>Section 1</h3> <div> <p> Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate. </p> </div> <h3>Section 2</h3> <div> <p> Sed non urna. Donec et ante. Phasellus eu ligula. Vestibulum sit amet purus. Vivamus hendrerit, dolor at aliquet laoreet, mauris turpis porttitor velit, faucibus interdum tellus libero ac justo. Vivamus non quam. In suscipit faucibus urna. </p> </div> <h3>Section 3</h3> <div> <p> Nam enim risus, molestie et, porta ac, aliquam ac, risus. Quisque lobortis. Phasellus pellentesque purus in massa. Aenean in pede. Phasellus ac libero ac tellus pellentesque semper. Sed ac felis. Sed commodo, magna quis lacinia ornare, quam ante aliquam nisi, eu iaculis leo purus venenatis dui. </p> <ul> <li>List item one</li> <li>List item two</li> <li>List item three</li> </ul> </div> <h3>Section 4</h3> <div> <p> Cras dictum. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aenean lacinia mauris vel est. </p> <p> Suspendisse eu nisl. Nullam ut libero. Integer dignissim consequat lectus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. </p> </div> </div> </body> </html>
regard,
SyamMarch 28, 2016 at 4:08 pm #855629Hi Syam,
Thanks for writing in! Please remove your code and follow this post: https://community.theme.co/forums/topic/the-last-accordion-item-collapses-without-click/#post-261245
You can add the code given to that post under Customizer > Custom > JavaScript.
Hope it helps, Cheers!
March 28, 2016 at 9:30 pm #855965Hi, i did what suggested in the above post, it worked initially, but after i updated the theme to 4.4.0, the effect was gone. here is the link http://akademisiroh.com/aksi/profil-aksi/
March 29, 2016 at 1:04 am #856225Hi There,
Would you mind sharing us your admin credentials so we could check your setup further.
Don’t forget to set it as private reply.
Thanks.
March 29, 2016 at 9:41 am #856922This reply has been marked as private.March 29, 2016 at 12:33 pm #857208Hi There,
Please try with this code instead:
jQuery(document).ready(function($) { $(".x-accordion-toggle") .mouseover(function(event) { var target = $(event.currentTarget), parent = target.parent(); target.removeClass('collapsed'); $(".x-accordion-body").removeClass('in'); parent.next().addClass('in'); }) .mouseout(function(event) { var target = $(event.currentTarget); target.addClass('collapsed'); $(".x-accordion-body").removeClass('in'); }); });
Hope it helps 🙂
March 29, 2016 at 7:55 pm #857778Hi thank you, hoverintent is active now. but still have some problems need your help.
1. when you click the toggle, the accordion content will overlap the toggle below.
2. when mouse hovering the toggle, the content will drop down automatically, but when mouse leaving the toggle the content will close.
Can you make the content close only after we hover the other toggle not right after leaving the toggle?thanks.
March 30, 2016 at 2:48 am #858300Hi Syam,
Thanks for updating the thread!
#1, #2: To achieve these, please replace the last provided code with following:
jQuery(document).ready(function($) { $('.x-accordion-group').on('mouseover', function(event) { var $this = $(this), target = $this.find('.x-accordion-toggle'), content = $this.find('.x-accordion-body'); target.removeClass('collapsed'); $('.x-accordion-body').removeClass('in'); content.addClass('in').css( { height: 'auto' } ); }).on('mouseout', function(event) { var $this = $(this), target = $this.find('.x-accordion-toggle'), content = $this.find('.x-accordion-body'); if ( ! content.hasClass('in') ) { target.addClass('collapsed'); $('.x-accordion-body').removeClass('in').css({ height: 0 }); } }); });
As this is a custom development, further customizations from here would be outside the scope of support we can offer. If you need more in-depth changes, you may wish to consult with a developer. X is quite extensible with child themes, so there are plenty of possibilities. Thanks for understanding. Take care!
March 30, 2016 at 8:54 am #858765hi, thanks so much. it works very well.
March 30, 2016 at 11:51 am #858984You’re very welcome 🙂
-
AuthorPosts