zoukankan      html  css  js  c++  java
  • 返回顶部

    /*
     backtotop.js
     by sunhw 2014-12-2
     */
    ;
    (function() {
        T.dom.ready( function() {
            var dom = T.get( 'gototopwrap' ), timer = 0;
            var map = {
                scroH : 450,
                pageH : 230,
                ttl   : 500
            };
            if ( T.page.getViewHeight() < map.pageH || !dom ) {
                return;
            }
            var scrollHandle = function() {
                clearTimeout( timer );
                timer = setTimeout( function() {
                    if ( T.page.getScrollTop() > map.scroH ) {
                        T.dom.setStyle( dom, "visibility", "visible" );
                    } else {
                        T.dom.setStyle( dom, "visibility", "hidden" );
                    }
                }, map.ttl );
            };
            T.un( window, 'scroll', scrollHandle );
            T.on( window, 'scroll', scrollHandle );

            window.fixedIE6 && window.fixedIE6();
        } );
    })();

    /*
        backtotop.js
        by sunhw 2014-10-24
    */
    ;(function(){
        function BackTotop(option){
            this.map = {
                sh : 200, //getScrollTop
                ttl : 500, //延迟时间
                vh : 227 //getViewHeight
            };
            this.option = T.object.extend({
                root : ''
            }, option || {});
            this.ie6 = T.browser.ie < 7;
            this.init();
        }
        BackTotop.prototype.init = function(){
            var me = this;
            if(T.page.getViewHeight() < me.map.vh) return;
            me.scrollHandle = function(){
                me.timer = null;
                clearTimeout(me.timer);
                if(me.ie6){
                    if(T.get('gototopwrap')){
                        T.hide('gototopwrap');
                    }
                }
                me.timer = setTimeout(function(){
                    if(T.page.getScrollTop() > me.map.sh){
                        me.tpl = '<div class="gototop" id="gototopwrap"><a class="totop-btn" id="totopBtn" href="javascript:void(window.scroll(0,0));" hidefocus></a></div>';
                        if(!T.get('gototopwrap')){
                            T.dom.insertHTML(T.get(me.option.root), 'afterBegin', me.tpl);
                        }
                        if(me.ie6){
                            if(T.get('gototopwrap')){
                                T.get('gototopwrap').style.top = (T.page.getViewHeight()-me.map.sh)+ T.page.getScrollTop() + 'px';
                                T.show('gototopwrap');
                            }
                        }
                    }else{
                        if(T.get('gototopwrap')){
                            T.dom.remove(T.get('gototopwrap'));
                        }
                    }
                }, me.map.ttl);
            };
            T.on(window, 'scroll', me.scrollHandle);
        }
        T.dom.ready(function(){
            var gototop = new BackTotop({
                root : 'footer'
            });
        });
    })();

  • 相关阅读:
    uIP学习笔记
    ALIENTEK 战舰ENC28J60 LWIP和UIP补充例程
    PID整定方法
    ENC28j60以太网芯片驱动程序简介
    Petit FatFs
    如何使用可控硅?(详细教程)
    Linux查看系统资源占用
    驾照科目三考试通过需要注意什么?
    科目三考试
    驾照的科目三考试中,如何完成直线行驶?
  • 原文地址:https://www.cnblogs.com/sunhw360/p/4139571.html
Copyright © 2011-2022 走看看