1 /** 2 * @class 3 */ 4 function Zoomer(scale, toScroll, callback, time, zoomLoc) { 5 Animation.call(this, toScroll, callback, time); 6 this.toZoom = toScroll.zoomContainer; 7 var cWidth = this.toZoom.clientWidth; 8 9 this.initialWidth = cWidth; 10 11 // the container width when zoomFraction is 0 12 this.width0 = cWidth * Math.min(1, scale); 13 // the container width when zoomFraction is 1 14 var width1 = cWidth * Math.max(1, scale); 15 this.distance = width1 - this.width0; 16 this.zoomingIn = scale > 1; 17 //this.zoomLoc = zoomLoc; 18 this.center = 19 (toScroll.getX() + (toScroll.elem.clientWidth * zoomLoc)) 20 / toScroll.scrollContainer.clientWidth; 21 22 // initialX and initialLeft can differ when we're scrolling 23 // using scrollTop and scrollLeft 24 this.initialX = this.subject.getX(); 25 this.initialLeft = parseInt(this.toZoom.style.left); 26 }; 27 28 Zoomer.prototype = new Animation(); 29 30 Zoomer.prototype.step = function(pos) { 31 var zoomFraction = this.zoomingIn ? pos : 1 - pos; 32 var newWidth = 33 ((zoomFraction * zoomFraction) * this.distance) + this.width0; 34 var newLeft = (this.center * this.initialWidth) - (this.center * newWidth); 35 this.toZoom.style.width = newWidth + "px"; 36 this.toZoom.style.left = (this.initialLeft + newLeft) + "px"; 37 var forceRedraw = this.toZoom.offsetTop; 38 this.subject.updateViewDimensions({ x: this.initialX - newLeft }); 39 }; 40 41