سؤال

وأنا إعطاء إذا كانت تصريحات شيء آخر طعنة، ولست متأكدا إذا أنا أكتب هذا صحيح ... محاولة للحصول عليه بحيث إذا كان البعد popupHeight أكبر من البعد windowHeight، فإنه سيكون وضعه على الجزء العلوي من العرض + 10px ...

$("#data").load("/content/" + htmlName + ".html", null, function(){
    //Set Variables
    var container = $(".container");
    var project = $(".project");
    var popupWidth = container.find(".project img:first").width();
    var popupHeight = container.find(".project img:first").height()+35;
    var windowWidth = document.documentElement.clientWidth;
    var windowHeight = document.documentElement.clientHeight;
    var x = ($(window).width() / 2 - popupWidth / 2) + $(window).scrollLeft();
    var y = ($(window).height() / 2 - popupHeight / 2) + $(window).scrollTop();

    //Set popup dimensions
    container.css("width" , popupWidth);
    container.css("height" , popupHeight);

    //Set popup CSS
    container.css({"position": "absolute", "left": x + "px", "z-index": "2" });
    project.css({"width": (popupWidth), "height": (popupHeight) });

    //Determine Position
    if(popupHeight>windowHeight) {
        container.css{("top": $(window).scrollTop(); + 10 + "px") 
        }else{
        container.css({"top": y + "px"});
        return;
        }
});
هل كانت مفيدة؟

المحلول

والتخلص من منقوطة بعد scrollTop () ووضعها في نهاية السطر -

container.css{("top": $(window).scrollTop(); + 10 + "px")

ويجب أن تبدو وكأنها -

container.css({"top": $(window).scrollTop() + 10 + "px"});

وظيفة المغلق لديك يجب أن يكون إخراجها أيضا، يجب أن تحب ما سبق.

نصائح أخرى

وأنا لم تستخدم مسج قبل، لذلك قد أكون مخطئا، ولكن ليست منقوطة في هذا الخط في المكان الخطأ؟

container.css{("top": $(window).scrollTop(); + 10 + "px") 
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top