限时优惠活动
亲爱的苦力吧用户,我们为了回馈新老用户一直以来的鼎力支持,即日起(2025-02-06至2025-03-06)凡是购买苦力吧VIP/充值K币的新老用户,都直接可获得买一送一的优惠馈赠。例如:购买一个月的VIP会员可直接获得两个月的VIP会员;充值100K币可直接获得200K币,以此类推!有任何疑问可联系在线客服,感谢各位用户对苦力吧素材的信任与厚爱,我们将一如既往的给大家上新更多优质的素材源码,祝大家开工大吉、工作顺利、心想事成。

jquery基于DIV指定区域局部滚动定位特效代码

所属分类: 网页特效-导航菜单    2023-11-16 10:23:39

jquery基于DIV指定区域局部滚动定位特效代码 ie兼容6
 查看演示  登录后下载 温馨提示
登录会员即可享受免费下载
 我要建站

jquery基于DIV指定区域局部滚动定位特效代码(共3个文件)

    • index.html

使用方法

  • code
  • source
  1. (function ($) {
  2. 'use strict';
  3. let defaults = {
  4. activeClass: 'active',
  5. fixed: true
  6. };
  7. let container,
  8. target,
  9. activeClass,
  10. fixed,
  11. collection = [];
  12. let init = function (params) {
  13. let options = $.extend({}, defaults, params);
  14. container = this;
  15. target = options.target;
  16. activeClass = options.activeClass;
  17. fixed = options.fixed;
  18. let hash = null, element = null;
  19. $.each(target, function () {
  20. (hash = this.href.split('#')[1]) !== undefined
  21. ? (element = container.find(`[id="${hash}"]`)).length > 0 ? collection.push({
  22. link: $(this),
  23. element: element
  24. }) : null : null;
  25. });
  26. this.unbind('scroll', eventListener).bind('scroll', eventListener);
  27. return this;
  28. };
  29. let eventListener = function () {
  30. let relativeOffsetTop = collection.length > 0 ? collection[0].element.offset().top + container.scrollTop() : 0;
  31. $.each(collection, function () {
  32. let _ot = Math.floor(this.element.offset().top + container.scrollTop() - relativeOffsetTop);
  33. let _st = Math.ceil(container.scrollTop());
  34. if (_ot <= _st && _st < _ot + Math.floor(this.element.outerHeight())) {
  35. if (!this.link.hasClass(activeClass)) {
  36. target.removeClass(activeClass);
  37. this.link.addClass(activeClass);
  38. }
  39. return false;
  40. } else if (fixed) {
  41. this.link.removeClass('active');
  42. }
  43. });
  44. };
  45. $.fn.scrollSpy = function (options) {
  46. if (typeof options === 'object' && typeof options.target != "undefined") {
  47. return init.apply(this, arguments);
  48. } else {
  49. $.error('You should use plugin with required options...');
  50. }
  51. };
  52. })(jQuery);
(function ($) {
    'use strict';

    let defaults = {
        activeClass: 'active',
        fixed: true
    };

    let container,
        target,
        activeClass,
        fixed,
        collection = [];

    let init = function (params) {
        let options = $.extend({}, defaults, params);

        container = this;
        target = options.target;
        activeClass = options.activeClass;
        fixed = options.fixed;

        let hash = null, element = null;
        $.each(target, function () {
            (hash = this.href.split('#')[1]) !== undefined
                ? (element = container.find(`[id="${hash}"]`)).length > 0 ? collection.push({
                    link: $(this),
                    element: element
                }) : null : null;
        });
        this.unbind('scroll', eventListener).bind('scroll', eventListener);
        return this;
    };

    let eventListener = function () {
        let relativeOffsetTop = collection.length > 0 ? collection[0].element.offset().top + container.scrollTop() : 0;
        $.each(collection, function () {
            let _ot = Math.floor(this.element.offset().top + container.scrollTop() - relativeOffsetTop);
            let _st = Math.ceil(container.scrollTop());
            if (_ot <= _st && _st < _ot + Math.floor(this.element.outerHeight())) {
                if (!this.link.hasClass(activeClass)) {
                    target.removeClass(activeClass);
                    this.link.addClass(activeClass);
                }
                return false;
            } else if (fixed) {
                this.link.removeClass('active');
            }
        });
    };

    $.fn.scrollSpy = function (options) {
        if (typeof options === 'object' && typeof options.target != "undefined") {
            return init.apply(this, arguments);
        } else {
            $.error('You should use plugin with required options...');
        }
    };

})(jQuery);

站长提示:
1. 苦力吧素材官方QQ群:950875342
2. 平台上所有素材资源,需注册登录会员方能正常下载。
3. 会员用户积极反馈网站、素材资源BUG或错误问题,每次奖励2K币
4. PHP源码类素材,如需协助安装调试,或你有二次开发需求,可联系苦力吧客服。
5. 付费素材资源,需充值后方能下载,如有任何疑问可直接联系苦力吧客服
相关资源 / 导航菜单

原生js仿苹果dock栏动态图片动感导航菜单特效

这是一款苹果风格的导航菜单,比较早期的版本了,不过现在还是一样的酷炫动感。
  导航菜单
 9498  0

jquery侧边栏可展开收缩垂直二级导航菜单

一款侧边栏折叠展开的二级导航菜单,普遍用户网站后台管理的功能菜单!
  导航菜单
 9540  0

jquery鼠标hover经过显示下拉导航菜单特效

一款创业项目门户网站的顶部导航,鼠标经过立即显示下拉二级分类导航。
  导航菜单
 3592  0

CSS固定于网页右下角悬浮在线人工客服和二维码菜单特效代码

鼠标悬停显示横向菜单,移走隐藏菜单,带人工客服、客服电话、二维码显示。
  导航菜单
 5432  0

评论数(0) 回复有机会获得K币 用户协议

^_^ 还没有人评论,快来抢个沙发!
😀
  • 😀
  • 😊
  • 😂
  • 😍
  • 😑
  • 😷
  • 😵
  • 😛
  • 😣
  • 😱
  • 😋
  • 😎
  • 😵
  • 😕
  • 😶
  • 😚
  • 😜
  • 😭
发表评论