var animateBlock={
        isVisiable:function(el,wh,st,delta){
            delta=delta||200;
            //console.log($(el).offset().top,wh,st,delta)
            return $(el).offset().top<wh+st-delta;
        },
        animations:{
            band:function(wh,st){
                var $el=$("#band");
                if(animateBlock.isVisiable($el,wh,st)){
                    //background:time:0-500.o
                    //text:time:500-733.o.p:10px;
                    //menu:time:633-900.o.p:-10px;
                    $("#js-band-bg").animate({opacity:1},500);
                    $("#js-band-text").delay(500).animate({top:330,opacity:1},233);
                    $("#js-header").delay(633).animate({top:0,opacity:1},267);
                    delete animateBlock.animations.band;
                }
            },
            character:function(wh,st){
                var $el=$("#characters");
                if(animateBlock.isVisiable($el,wh,st)){
                    $el.find(".char-icon1").animate({top:50,opacity:1},333);
                    $el.find(".char-icon2").delay(200).animate({top:50,opacity:1},533);
                    $el.find(".char-icon3").delay(400).animate({top:50,opacity:1},733);

delete animateBlock.animations.character;
                }
            },
            intro1:function(wh,st){
                var $el=$("#intro1");
                if(animateBlock.isVisiable($el,wh,st)){
                    //console.log("trigger intro1 animate");
                    $el.find(".intro1-video").animate({
                        "bottom":0,
                        opacity:1
                    },500);
                    $el.find(".intro1-text").delay(167).animate({opacity:1},500);
                    $el.find(".intro1-star").delay(333).animate({opacity:1},333);
                    delete animateBlock.animations.intro1;
                }
            },
            intro2:function(wh,st){
                var $el=$("#intro2");
                if(animateBlock.isVisiable($el,wh,st)){
                    //console.log("trigger intro2 animate");
                    $el.find(".intro2-computer1").animate({
                        "top":-30,
                        opacity:1
                    },500);
                    $el.find(".intro2-computer2").delay(500).animate({
                        opacity:1
                    },167);
                    $el.find(".intro2-text").delay(167).animate({opacity:1},500);
                    delete animateBlock.animations.intro2;
                }
            },
            intro3:function(wh,st){
                var $el=$("#intro3");
                if(animateBlock.isVisiable($el,wh,st)){
                    //console.log("trigger intro3 animate");
                    $el.find(".intro3-calendar").animate({
                        "top":-31,
                        opacity:1
                    },333);
                    $el.find(".intro3-rockets").delay(233).animate({
                        "top":-46,
                        opacity:1
                    },267);
                    $el.find(".intro3-smoke").delay(333).animate({
                        "top":-31,
                        opacity:1
                    },334);
                    $el.find(".intro3-text").delay(167).animate({opacity:1},500);
                    delete animateBlock.animations.intro3;
                }
            },
            intro4:function(wh,st){
                var $el=$("#intro4");
                if(animateBlock.isVisiable($el,wh,st)){
                    //console.log("trigger intro4 animate");
                    $el.find(".intro4-hand").animate({
                        "top":-30,
                        opacity:1
                    },500);
                    $el.find(".intro4-icon").delay(333).animate({
                        opacity:1
                    },333);
                    $el.find(".intro4-text").delay(167).animate({opacity:1},500);
                    delete animateBlock.animations.intro4;
                }
            }
        }
    }

$(window).on("scroll",function(){
        var animations,
            name,
            winHeight=$(window).height(),
            scrollTop=$(window).scrollTop();

animations=animateBlock.animations;
        for(name in animations){
            animations[name](winHeight,scrollTop);
        }
    });
    if($(window).height()>500){
        $(document).trigger("scroll");
    }

scroll 事件绑定的更多相关文章

  1. 关于如何绑定Jquery 的scroll事件(兼容浏览器 Wookmark瀑布流插件)

    做一个随屏幕滚动的导航条时,发现一个问题: 火狐.谷歌.ie9正常,ie8.7.6页面滚动时,导航条没有反应. 代码如下: $(document).bind("scroll",fu ...

  2. 深入学习jQuery事件绑定

    × 目录 [1]bind [2]trigger [3]delegate[4]on[5]one 前面的话 javascript有HTML.DOM0级.DOM2级和IE这四种事件处理程序,而jQuery对 ...

  3. jQuery-1.9.1源码分析系列(十) 事件系统——事件绑定

    事件绑定的方式有很多种.使用了jQuery那么原来那种绑定方式(elem.click = function(){...})就不推荐了,原因? 最主要的一个原因是elem.click = fn这种方式只 ...

  4. JQuery实现click事件绑定与触发方法分析

    原生JS通过什么方法绑定click事件? 原生js有一下三种方法为DOM对象绑定click事件, 第一种,在html中添加 onclick属性,在此属性中添加要绑定的事件函数,如下, 这种方法为htm ...

  5. 关于scroll无法绑定的问题

    关于jQuery的scroll([[data],fn])事件, 概述是:当用户滚动指定的元素(元素包括:所有可滚动的元素和 window 对象)时,会触发该事件. 如绑定窗口对象: $(window) ...

  6. “如何稀释scroll事件”引出的问题

    背景:我在segmentfault提了个问题如何稀释onscroll事件,问题如下: 面试时问到这个问题,是这样的:    面试官问一个关于滚动到某个位置的时候出现一个顶部的导航栏,答完之后,她接着问 ...

  7. 事件绑定之.bind()

    .bind(eventType[,eventData],handler(eventObject)) 描述:为一个元素绑定一个事件处理程序,bind()绑定方法的时候元素必须已经存在. -eventTy ...

  8. jQuery的三种bind/One/Live/On事件绑定使用方法

    本篇文章介绍了,关于jQuery新的事件绑定机制on()的使用技巧.需要的朋友参考下   今天浏览jQuery的deprecated列表,发现live()和die()在里面了,赶紧看了一下,发现从jQ ...

  9. JQuery的方便之处——宽高设置、坐标值和滚动条+事件绑定机制

    1.元素的宽高 可以通过css来进行设置,例如:$("元素").css({"宽度":"值","高度":"值&q ...

随机推荐

  1. 查询sql耗时(运行时间)

    SET STATISTICS TIME ON SELECT * FROM dbo.UserBase SET STATISTICS TIME OFF

  2. php图形图像处理之生成验证码

    \(^o^)/~ 现在网上越来越离不开验证码了,不知道小伙伴们知不知利用php的GD库就可以生成验证码,Σ(⊙▽⊙"a ...... 首先介绍几个需要用的函数. 1.imagesetpixe ...

  3. Visual Studio 2013

    1.How to hide reference counts in VS2013? Tools--> Options --> Text Editor --> All Language ...

  4. boost之signal

    boost里的signal是一个模板类,不区分信号种类,产生信号统一用()调用操作符. 1.回调普通函数代码示例: #include <iostream> #include <str ...

  5. Keil中的code关键字

    一般说来,我们在C语言中定义的每一个变量初始化后都会占用一定的内存(RAM)空间.但是在keil中提供了一个特殊的关键字“code”,这个关键字在标准C中是没有的.其语法举例如下: unsigned ...

  6. jQuery打印插件PrintArea实现

    实现javascript打印功能,打印整个页面就很简单,但如果指定打印某一个区域就有点难点,这里有一个jQuery插件PrintArea可实现打印页面某区域功能. 使用说明需要使用jQuery库文件和 ...

  7. PC端模拟手机浏览网页

    很多网站都通过User-Agent来判断浏览器类型,如果是3G手机,显示手机页面内容,如果是普通浏览器,显示普通网页内容. 谷歌Chrome浏览器,可以很方便地用来当3G手机模拟器.在Windows的 ...

  8. 最长连续回文串(最优线性时间O(n))

    转自:http://blog.csdn.net/hopeztm/article/details/7932245 Given a string S, find the longest palindrom ...

  9. 20款最受欢迎的HTML5游戏引擎收集

    在“最火HTML5 JavaScript游戏引擎”系列文章国外篇(一)中,我们盘点了当下备受开发者推崇的非国产HTML5和JavaScript游戏引擎.在各种2D小游戏逆袭的今天,用HTML5和Jav ...

  10. poj 3311(floyd+状态压缩)

    题目链接:http://poj.org/problem?id=3311 思路:Floyd + 状态压缩DP  题意是有N个城市(1~N)和一个PIZZA店(0),要求一条回路,从0出发,又回到0,而且 ...