- This topic has 11 replies, 2 voices, and was last updated 3 months, 2 weeks ago by
David.
-
AuthorPosts
-
April 26, 2022 at 5:08 am #2200457
User 7
Hello team,
I just followed your great tutorial on how to add sticky social icons and used that to create a “WhatsApp Button” and it’s worked beautifully! Just wondering, if I want this “WhatsApp button element” to show in the footer at the left-side and only when a visitor scroll down to the footer; Is there any option or css code snippet for that?
April 26, 2022 at 5:40 am #2200479David
StaffCustomer SupportHi there,
so is this going to be part of the Footer or float over the footer ?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/April 26, 2022 at 6:04 am #2200498User 7
Let’s put it in the following scenario ๐
In Mobile/Tablet/Desktop: When a visitor visits the website, there will be no “WhatsApp Button”, but if he/she scrolled down to the bottom (which is here the footer bar) then the “WhatsApp” will shows up as a float button at the lower-left corner of the page. When the visitor scroll up, the “WhatsApp Button” disappears.I know it seems a bit complicated, but I hope there will be a way to do it without using a plugin.
April 26, 2022 at 6:43 am #2200521David
StaffCustomer SupportTrickier as its going to require Javascript. But lets give this a shot:
1. The Whatsapp button needs to be added inside the site-footer. So following the steps that were provided in that video but use the
generate_after_footer_content
hook.And the GB Container Block you first add to the Block Element needs an Advanced > Additional CSS Class of:
floating-button
2. Now create a Hook Element, and set that Hook to
wp_footer
and add this script to hook text area:<script> const found = document.querySelectorAll('.site-footer'); observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.intersectionRatio > 0) { entry.target.classList.add('in-view'); } else { entry.target.classList.remove('in-view'); } }); }); found.forEach(find => { observer.observe(find); }); </script>
3. Add this CSS to your site:
.gb-container.floating-button { position: fixed; bottom: 30px; left: 30px; opacity: 0; pointer-events: none; transition: opacity 0.3s ease-in-out; } .in-view .gb-container.floating-button { opacity: 1; pointer-events: auto; }
Once thats done, and the buttons is visible, let me know so i can take a look at the CSS requirements.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/April 26, 2022 at 7:07 am #2200540User 7
Done.
April 26, 2022 at 7:11 am #2200542David
StaffCustomer SupportCan you edit the Block element. Select the Container Block that the Whatsapp icon is inside of and go in Advance > Additional CSS Class(es) add:
floating-button
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/April 26, 2022 at 7:19 am #2200549User 7
Yes, I did it!
April 26, 2022 at 7:24 am #2200557David
StaffCustomer SupportNow in Customizer > Additional CSS or in your Child Theme style.css add this:
.gb-container.floating-button { position: fixed; bottom: 30px; left: 30px; opacity: 0; pointer-events: none; transition: opacity 0.3s ease-in-out; } .in-view .gb-container.floating-button { opacity: 1; pointer-events: auto; }
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/April 26, 2022 at 7:44 am #2200578User 7
Really can’t find words to thank you enough!
Just one minor thing please: The button is not clickable (I put the WhatsApp number already and it was working before).Any idea?
April 26, 2022 at 7:52 am #2200785David
StaffCustomer SupportOops updated the CSS above – which was to add the
pointer-events: auto;
property in the second rule.Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/April 26, 2022 at 8:10 am #2200805User 7
I had truly never experienced such a great support team as you in my whole life, I want you to know that and I want everyone in the WordPress industry knows this as well. Keep up the good work and have a beautiful day!
April 26, 2022 at 9:14 am #2200858David
StaffCustomer SupportWell thats super nice of you to say. Glad we can be of help ๐
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/ -
AuthorPosts
- You must be logged in to reply to this topic.