Tagged: x
-
AuthorPosts
-
October 17, 2016 at 10:40 am #1219481
dsm_wpParticipantGood morning!
I am trying to implement custom JS (which works fine in Codepen) on Xtheme to use instead of Isotope (can not get it to center properly). Only the JS I am using will not work at all. I have placed it in my “Custom JS” for the page I want it applied to, and the code looks like this:
var box = jQuery('.box'), boxContainer = jQuery('.boxes'), section = jQuery('.sort-section'), containerHeight = jQuery('.adjustable-height'), boxClassFilter, showThese; jQuery('button').on('click', function(){ boxClassFilter = jQuery(this).data('filter'); showThese = boxContainer.find('.box' + '.' + boxClassFilter); var sectionHeight = section.height(); jQuery('.tag-container').find('button.selected').removeClass(); jQuery(this).toggleClass('selected'); var tl = new TimelineLite() .to(box, 0.5, {scale:0, opacity:0, ease: Power3.easeOut}) .set(box, {display:'none'}) .set(showThese, {display:'block'}) .to(showThese, 0.8, {scale:1, opacity:1, ease: Power3.easeOut}, '+=0.1') .fromTo(section, 1, {height:'sectionHeight', ease: Power3.easeOut}, {height:'initial', ease: Power3.easeIn}, '-=1'); if (boxClassFilter == 'all') { var allTL = new TimelineLite() .set(section, {height:sectionHeight}) .to(box, 0.5, {scale:0, opacity:0, ease: Power3.easeOut}) .set(box, {display:'none'}) .set(box, {display:'block'}) .to(box, 0.8, {scale:1, opacity:1, ease: Power3.easeOut}, '+=0.1') .fromTo(section,1 , {height:'sectionHeight', ease: Power3.easeOut}, {height:'initial', ease: Power3.easeIn}, '-=1'); } });This JS is applied to the following HTML:
<section class="sort-section"> <div class="tag-container"> <button class="selected" data-filter="all">all</button> <button data-filter="pink">pink</button> <button data-filter="green">green</button> <button data-filter="orange">orange</button> <button data-filter="blue">blue</button> </div> <div class="boxes"> <div class="box blue"></div> <div class="box pink"></div> <div class="box green"></div> <div class="box blue"></div> <div class="box pink"></div> <div class="box orange"></div> <div class="box blue"></div> <div class="box green"></div> <div class="box orange"></div> <div class="box blue"></div> <div class="box pink"></div> <div class="box green"></div> </div> </section>As I said, the JS works fine in Codepen so I’m not sure why it’s refusing to work in Xtheme.
October 17, 2016 at 10:42 am #1219485
dsm_wpParticipantThis reply has been marked as private.October 17, 2016 at 11:36 am #1219554
RupokMemberHi there,
Your script returning an error – http://prntscr.com/cvgilh
Make sure the code is complete and if it have any dependency then that’s also loaded.
Thanks!
October 17, 2016 at 12:09 pm #1219598
dsm_wpParticipantHello and thank for the response!
This is the codepen it’s running from https://codepen.io/MandyMadeThis/pen/dGQxaN
I’ll have to comb through and make sure I didn’t lose something in translation
October 17, 2016 at 12:10 pm #1219600
dsm_wpParticipantIs “TimelineLite” included with Xtheme? It’s a component of GreenSock
October 17, 2016 at 1:19 pm #1219685
RupokMemberHi there,
Thanks for writing back. As mentioned on previous reply, there is another dependency that you didn’t load – http://prntscr.com/cvhxee
You can try adding the script using Child Theme‘s functions.php :
add_action( 'wp_footer', 'custom_page_script' ); function custom_page_script(){ echo '<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.18.0/TweenMax.min.js">'; }Hope this helps.
October 18, 2016 at 11:00 am #1220991
dsm_wpParticipantWhere should this go in the functions.php?
October 18, 2016 at 12:27 pm #1221096
RupokMemberHi there,
Let’s place this at the bottom of all code in your functions.php
Thanks!
October 19, 2016 at 9:09 am #1222295
dsm_wpParticipantWhen I place this at the bottom of my PHP file, live viewer in Cornerstone no longer works. Did I put this in wrong?
October 19, 2016 at 11:19 am #1222486
RupokMemberHi there,
Thanks for writing back. I can’t see the code on your functions.php so can’t say either you added this correctly or not. But using such script is not recommended within WordPress. As you are using WordPress, you should look for some WordPress plugin to accomplish this instead of hard coding scripts to theme as it might cause unexpected script error that eventually might break something. So instead of using such raw code, use plugins and there are lot of free plugins out there in repository to accomplish such filtering.
Hope this makes sense.
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1219481 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
