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 ...
随机推荐
- Java令牌生成器
package Token; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; im ...
- 安装Symfony2
我就不明白这个框架明明很小就几M,为什么这么难下载. 他们为什么不把文件打包好?非要搞得这么复杂. 一开始我在Linux ubuntu下载没有成功 然后想在win10上试试 到www.apache.o ...
- hdu 4685 二分匹配+强连通分量
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4685 题解: 这一题是poj 1904的加强版,poj 1904王子和公主的人数是一样多的,并且给出 ...
- BitMap排序
问题描述: BitMap排序思想: 用1bit位标记某个元素对应的值 优点: 效率高,不允许进行比较和移位 ...
- JS 时分秒验证
- angularJs 问题
1. IE不能渲染指令中的 style="background-color",而chrome和firefox可以 <!DOCTYPE html> <html ng ...
- 常用正则表达式(匹配URL/email/number)
var URL_REGEXP = /^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/ ...
- HTML5程序设计--SVG
SVG(Scalable Vector Graphics):可缩放矢量图形,一种二维图形表示语言. 借助SVG,我们可以实现很多同Canvas API类型的绘制操作,但在Canvas元素上绘制文本的时 ...
- JSP 页面打印
<HTML><HEAD><TITLE>javascript打印-打印页面设置-打印预览代码</TITLE> <META http-equiv=Co ...
- POJ 3255
Roadblocks Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 6605 Accepted: 2458 Descri ...