Skip to content
This repository has been archived by the owner on Jun 18, 2022. It is now read-only.

stickUp在jquery3.2.1下不工作,目标menu包含top属性 #55

Open
nickxin opened this issue Dec 6, 2017 · 1 comment
Open

stickUp在jquery3.2.1下不工作,目标menu包含top属性 #55

nickxin opened this issue Dec 6, 2017 · 1 comment

Comments

@nickxin
Copy link

nickxin commented Dec 6, 2017

我的jquery版本是3.2.1 ,发现我需要定位的DIV不动。

另外我的这个DIV有一个样式:top :500px;

更换jquery后,可以实现。但当滚动条高度小于500时,它就会到顶部去。

如何解决?

@nickxin
Copy link
Author

nickxin commented Dec 6, 2017

jquery3.2.1 弃用size() 改用length. 插件中需要修改。

如果目标导航有top样式。只需要对top进行较。

下面修改最终实现在我想要的效果。如有更好方法请指教

var itemTop = 0;

itemTop = options.itemTop;

if (varscroll > itemTop) {
                $(".stuckMenu").addClass("isStuck");
                $(".stuckMenu").next().closest("div").css({
                    "margin-top": stickyHeight + stickyMarginB + currentMarginT + "px"
                }, 10);
                $(".stuckMenu").css("position", "fixed");
                $(".isStuck").css({
                    "top": "0px"
                }, 10, function () { });
            };
            if (varscroll < itemTop) {
                $(".stuckMenu").removeClass("isStuck");

                $(".stuckMenu").next().closest("div").css({
                    "margin-top": currentMarginT + "px"
                }, 10);

                $(".stuckMenu").css({
                    "top": itemTop + "px",
                    "position": "absolute"
                }, 10, function () {

                });
            };

@nickxin nickxin changed the title stickUp不工作 stickUp在jquery3.2.1下不工作,目标menu包含top属性 Dec 6, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant