- This topic is empty.
-
AuthorPosts
-
January 16, 2012 at 8:10 am #94712Carlos56Member
Anyone?
If it’s not possible to update the logo when accessing an item through a hash link, then is it possible to have the change fade in?
January 16, 2012 at 7:15 pm #94773sheepysheep60ParticipantHey sorry haven’t been on in a while. It sounds like you could really do with watching something like this:
https://css-tricks.com/video-screencasts/85-best-practices-dynamic-content/not being awkward, but I’m not 100% sure either and I’m sure Chris goes through everything you’ll need to know, you’ll just need to apply what we’ve spoken about using a method he uses!
January 16, 2012 at 8:25 pm #94774Carlos56MemberHey Sheepysheep60, thanks for your reply!
I’ll give that a go, thanks for sharing.
In the meantime, anyone with a solution, PLEASE share it! (-:
Thanks
January 17, 2012 at 1:12 am #94798jamygoldenMember“That fixes the revert to the first image when refreshing the page. It doesn’t however update the logo when an item is accessed via a hash link. Is this not possible?”
I provided that solution earlier.
January 17, 2012 at 8:27 am #94819Carlos56MemberYou did?!
Where!?!?
I’m pretty sure I have included all the script you guys have suggested in this thread. I don’t think any suggestions have updated the logo when accessing items through the hash url.
Thanks again!
January 17, 2012 at 9:00 am #94823jamygoldenMemberJanuary 17, 2012 at 9:03 am #94824MottieMemberAhh, sorry the problem with my demo is I forgot to remove the ” e.preventDefault(); // prevent default link behaviour” line, try this updated demo.
January 17, 2012 at 11:56 am #94844Carlos56Memberjamy_za, I’ve made your code look like this..
function cssChangeBasedOnHash() {
switch ( window.location.hash ) {
case '#serv':
var backgroundPosition = '0px -151px'
break;
case '#port':
var backgroundPosition = '0px -302px'
break;
case '#contact':
var backgroundPosition = '0px -453px'
break;
default: // fallback
var backgroundPosition = '0 0'
break;
};
console.log(window.location.hash);
$('.logo-item').css('backgroundPosition', backgroundPosition);
}; // cssChangeBasedOnHash()
$(document).ready(function() {
cssChangeBasedOnHash();
$(window).bind( 'hashchange', function(){
cssChangeBasedOnHash();
}); // window.bind.hashchange
}); // dom.readyIt’s not working though? :(
Just to clarify the ‘#serv’ is just referring to what goes in ‘ href=”” ‘ – within the HTML right?? I can see your code works in your demo, but for some reason It’s not happening at my end. Must be the code.. or my slider maybe..
Also Mottie your method does allow me to refresh the page once accessed through a hash link and update the logo, but it doesn’t do it automatically.
Could my slider have something to do with it?!
I appreciate all the time you guys have given me- thank you.
January 17, 2012 at 9:12 pm #94890Carlos56MemberEdit: thought something had solved it but it’s not the case. Sorry.
January 18, 2012 at 1:01 am #94907jamygoldenMemberExample with backgroundColor changed to backgroundPosition
I’ve used Chris’ frog sprite as the background image =)
January 18, 2012 at 1:28 am #94908Carlos56Memberit’s not showing up :(
January 18, 2012 at 2:39 am #94910jamygoldenMemberIt’s the same link – but I’ve fixed the href problem.
January 18, 2012 at 11:45 am #94933Carlos56Member@jamy_za thank you so much for all your help.
It’s finally working – it’s quite interesting to see how different methods achieve things in different ways.
Before, the change of logo would happen almost instantly after the click. It now happens with a delay which kinda coincides with the page load.
I realise I’m pushing it ever so slightly and should’ve probably started paying you guys a long time ago, but literally just a quick example of how a fade transition could be introduced to work with @jamy-za ‘s solution, would be extremely appreciated!
Thank you once again all.
Carlos
-
AuthorPosts
- The forum ‘CSS’ is closed to new topics and replies.