zoukankan      html  css  js  c++  java
  • js页面滚动浮动层智能定位(MooTools)实例页面

    HTML代码:

    <div class="float" id="float">
        我是个腼腆羞涩的浮动层...
    </div>

    JS代码:

    var $smartFloat = function(elements) {
        
    var position = function(element) {
            
    var top = element.getPosition().y, pos = element.getStyle("position");
            window.addEvent(
    "scroll"function() {
                
    var scrolls = this.getScroll().y;
                
    if (scrolls > top) {
                    
    if (window.XMLHttpRequest) {
                        element.setStyles({
                            position: 
    "fixed",
                            top: 
    0
                        });    
                    } 
    else {
                        element.setStyles({
                            top: scrolls
                        });    
                    }
                }
    else {
                    element.setStyles({
                        position: 
    "absolute",
                        top: top
                    });    
                }                       
            });
        };
        
    if ($type(elements) === "array") {
            
    return elements.each(function(items) {
                position(items);                         
            });
        } 
    else if ($type(elements) === "element") {
            position(elements);    
        }
    };

    //绑定
    $smartFloat($("float"));

    转至:http://www.zhangxinxu.com/wordpress/?p=1242

  • 相关阅读:
    Python form...import...和import的区别(自己理解的)
    ! cocos2d 同一个sprite的触控问题
    cocosjs 触摸
    打包apk
    单例模式
    策略模式
    工厂模式
    cocos3 singleton
    tiledmap2
    quick cocos 暂停场景
  • 原文地址:https://www.cnblogs.com/sonicit/p/2140749.html
Copyright © 2011-2022 走看看