Dyanmically build zoom level list, prevent overzoom.
This commit is contained in:
@@ -799,14 +799,16 @@ var ClicksVideo = function(youTubeAPIKey, id, container, onReady) {
|
|||||||
|
|
||||||
|
|
||||||
ClicksVideo.prototype.zoomLevels_ = function() {
|
ClicksVideo.prototype.zoomLevels_ = function() {
|
||||||
// TODO: make this dynamic and refuse to zoom beyond 1:1
|
var ret = [];
|
||||||
return [
|
var zoom = 1.0;
|
||||||
1.0,
|
while (true) {
|
||||||
1.5,
|
ret.push(zoom);
|
||||||
2.0,
|
if (this.actualZoomLevel_(zoom) >= 1.0) {
|
||||||
2.5,
|
break;
|
||||||
3.0,
|
}
|
||||||
];
|
zoom += 0.5;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -816,8 +818,14 @@ ClicksVideo.prototype.getZoomLevel = function() {
|
|||||||
|
|
||||||
|
|
||||||
ClicksVideo.prototype.zoom = function(zoomLevel) {
|
ClicksVideo.prototype.zoom = function(zoomLevel) {
|
||||||
// TODO: sotp overzoom
|
var zoomLevels = this.zoomLevels_();
|
||||||
this.zoomLevel_ = zoomLevel;
|
this.zoomLevel_ = zoomLevels[zoomLevels.length - 1];
|
||||||
|
for (var i = 0; i < zoomLevels.length; i++) {
|
||||||
|
if (zoomLevels[i] >= zoomLevel) {
|
||||||
|
this.zoomLevel_ = zoomLevels[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
this.resize();
|
this.resize();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -842,11 +850,16 @@ ClicksVideo.prototype.unhide = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
ClicksVideo.prototype.resize = function() {
|
ClicksVideo.prototype.actualZoomLevel_ = function(zoomLevel) {
|
||||||
var zoom = Math.min(
|
var zoom = Math.min(
|
||||||
this.container_.clientWidth / this.videoRes[0],
|
this.container_.clientWidth / this.videoRes[0],
|
||||||
this.container_.clientHeight / this.videoRes[1]);
|
this.container_.clientHeight / this.videoRes[1]);
|
||||||
zoom = Math.min(zoom * this.zoomLevel_, 1.0);
|
return zoom * zoomLevel;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
ClicksVideo.prototype.resize = function() {
|
||||||
|
zoom = Math.min(this.actualZoomLevel_(this.zoomLevel_), 1.0);
|
||||||
this.playerScale_.style.transform = [
|
this.playerScale_.style.transform = [
|
||||||
'scale(' + zoom + ',' + zoom + ')',
|
'scale(' + zoom + ',' + zoom + ')',
|
||||||
].join(' ');
|
].join(' ');
|
||||||
|
|||||||
Reference in New Issue
Block a user