zoukankan      html  css  js  c++  java
  • jquery插件编写思路

    function(e) {
    	e.fn.floatNav = function(t) {
    		var i = e.extend({
    			start: null,
    			end: null,
    			fixedClass: "nav-fixed",
    			anchor: null,
    			targetEle: null,
    			range: 0,
    			onStart: function() {},
    			onEnd: function() {}
    		},
    		t),
    		s = e(this),
    		a = s.height(),
    		o = s.width(),
    		n = e('<div class="float-nav-wrap"/>');   //以逗号分隔各个值,一次定义多个变量

    //return 返回用逗号隔开的各个值,这里用到了逗号表单式,把this单签这个对象放到最后,确保逗号表达式返回的是当前的这个jquery对象,这样写,确保了每个逗号
    表达式中的语句都被执行
    return s.css({ height: a, o }), s.parent().hasClass("float-nav-wrap") || s.wrap(n.css("height", a)), //先判断下父级是否有float-nav-wrap这个对象,如果有的话,则执行后面的s.wrap(n.css("height", a))语句 e(window).bind("scroll", function() { var t = e(document).scrollTop(), a = s.find("a").eq(0).attr("href"), o = i.start || s.parent(".float-nav-wrap").offset().top, n = i.targetEle ? e(i.targetEle).offset().top: 1e4; t > o && (i.end || n) - i.range > t ? (s.addClass(i.fixedClass), i.anchor && a !== i.anchor && s.find("a").attr("href", i.anchor), i.onStart && i.onStart()) : (s.removeClass(i.fixedClass), i.anchor && s.find("a").attr("href", "javascript:;"), i.onEnd && i.onEnd()) }), this } } (jQuery),
  • 相关阅读:
    Linux基础命令
    python中eval的用法
    man命令手册打开以后的使用方法
    Sequel Pro(连接mysql数据库)的下载和使用
    pycharm里连接mysql
    python里的路径拼接
    第一个接口自动化框架atp
    使用yaml(yml)写用例
    计算机及Linux简介
    xpath和css selector
  • 原文地址:https://www.cnblogs.com/Alight/p/3097337.html
Copyright © 2011-2022 走看看