内容列表时候有预览,每次显示一个(2/2)

本文介绍了JavaScript动画效果库moo.fx的源码,包括滚动、文字大小修改、组合效果、折叠效果等。通过Class创建不同效果类,如fx.Scroll、fx.Text和fx.Combo,并提供了过渡、透明度、高度和宽度等多种动画效果。同时,还涉及到fx.RememberHeight和fx.RememberText,它们实现了记住元素高度和文本大小的功能。
摘要由CSDN通过智能技术生成
<script type="text/javascript"> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>

JS 文件如下

/*
moo.fx pack, effects extensions for moo.fx.
by Valerio Proietti (http://mad4milk.net) MIT-style LICENSE
for more info visit (http://moofx.mad4milk.net).
Friday, April 14, 2006
v 1.2.4
*/

//smooth scroll
fx.Scroll = Class.create();
fx.Scroll.prototype = Object.extend(new fx.Base(), {
 initialize: function(options) {
  this.setOptions(options);
 },

 scrollTo: function(el){
  var dest = Position.cumulativeOffset($(el))[1];
  var client = window.innerHeight || document.documentElement.clientHeight;
  var full = document.documentElement.scrollHeight;
  var top = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop;
  if (dest+client > full) this.custom(top, dest - client + (full-dest));
  else this.custom(top, dest);
 },

 increase: function(){
  window.scrollTo(0, this.now);
 }
});

//text size modify, now works with pixels too.
fx.Text = Class.create();
fx.Text.prototype = Object.extend(new fx.Base(), {
 initialize: function(el, options) {
  this.el = $(el);
  this.setOptions(options);
  if (!this.options.unit) this.options.unit = "em";
 },

 increase: function() {
  this.el.style.fontSize = this.now + this.options.unit;
 }
});

//composition effect: widht/height/opacity
fx.Combo = Class.create();
fx.Combo.prototype = {
 setOptions: function(options) {
  this.options = {
   opacity: true,
   height: true,
   width: false
  }
  Object.extend(this.options, options || {});
 },

 initialize: function(el, options) {
  this.el = $(el);
  this.setOptions(options);
  if (this.options.opacity) {
   this.o = new fx.Opacity(el, options);
   options.onComplete = null;
  }
  if (this.options.height) {
   this.h = new fx.Height(el, options);
   options.onComplete = null;
  }
  if (this.options.width) this.w = new fx.Width(el, options);
 },
 
 toggle: function() { this.checkExec('toggle'); },

 hide: function(){ this.checkExec('hide'); },
 
 clearTimer: function(){ this.checkExec('clearTimer'); },
 
 checkExec: function(func){
  if (this.o) this.o[func]();
  if (this.h) this.h[func]();
  if (this.w) this.w[func]();
 },
 
 //only if width+height
 resizeTo: function(hto, wto) {
  if (this.h && this.w) {
   this.h.custom(this.el.offsetHeight, this.el.offsetHeight + hto);
   this.w.custom(this.el.offsetWidth, this.el.offsetWidth + wto);
  }
 },

 customSize: function(hto, wto) {
  if (this.h && this.w) {
   this.h.custom(this.el.offsetHeight, hto);
   this.w.custom(this.el.offsetWidth, wto);
  }
 }
}

fx.Accordion = Class.create();
fx.Accordion.prototype = {
 setOptions: function(options) {
  this.options = {
   delay: 100,
   opacity: false
  }
  Object.extend(this.options, options ||

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值