⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 15.04 - animation example.js

📁 JS设计模式源代码
💻 JS
字号:
// Publisher APIvar Animation = function(o) {  this.onStart = new Publisher,  this.onComplete = new Publisher,  this.onTween = new Publisher;};Animation.  method('fly', function() {    // begin animation    this.onStart.deliver();    for ( ... ) { // loop through frames      // deliver frame number      this.onTween.deliver(i);     }    // end animation    this.onComplete.deliver();  });// setup an account with the animation managervar Superman = new Animation({...config properties...});// Begin implementing subscribersvar putOnCape = function(i) { };var takeOffCape = function(i) { };putOnCape.subscribe(Superman.onStart);takeOffCape.subscribe(Superman.onComplete);// fly can be called anywhereSuperman.fly();// for instance:addEvent(element, 'click', function() {  Superman.fly();});

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -