scroll 事件绑定
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 事件绑定的更多相关文章
- 关于如何绑定Jquery 的scroll事件(兼容浏览器 Wookmark瀑布流插件)
做一个随屏幕滚动的导航条时,发现一个问题: 火狐.谷歌.ie9正常,ie8.7.6页面滚动时,导航条没有反应. 代码如下: $(document).bind("scroll",fu ...
- 深入学习jQuery事件绑定
× 目录 [1]bind [2]trigger [3]delegate[4]on[5]one 前面的话 javascript有HTML.DOM0级.DOM2级和IE这四种事件处理程序,而jQuery对 ...
- jQuery-1.9.1源码分析系列(十) 事件系统——事件绑定
事件绑定的方式有很多种.使用了jQuery那么原来那种绑定方式(elem.click = function(){...})就不推荐了,原因? 最主要的一个原因是elem.click = fn这种方式只 ...
- JQuery实现click事件绑定与触发方法分析
原生JS通过什么方法绑定click事件? 原生js有一下三种方法为DOM对象绑定click事件, 第一种,在html中添加 onclick属性,在此属性中添加要绑定的事件函数,如下, 这种方法为htm ...
- 关于scroll无法绑定的问题
关于jQuery的scroll([[data],fn])事件, 概述是:当用户滚动指定的元素(元素包括:所有可滚动的元素和 window 对象)时,会触发该事件. 如绑定窗口对象: $(window) ...
- “如何稀释scroll事件”引出的问题
背景:我在segmentfault提了个问题如何稀释onscroll事件,问题如下: 面试时问到这个问题,是这样的: 面试官问一个关于滚动到某个位置的时候出现一个顶部的导航栏,答完之后,她接着问 ...
- 事件绑定之.bind()
.bind(eventType[,eventData],handler(eventObject)) 描述:为一个元素绑定一个事件处理程序,bind()绑定方法的时候元素必须已经存在. -eventTy ...
- jQuery的三种bind/One/Live/On事件绑定使用方法
本篇文章介绍了,关于jQuery新的事件绑定机制on()的使用技巧.需要的朋友参考下 今天浏览jQuery的deprecated列表,发现live()和die()在里面了,赶紧看了一下,发现从jQ ...
- JQuery的方便之处——宽高设置、坐标值和滚动条+事件绑定机制
1.元素的宽高 可以通过css来进行设置,例如:$("元素").css({"宽度":"值","高度":"值&q ...
随机推荐
- 【Binary Tree Level Order Traversal II 】cpp
题目: Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from ...
- Netsharp快速入门(之11) 销售管理(开发销售订单工作区)
作者:秋时 杨昶 时间:2014-02-15 转载须说明出处 4.3 销售订单开发 4.3.1 部件工作区设置 1.创建部件工作区,建工作区向导中要注意勾选组合并系部分.具体要建立的部 ...
- Windows下配置使用MemCached
工具: memcached-1.2.6-win32-bin.zip MemCached服务端程序(for win) Memcached Manager win下的Mem ...
- 响应式设计Responsinator工具推荐
from:http://www.25xt.com/allcode/4066.html 原文推荐了5种,感觉有用的吧就这一种,所以收藏过来. Responsinator工具的好处Responsinato ...
- 【转载】CreateProcess的用法
第一.第二个参数的用法: 例子: 使用ie打开指定的网页. 注意第二个参数是 可执行文件+命令行参数 #include "stdafx.h" #include <window ...
- yebis error ---depth of field
前几天在墙外无法登陆cnblogs...导致很多blogs就没写了 有几篇比较值得记下来的,但是我已经不记得了,应该和sao有关scalable ambient obscurance 我似乎回忆起一点 ...
- 引擎设计跟踪(九.14.2b) 骨骼动画基本完成
首先贴一个介绍max的sdk和骨骼动画的文章, 虽然很早的文章, 但是很有用, 感谢前辈们的贡献: 3Ds MAX骨骼动画导出插件编写 1.Dual Quaternion 关于Dual Quatern ...
- myeclipse 反编译插件 jad 安装
1. 准备工作 下载jad.exe文件:http://www.varaneckas.com/sites/default/files/jad/jad158g.win.zip 下载jadeclipse插 ...
- 如何理解JS项目
JS API(DOM/PhoneGap/Cordova/NodeJS/Library/Android/MongoDB....)最基础,可以看懂一行代码. -------> JS OOP, JS语 ...
- Yarn的服务库和事件库
对于生命周期较长的对象,YARN采用了基于服务对象管理模型对其进行管理. 该模型有一下特点: 每个被服务化的对象都分为4个状态 任何服务状态变化都可以触发另外一些动作 可以通过组合方式对任意服务进行组 ...