很纠结
学js也有一年了 可是看看现在的代码  相当的烦琐。
我也想写的清爽  幽雅,可总是做不到.................
有时候也想写短,可是有的属性本声就长 还带几个,还有就是为了方便看变量,变量也取的很长。
但是看别人写的了,却很幽雅....  很纠结
各位大虾,前辈,指教下 该怎么办了..........(或者说应该注意哪些方面了)顺便帮我看个问题  连接在这
第4个滚动条 点击后 会向左偏移1象素........

解决方案 »

  1.   

    很赞的效果!先赞一个
    一般给人看的代码变量名都会比较长,给机器看的会略短,虽然在JS下长度影响性能,不过还是支持给人看的代码
    很少有人能第一次写的代码就很幽雅吧,再不断的尝试,重构以后才能不断的完善,给别人看的时候就显得很幽雅.
    不过,程序不是要代码幽雅,是要能实现功能,界面幽雅,创意独到,再优美的代码表现不出独特的创意,网站是靠创意赢得客户的,不是么
    况且,写得并不差....只是个人一点拙见而已PS.我在chrome下怎么也没看出那1px的偏移..
      

  2.   


    语言我还不太会,不过编码风格还算可以。楼主自己平常多看看人家优秀的编码,还有就是各个
    语言官方的编码规范,自己多注意就好了。顺便请假一下楼主,你学js一年了。在学JS以前你会一些什么技能?我刚出学校,现在在学java
    web方面的开发。html、JavaScript以前是完全一点都不懂,近期补着看了点,但是还是用得不
    顺手(我想只有等到地久天长的时候才会顺手把)。 现在心理面有点着急,主要是在自学,觉得
    很有难度。公司的大哥都忙得要四,没什么空来带我。需求分析我都没有参与过……我也很纠结……
      

  3.   

    是不是block那个图片的关系,视觉上偏左?放大看好像没有偏
      

  4.   

    呵呵,这不挺好的效果嘛。
    看了下源码,不小心看到这样一段var Slider = new Class({
    options :{
    direction   : true, //true为纵,false为横
    type        : "Y",  //分别为X,Y,N
    shapechange : true,
    topvalue    : 0,   //上或左偏差值
    bottomvalue : 0,   //下或右偏差值
    border      : 0,   //处理ie下border的问题
    step        : 1,  //键盘操作时候的步长
    t           : 0,
    b           : 0,
    c           : 0,
    d           : 40, 
    Onmove      : function(){}
    },
    initialize :function(container,block,blockcontainer,options){
    this.container  = container;
    this.block      = block;
    this.blockcontainer = blockcontainer;
    Extend(this.options,options||{});
    this.direction  = this.options.direction;
    this.type       = this.options.type;
    this.topvalue   = this.options.topvalue;
    this.bottomvalue= this.options.bottomvalue;
    this.Onmove     = this.options.Onmove;
    this.border     = this.options.border;
    this.step       = this.options.step;
    this.t          = this.options.t;
    this.b          = this.options.b;
    this.c          = this.options.c;
    this.d          = this.options.d;
    this.timer      = null;
    this.ismove     = false;   
    this.shapechange= this.options.shapechange;
    ...
    ..
    其实确实写多了,像是Ext,或者其它框架,通常会开个apply方法用来拷贝对象属性//直接copy ext的代码
    var apply = function(o, c, defaults){
        if(defaults){
            // no "this" reference for friendly out of scope calls
            apply(o, defaults);
        }
        if(o && c && typeof c == 'object'){
            for(var p in c){
                o[p] = c[p];
            }
        }
        return o;
    };
    var Slider = new Class({
    options :{
    direction   : true, //true为纵,false为横
    type        : "Y",  //分别为X,Y,N
    shapechange : true,
    topvalue    : 0,   //上或左偏差值
    bottomvalue : 0,   //下或右偏差值
    border      : 0,   //处理ie下border的问题
    step        : 1,  //键盘操作时候的步长
    t           : 0,
    b           : 0,
    c           : 0,
    d           : 40, 
    Onmove      : function(){}
    },
    initialize :function(container,block,blockcontainer,options){
    this.container  = container;
    this.block      = block;
    this.blockcontainer = blockcontainer;
    Extend(this.options,options||{});
    /*
    this.direction  = this.options.direction;
    this.type       = this.options.type;
    this.topvalue   = this.options.topvalue;
    this.bottomvalue= this.options.bottomvalue;
    this.Onmove     = this.options.Onmove;
    this.border     = this.options.border;
    this.step       = this.options.step;
    this.t          = this.options.t;
    this.b          = this.options.b;
    this.c          = this.options.c;
    this.d          = this.options.d;
    this.timer      = null;
    this.ismove     = false;   
    this.shapechange= this.options.shapechange;
    */
    apply(this,this.options,{'timer':null,'ismove':false})//这样一行是不是可以搞定了。
    ...
    ..
      

  5.   

    大概还得写4个效果..........  在回头看看
    ie6下测试 效果很明显
    这个 对照下cloudgamer写的   很明显的区别
      

  6.   

    学js之前 我会点asp和html
    我并非全部靠自学
    有个老大指教  还有一堆热心的csdn网友指教  现在我这边的头有时也会带下我
    大家一起努力吧
    ie6  下确实有问题  我都看了2天了准确的说是1年3个月
    我专职的js民工  放在js上的时间总时间肯定比你多
    你其他的也肯定比我强多谢指教
      

  7.   


    alert("jf,一年后半年后我有这水平就可以了");
      

  8.   

    我和楼主有同感.... 
    我也一直在总结..我想应该是对JavaScript面向对像掌握的还不够深刻,概念理解的还比较浅
    缺少对整个项目控制的逻辑能力...比如说在做一个效果之前.总不能明确的定义需求,总是在做的过程中发现怎么做会更简单,更符合规则拙见....
      

  9.   

    以我这个菜鸟来说,lz很牛B啦。。是不是看看jquery,ext