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 ...
随机推荐
- Ming Rpc
原文地址:http://iwantmoon.com/Post/487ab43d609f49d28ff4228241e2b7c7 Rpc(Remote Procedure Call Protocal)远 ...
- BZOJ 1012: [JSOI2008]最大数maxnumber 线段树
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1012 现在请求你维护一个数列,要求提供以下两种操作: 1. 查询操作.语法:Q L 功能: ...
- wrap device
刚刚看见了,wrap device && reference device 区别在这里 https://msdn.microsoft.com/en-us/library/windows ...
- map初始化定时器
init_timer(); //各种定时器的初始化 void Map::init_timer() { //auto tf = GetPlug(TimerFactory); auto tf = m_sp ...
- 贴代码—CF230 DIV1 B
题目在此: http://codeforces.com/contest/392/problem/B 一直理解错了一句话,以为是用最小的move求最小的花费, 读错题目的有木有!!! 不懂汉诺塔的原理有 ...
- AJAX实现仿Google Suggest效果
修复了一些细节代码(支持持续按键事件) *项目名称:AJAX实现类Google Suggest效果*作者:草履虫(也就是蓝色的ecma)*联系:caolvchong@gmail.com*时间:2007 ...
- 使用CSS3实现超炫的Loading(加载)动画效果
SpinKit 是一套网页动画效果,包含8种基于 CSS3 实现的很炫的加载动画.借助 CSS3 Animation 的强大功能来创建平滑,易于定制的动画.SpinKit 的目标不是提供一个每个浏览器 ...
- eclipse git 整合
最近朋友都推荐使用github管理自己的项目,而且免费用户可以有5个仓库,恰好我也想了解下git,借此机会学习一下.github官方指南使用独立第三方git工具来进行版本控制,并不借助于eclipse ...
- self._raiseerror(v) File "D:\GameDevelopment\Python27\lib\xml\etree\ElementTree.py", line 1506, in _raiseerror
D:\BaiDuYun\Plist>python unpack_plist.py lobbyRelieveTraceback (most recent call last): File &quo ...
- FastDfs点滴
1.centos安装后提示找不到libevent动态库 根据系统是64位版本还是32位版本,若是64位版本则默认回到 /usr/lib64 目录下查找,而对于32位则到 /usr/lib 目录下查找. ...