博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
mootools_使用MooTools进行背景动画
阅读量:2522 次
发布时间:2019-05-11

本文共 2320 字,大约阅读时间需要 7 分钟。

mootools

Updated 4/25/2011: The background animation has been updated to work well with Internet Explorer 7 and 8, and more efficiently with every other browser. This was accomplished by adding the wait property to the animation, and using an initial setStyle assignment to work around an IE8 background-position bug.

2011年4月25日更新:背景动画已经更新,可以与Internet Explorer 7和8协同工作,并且可以与其他所有浏览器一起更有效地工作。 这是通过将wait属性添加到动画中并使用初始setStyle分配来解决IE8 background-position错误来实现的。

One of the sweet effects made easy by JavaScript frameworks like MooTools and jQuery is animation. I ran across that walks you through animating a background image of a page. Here's a quick MooTools code snippet that shows you how you can add this sweet effect to any element on a page.

通过动画框架(如MooTools和jQuery)可以轻松实现的甜美效果之一。 我遇到了 ,它引导您动画化页面的背景图像。 这是一个快速的MooTools代码段,向您展示如何将这种甜美效果添加到页面上的任何元素。

CSS (The CSS)

#animate-area	{ 	background-image: url(clouds.png);	background-position: 0px 0px;	background-repeat: repeat-x;}

The first step is assigning the image as a background image for our given container. Be sure to repeat the background horizontally!

第一步是将图像分配为给定容器的背景图像。 确保水平重复背景!

MooTools JavaScript (The MooTools JavaScript)

window.addEvent("domready",function() {	//settings	var duration = 40000;	var length = 2000;	var count = 0;		var tweener;		// Executes the standard tween on the background position	var run = function() {		tweener.tween("background-position", "-" + (++count * length) + "px 0px");	};		// Defines the tween	tweener = $("animate-area").setStyle("background-position", "0px 0px").set("tween", { 		duration: duration, 		transition: Fx.Transitions.linear,		onComplete: run,		link: "cancel"	});		// Starts the initial run of the transition	run();	});

The first step, as always is getting our settings ready for the show. The next piece is putting the animation function in place. We increment the negative background left position counter calculation to keep the show rolling. Last step is playing the show!

与往常一样,第一步是为节目准备好我们的设置。 下一件是将动画功能放置到位。 我们增加负背景左位置计数器的计算,以保持节目的滚动。 最后一步是播放节目!

Make sure the animation speed is very slow and subtle -- a rapid background speed could make your users pass out. On the other hand, implementing it tastefully will make your website unique.

确保动画速度非常慢且微妙-快速的背景速度可能会使您的用户昏迷。 另一方面,高雅地实施它会使您的网站独一无二。

翻译自:

mootools

转载地址:http://hppwd.baihongyu.com/

你可能感兴趣的文章
@ServletComponentScan ,@ComponentScan,@Configuration 解析
查看>>
unity3d 射弹基础案例代码分析
查看>>
thinksns 分页数据
查看>>
os模块
查看>>
LINQ to SQL vs. NHibernate
查看>>
基于Angular5和WebAPI的增删改查(一)
查看>>
windows 10 & Office 2016 安装
查看>>
最短路径(SP)问题相关算法与模板
查看>>
js算法之最常用的排序
查看>>
Python——交互式图形编程
查看>>
经典排序——希尔排序
查看>>
团队编程项目作业2-团队编程项目代码设计规范
查看>>
英特尔公司将停止910GL、915GL和915PL芯片组的生产
查看>>
团队编程项目作业2-团队编程项目开发环境搭建过程
查看>>
Stax解析XML示例代码
查看>>
cookie
查看>>
二级图片导航菜单
查看>>
<Using parquet with impala>
查看>>
07-Java 中的IO操作
查看>>
uclibc,eglibc,glibc之间的区别和联系【转】
查看>>