Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function runSlide(polyParent, stepDuration, transitionDuration) {
- function slider(polyParent, stepDuration, transitionDuration) {
- this.iterate = function() {
- $t = this;
- if ($t.polygons.length > 0) {
- $t.polygons
- .delay($t.polyIndex * $t.step)
- .qcss({
- display: "inline",
- transform: "translateY(-" + ($t.polyParent.height() * 5 * $t.stepsLeft / $t.slideFrom) + "px)",
- "transition-duration": $t.transitionDuration,
- "-webkit-transition-duration": $t.transitionDuration,
- "-moz-transition-duration": $t.transitionDuration,
- "-o-transition-duration": $t.transitionDuration
- });
- $t.lastStep = $t.stepsLeft;
- }
- $t.stepsLeft--;
- };
- this.slide = function() {
- $t = this;
- //$t.polyParent.find("polygon").hide();
- while ($t.nextPoly().length > 0) {
- while ($t.stepsLeft >= 0) {
- $t.iterate();
- }
- }
- };
- this.nextPoly = function() {
- this.polyIndex++;
- this.stepsLeft = this.slideFrom;
- this.lastStep = 0;
- polys = this.polyParent.find("[data-volume-index="+this.polyIndex+"]");
- if (polys.length > 0 && polys.first().prop("tagName").toLowerCase() != "polygon") {
- return this.nextPoly();
- }
- this.polygons = polys;
- return this.polygons
- };
- this.polyIndex = 0;
- this.slideFrom = 2; // number of length units to slide, one per step.
- this.step = stepDuration || 50; //ms duration
- this.transitionDuration = transitionDuration || "0.5s";
- this.polyParent = polyParent || $("svg");
- };
- var s = new slider(polyParent, stepDuration, transitionDuration);
- s.slide();
- return s;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement