Search Results

Search found 3 results on 1 pages for 'fatdogmark'.

Page 1/1 | 1 

  • What is the proper way to wait a script loaded completely before another

    - by FatDogMark
    I am making a website that is divided by several sections <div id='section-1' class='section'>web content</div> <div id='section-2' class='section'>web content</div> I have like ten sections on my webpage ,each sections height is set to the user window height when document is ready by javascript $('.section').height($(window).height()); Some effects like slideshows on my webpage require the calculated height of the section in order to work properly. Therefore I always use something like this at document ready as a solution. setTimeout(startslideshow,1000); setTimeout(startanimations,1000); ...etc To make sure the section height is the user window height before the slideshow's code start because the sections cannot change to user window height instantly once the webpage loaded will generate serious problems in my slideshow code,like wrong calculated positions. Therefore there will be a situation that's after the page loaded, there will be about a second everything is messed up,before everything can works properly, how could I avoid that being seen by the user? I tried to $(document).hide(),or $('html,body').hide(), then fade in after a second,but I get other weird problems, especially on ipad,my fixed position top navigation bar will always become 'not fixed' while user is scrolling. As I am a self-learner, I afraid my method is not typical. I want to know what is the common ways of real web programmers usually do when they have to divide his webpage into different sections and set its height to window height , then make sure the other effects that's depends on the section height works properly and avoid to wait the height change for a second?

    Read the article

  • How to return function in document ready?

    - by FatDogMark
    I don't know if it is possible to do this, like I have 2 js files. The first Js File: var news_pos, about_pos, services_pos, clients_pos; function define_pos(){ var $top_slides=$('#top_slides'), $mid_nav=$('#mid_nav'), $news_section=$('#section-1'); var fixed_height = $top_slides.height()+$mid_nav.height(); news_pos = fixed_height-20 ; about_pos = fixed_height+$news_section.height(); services_pos = fixed_height+$news_section.height()*2; clients_pos = fixed_height+$news_section.height()*3; } $(document).ready(function(){ var section_news = $('#section-1'), section_about = $('#section-2'), section_services = $('#section-3'), section_clients = $('#section-4'); setheight(); function setheight(){ var section_height=$(window).height()+200; $section_news.height(section_height); $section_about.height(section_height); $section_services.height(section_height); $section_clients.height(section_height); define_pos(); } }); The second JS File: $(document).ready(function(){ var nav = { '$btn1':$('#btn1'), '$btn2':$('#btn2'), '$btn3':$('#btn3'), '$btn4':$('#btn4'), '$btn5':$('#btn5'), myclick : function(){ myclicked(nav.$btn1,0); myclicked(nav.$btn2,news_pos); myclicked(nav.$btn3,about_pos); myclicked(nav.$btn4,services_pos); myclicked(nav.$btn5,clients_pos); function myclicked(j,k){ j.click(function(e) { e.preventDefault(); $('html,body').animate({scrollTop: k}, 1000); }); } //Is it right to do return{'myclick':myclick}, how to call? seems not logical } } nav.myclick(); // Here will not work because it say news_pos is undefined //if I use setTimeout(nav.myclick,1000), it will works but I want to run it right the when position is caculated. }); How do I pass the nav.myclick() function to the frist js file and put it in setheight() and under define_pos()? By the way writing codes right in stackoverflow is strange,press tab not really give you any spacing.

    Read the article

  • possible to use <img> as <div>?

    - by FatDogMark
    for example if I want to put an image wrap another object,possible? <img src='pic.png'> <div id='block'> <p>Somebody </div> </img> I know I should just use div and background-image but I want to use the property auto img{width:50%; height:auto;} If I use div , using auto won't works because it won't know the background-image size and will not adjust the div depends on the image ratio aspect.

    Read the article

1