Giter Site home page Giter Site logo

sticky's People

Contributors

afc163 avatar airyland avatar lepture avatar lizzie avatar sorrycc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sticky's Issues

sticky.fix("#bottom");调用后 没反应

'sticky': 'arale/sticky/1.1.0/sticky',

$('

footer fixed
').appendTo("body");
sticky.fix("#bottom");
调用后没反应,页面里找不到footer fixed这个元素,js都加载了。

提供占位元素

从实际使用来看,之前在 #4 中提到的占位元素避免影响页面元素的想法还是有必要的。

从实现的角度,clone 不可取,但是可以生造一个空的 div 来代替现有元素。

优化 API

sticky.stick 接口, 之前采用事件的方式将 stick 和 restored 的时间点暴露给使用者, 但这需要先绑定事件再 render 对象, 接口不太简洁. 在小组讨论后, 将原先方式:

    sticky.stick("#stick", 30).on("stick", function(e) {
        seajs.log("stick");
    }).on("restored", function(e) {
        seajs.log("restored");
    }).render();

改成:

    sticky.stick("#stick", 30, function(status) {
        if (status) {
            seajs.log("stick");
        } else {
            seajs.log("unstick");
        }
    });

即, 增加第三个 callback(status) 参数, status 为 true 时, 表示状态变为 stick, status 为 false 时, 表示状态恢复成原先的 unstick 状态.

关于top的定位问题

我现在有个需求:一个fixed的元素始终保持距body底部一定的距离。
我看代码中直接取的offset().top的距离,这样就导致我页面resize的时候,给了bottom值的元素不准确!
建议如果样式中指明了bottom的值,同时没有声明top值得情况下直接用bottom定位不可以吗?这样也不用处理resize事件,同时也跟使用者的意图是最一致的。

2个建议

  1. 现在chrome 23以上 支持 position : sticky了,考虑可以用原生实现
  2. 如果 只要fixed模拟 ,直接省略第二个参数吧(内部给予一个大值),不要人为的设置一个大值,不够友好
  3. 从固定位置变成跟随状态的一瞬间有个抖动的感觉(个人的感觉),这个还真不好模拟。。

IE9浏览器的IE9模式下Sticky.sticky指定的元素,在页面高度变化时没有触发回调的unstick处理。

其他浏览器或IE9的其他模式都是正常的。
现象描述:
1,页面高度超过浏览器可视区域,将页面滚动到底部,通过Sticky.sticky指定的元素以 position: fixed; 方式浮动在固定位置。
2,动态修改页面内容,使其高度小于可视区域,竖向滚动条消失,通过Sticky.sticky指定的元素仍以 position: fixed; 方式浮动在固定位置。未触发回调方法。
3,更换其他浏览器或IE9的其他模式则不会浮动。

sticky.stick 两个问题

  1. sticky.stick 的第二个参数 marginTop 默认值不该为 originTop.
  2. left 值设置的时机有点问题.

变量isPositionStickySupported和isPositionFixedSupported是否多余?

代码第13和14行:
var isPositionStickySupported = checkPositionStickySupported(),
isPositionFixedSupported = checkPositionFixedSupported();
这两个变量是否多余呢?代码中其他部分并没有用到。而且如果这样做了,我用checkPositionStickySupported()直接判断不是比再声明isPositionStickySupported更方便?!

title

从代码上看,考虑的情况太少了,在实际应用中会碰到很多问题。比如窗口高度小于fix内容,宽度小于页面宽度,。。。。。等等

判断ie6的bug

image
由于jquery v1.9移除了$.browser,所以插件就报错,不能支持ie6

IE6下bug

在IE6下,使用鼠标滚轮,页面可以无限往下滚(出现的概率比较小),
另外,在IE6下滚动页面的时候有很严重的闪屏现象。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.