Tagged: shrinking header, sticky header
-
AuthorPosts
-
May 30, 2023 at 5:58 pm #1409040
Ive tried https://kriesi.at/support/topic/show-different-logo-in-head-upon-scrolldown/ and other solutions I was able to find on the forums (like Guenni007’s different function/css) but none are working. The closest I can get is to show both the default logo and the logo I defined or scrolling, but both are showing.
I am looking for a definitive way to show a completely different logo when sticky/shrinking header. Thanks in advance for any help!
May 30, 2023 at 7:17 pm #1409050Your topic of that is the way i understand – different logo during scrolling – stop scrolling default logo:
the method used for your aim depends on the logos you like to use.
E.g. – Logo a and logo b are only colored differently (change of font color – change of branding color etc.). I would try to realize it by an svg logo just switching the fill colors by scroll event.
Etc.F.e. two logo variants are by same dimensions. Insert your logo as usual – and set on quick css the other logo as background-image.
on my example page these are svg files – but png or jpg is also a possibility..av-contains-svg.invisible { background-image: url(/wp-content/uploads/icon807.svg); background-repeat: no-repeat; background-size: contain; background-position: center center; } .av-contains-svg.invisible svg { opacity: 0; transition: opacity 1s ease-in-out }
the jQuery function now on child-theme functions.php:
function invisible_on_scrolling() { ?> <script type="text/javascript"> (function($){ let timeout; let $targetOnScroll = $('.av-contains-svg'); $(document).on("scroll", () => { $targetOnScroll.addClass("invisible"); clearTimeout(timeout); timeout = setTimeout(() => $targetOnScroll.removeClass('invisible'), 200); }); })(jQuery); </script> <?php } add_action('wp_footer', 'invisible_on_scrolling');
see: https://webers-web.info/datenschutz/
Or: do you like to have different logo during shrink – after shrink finished – default logo
can you link to my post that you are referring to?May 30, 2023 at 8:24 pm #1409054Thank you @Guenni007 – as mentioned, I am hoping to show a completely different logo when the sticky/shrinking header is being used. I did put your solution in place to test an on scrolling it is showing the alternate logo, but once I stop scrolling the initial logo (the one I want to replace when the sticky/shrinking header is enabled) shows again.
When I use the sticky and/or shrinking header and start to scroll down the page, I want to display a completely different logo.
May 30, 2023 at 11:46 pm #1409067But that’s what it sounds to me when it’s said: different logos on scroll ( means during the scroll ).
if you want to show logo A only when loading the page – and while scrolling to the end of the shrunk header. After reaching the shrunk height of the header, logo B should be visible.
This is analogous to the transparency header – but now with the same behavior on all pages.It would be best if we could see your logos to get an idea of what we have to work with.
May 30, 2023 at 11:53 pm #1409069Your solution did show the logo ‘during’ the scroll, but when I stoped scrolling – even though the header was shrunk and scrolled to the lower part of the page I was on – the original logo shows again and the logo I want to show in a shrunk/scrolled header is no longer visible.
Can you see hidden content in this ticket?
Thanks!
May 31, 2023 at 5:02 am #1409086Hi,
Please provide the link to the site so that we can inspect it and make the necessary adjustments. Screenshots will also help. You can use platforms like Savvyify, Imgur or Dropbox to upload and share the screenshot. Here are the steps to follow:
1.) Visit the website of your chosen platform, such as Savvyify, Imgur or Dropbox.
2.) Locate the option to upload a file or an image.
3.) Select the screenshot file from your computer or device and upload it to the platform.
4.) After the upload is complete, you will be provided with a shareable link or an embed code.
5.) Copy the link or code and include it in your message or response to provide us with the screenshot.Thank you for taking the time to share the screenshot. It will help us better understand the issue you’re facing and provide appropriate assistance.
Best regards,
IsmaelMay 31, 2023 at 7:44 am #1409093so look again to the example page: https://webers-web.info/
This is default behavior on transparency pages – showing first the logo (from options : header – transprency options – transparency logo) after shrinking finished the default logo is shown.
And that is what you like to have on all pages – even those with header option : not transprency.
May 31, 2023 at 9:42 pm #1409197@Guenni007, that is what I want. I would like to know how to put this in place though without the transparent header. I don’t want sliders all the way on top on my pages if I can help it. I did set the logo I want users to see when scrolling as the transparency logo, but just so I can show which logo I am looking to use in that case. I’ll out everything in the private content space now…
June 2, 2023 at 6:51 pm #1409421Curious if Enfold support has seen the private data and had any suggestions?
June 2, 2023 at 7:03 pm #1409423what kind of mime type are your logos? png / jpg / svg ?
June 2, 2023 at 7:04 pm #1409424June 2, 2023 at 7:21 pm #1409425do you need inline svg for that alternative logo – or is a img src ok?
see: https://webers-web.info/impressum/the trick will be to insert another subtext logo. But this logo is not in dependency to av_header_transparency but to header-scrolled class.
Edit: just a moment – i had to optimize the codes
June 2, 2023 at 9:29 pm #1409432https://webers-web.info/impressum/ is exactly what I’m after. I can only click that link in your reply, not sure if the others are supposed to link?
June 2, 2023 at 9:54 pm #1409434hm – my coding abilities are not good enought to check in a filter function if a page/post is a transparency page.
i see that line on enfold-functions.php :$transparency = post_password_required() ? false : get_post_meta( $post_id, 'header_transparency', true );
but can’t get it to run for all non transparency pages/posts
what i got so far for my example page is:
function an_alternative_logo( $sub ) { if (is_page(2879) ) { $sub .= '<img class="alternative-logo" src="path_to_your_alternative_logo" alt="alternativ Logo" />'; } return $sub; } add_filter( 'avf_logo_subtext', 'an_alternative_logo' ); function replace_alternative_svg_logo_with_inline_code() { if (is_page(2879) ) { ?> <script type="text/javascript"> window.addEventListener("DOMContentLoaded", function () { (function($){ $( ".avia-img-svg-logo-sub img" ).remove(); $.get('path_to_your_alternative_svg_logo', function(svg){ $( ".avia-img-svg-logo-sub" ).html( svg ); }, 'text'); })(jQuery); }); </script> <?php } } add_action('wp_footer', 'replace_alternative_svg_logo_with_inline_code');
and for quick css:
#top.page-id-2879 .alternative-logo { position: absolute; top: 0; left: 0; opacity: 0; transition: opacity 0.5s ease } #top.page-id-2879 .header-scrolled .alternative-logo { opacity: 1; } #top.page-id-2879 .header-scrolled .av-contains-svg > svg, #top.page-id-2879 .header-scrolled .av-contains-svg > img { opacity: 0; transition: opacity 0.5s ease } #top.page-id-2879 .subtext.avia-img-svg-logo-sub > svg { position: absolute; top: 0; left: 0; } #top.page-id-2879 :not(.header-scrolled) .subtext.avia-img-svg-logo-sub > svg { opacity: 0; transition: opacity 0.5s ease } #top.page-id-2879 .header-scrolled .subtext.avia-img-svg-logo-sub > svg { opacity: 1; transition: opacity 0.5s ease }
maybe it is possible for a mod to change the code for a more global use, in the sense that only pages without transparent logo will have this filter.
June 2, 2023 at 10:37 pm #1409440Supposed to rain here all weekend and I’ll give this a shot and try to get it working on all pages. Thanks!
June 2, 2023 at 10:58 pm #1409444Hi,
Glad Guenni007 could help, thank you Guenni007, let us know if you need any further help or if we should close this thread.Best regards,
MikeJune 3, 2023 at 6:10 am #1409458Yes mike – but this is half the solution it could be.
Better would be :maybe it is possible for a mod to change the code for a more global use, in the sense that only pages without transparent logo will have this filter.
June 4, 2023 at 5:35 pm #1409550Hi,
Thanks Guenni007 I took a look at this and at lzevon’s site and I found that it works for this site even though it is not using a transparent header.
lzevon thanks for the login I see that are are using a page ID to your homepage for the css and script so it will only work on your homepage and this page is not transparent and uses the Shrinking Header & Sticky Header, I checked the code from Guenni007 and added a svg image all-for-you-no-cloud.svg in the placeholder path_to_your_alternative_svg_logo in the code.
So now the logo with the cloud shows at the top of the page and before scroll, then after scroll the logo with no cloud shows.
Please see the screenshots in the Private Content area and clear your browser cache and check.Best regards,
MikeJune 5, 2023 at 4:20 pm #1409630Thanks Mike, the logo script from @GUENNI007 was a great starting point, it’s now site-wide and was simplified to:
function an_alternative_logo( $sub ) { $sub .= '<img class="alternative-logo" src="/wp-content/uploads/2023/05/blah.svg" />'; return $sub; } add_filter( 'avf_logo_subtext', 'an_alternative_logo' );
We’re using the following CSS…
/* swap logo */ #top img.alternative-logo { display: none; } @media only screen and (min-width:767.1px) { #top .header-scrolled .avia-svg-logo > a > svg { opacity: 0; height: 0; overflow: hidden; transition: opacity 0.5s ease; } #top img.alternative-logo { display: block; opacity: 0; height: 0 !important; overflow: hidden; transition: opacity 0.5s ease; } #top .header-scrolled img.alternative-logo { width: 100%; height: 39px !important; opacity: 1; } #top .header-scrolled .avia-img-svg-logo-sub { height: 100%; display: flex; align-items: center; } }
Hope this helps someone else looking for similar functionality.
- This reply was modified 1 year, 5 months ago by lzevon.
June 5, 2023 at 6:18 pm #1409651Hi,
Glad Guenni007 could help, thank you Guenni007, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.Best regards,
Mike -
AuthorPosts
- The topic ‘working solution for different logo on scroll’ is closed to new replies.