Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
328 additions
and
276 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
define(['dojo/_base/declare' | ||
], | ||
function(declare) { | ||
/** | ||
* @class | ||
*/ | ||
return declare (null, { | ||
constructor: function(subject, callback, time) { | ||
//subject: what's being animated | ||
//callback: function to call at the end of the animation | ||
//time: time for the animation to run | ||
|
||
//don't want a zoom and a slide going on at the same time | ||
if ("animation" in subject) subject.animation.stop(); | ||
this.index = 0; | ||
this.time = time; | ||
this.subject = subject; | ||
this.callback = callback; | ||
|
||
var myAnim = this; | ||
this.animFunction = function() { myAnim.animate(); }; | ||
// number of milliseconds between frames (e.g., 33ms at 30fps) | ||
this.animID = setTimeout(this.animFunction, 33); | ||
|
||
this.frames = 0; | ||
|
||
subject.animation = this; | ||
}, | ||
|
||
animate: function() { | ||
if (this.finished) { | ||
this.stop(); | ||
return; | ||
} | ||
|
||
// number of milliseconds between frames (e.g., 33ms at 30fps) | ||
var nextTimeout = 33; | ||
var elapsed = 0; | ||
if (!("startTime" in this)) { | ||
this.startTime = (new Date()).getTime(); | ||
} else { | ||
elapsed = (new Date()).getTime() - this.startTime; | ||
//set the next timeout to be the average of the | ||
//frame times we've achieved so far. | ||
//The goal is to avoid overloading the browser | ||
//and getting a jerky animation. | ||
nextTimeout = Math.max(33, elapsed / this.frames); | ||
} | ||
|
||
if (elapsed < this.time) { | ||
this.step(elapsed / this.time); | ||
this.frames++; | ||
} else { | ||
this.step(1); | ||
this.finished = true; | ||
//console.log("final timeout: " + nextTimeout); | ||
} | ||
this.animID = setTimeout(this.animFunction, nextTimeout); | ||
}, | ||
|
||
stop: function() { | ||
clearTimeout(this.animID); | ||
delete this.subject.animation; | ||
this.callback.call(this.subject,this); | ||
} | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
define(['JBrowse/View/Animation'], | ||
function(Animation) { | ||
define(['dojo/_base/declare', | ||
'Rotunda/View/Animation'], | ||
function(declare, | ||
Animation) { | ||
|
||
/** | ||
* @class | ||
*/ | ||
function Slider(radians, rotunda, callback, time) { | ||
Animation.call(this, rotunda, callback, time) | ||
this.rotunda = rotunda | ||
this.degrees = (radians - rotunda.rotate) * 180 / Math.PI | ||
} | ||
return declare (Animation, | ||
{ | ||
constructor: function(rotunda, callback, time, radians) { | ||
this.rotunda = rotunda | ||
this.degrees = (radians - rotunda.rotate) * 180 / Math.PI | ||
}, | ||
|
||
Slider.prototype = new Animation(); | ||
|
||
Slider.prototype.step = function(pos) { | ||
this.rotunda.gTransformRotate (this.degrees * pos) | ||
}; | ||
|
||
return Slider; | ||
}); | ||
step: function(pos) { | ||
this.rotunda.gTransformRotate (this.degrees * pos) | ||
} | ||
}) | ||
}); |
Oops, something went wrong.