0
極品縮放頁面時用戶使用Ctrl +滾動,如何找到jQuery的小鼠滾動縮放因子
如果我發現了變焦倍數的意思是我基於因子放大當前頁面。
例如,當我得到縮放因子1.44。所以我將它轉換爲144%並進行縮放操作。
我在許多方面都在尋找。但我沒有得到結果。
請問如何從鼠標滾動查找變焦倍數?
我的代碼在下面 - 我在這裏找到this.zoomval?
請幫幫我!
var zoomFactor = scaleFactor;
var pageViewerContainer = $('#id');
var pagecontainer = $('#id');
this._selectionNodes = window.getSelection();
if (!(this._selectionNodes.anchorOffset == 0 && this._selectionNodes.focusOffset == 0)) {
this._maintainSelection();
}
if (isFactor) {
this._zoomVal = this._zoomVal + zoomFactor;
}
var w = pagecontainer.width();
var h = pagecontainer.height();
var zoomineventvalue = { currentZoomPercentage: 0, previousZoomPercentage: 0 };
var vscrolBar = document.getElementById(this._id + '_viewerContainer');
var vscrolValue = vscrolBar.scrollTop;
var scrollValue = (vscrolValue/this._previousZoom) * this._zoomVal;
var transform = "scale(" + this._zoomVal + "," + this._zoomVal + ")";
for (var i = 1; i <= this._totalPages; i++) {
var leftpos = (this.element.width() - this._pageSize[i - 1].PageWidth * this._zoomVal)/2;
if (leftpos < 0 || this._fitType=="fitToWidth")
leftpos = 5;
var canvas = document.getElementById('pagecanvas_' + i);
var context = canvas.getContext('2d');
canvas.height = this._pageSize[i - 1].PageHeight * this._zoomVal;
canvas.width = this._pageSize[i - 1].PageWidth * this._zoomVal;
canvas.style.height = this._pageSize[i - 1].PageHeight * this._zoomVal + 'px';
canvas.style.width = this._pageSize[i - 1].PageWidth * this._zoomVal + 'px';
var height = this._pageSize[i - 1].PageHeight * this._zoomVal;
var width = this._pageSize[i - 1].PageWidth * this._zoomVal;
canvas.style.width = width + "px";
canvas.style.height = height + "px";
context.clearRect(0, 0, canvas.clientWidth, canvas.clientHeight);
var pagediv = $('#' + this._id + 'pageDiv_' + i);
pagediv[0].style.top = this._pageLocation[i] * this._zoomVal + "px";
pagediv[0].style.left = leftpos + "px";
//Hyperlink canvas
var hyperlinklayer = document.getElementById('selectioncanvas_' + i);
hyperlinklayer.style.height = canvas.height + 'px';
hyperlinklayer.style.width = canvas.width + 'px';
hyperlinklayer.style.position = 'absolute';
hyperlinklayer.style.left = 0;
hyperlinklayer.style.top = 0;
hyperlinklayer.style.backgroundColor = 'transparent';
hyperlinklayer.style.opacity = '0.2';
hyperlinklayer.style.zIndex = '2';
if (!this._isAutoZoom) {
//resizing the loding indicator of the page
$('#').css({ 'display': 'block', 'height': canvas.height + 'px', 'width': canvas.width + 'px','left':'0px','top':'0px' });
var loadingindicator = document.getElementById(this._id + 'pageDiv_' + i + '_WaitingPopup');
var spanDiv = loadingindicator.childNodes[0];
spanDiv.style.top = (canvas.height - spanDiv.clientHeight)/2 + 'px';
}
}
if (this._renderedCanvasList)
this._renderedCanvasList.length = 0;
if (this._zoomVal < 1)
pageViewerContainer.css({ '-ms-scroll-limit-y-max': (this._cummulativeHeight * this._zoomVal) - this.element.height() + 50 + "px" });
else {
pageViewerContainer.css({ '-ms-scroll-limit-y-max': "" });
}
vscrolBar.scrollTop = scrollValue;
this._eventpreviouszoomvalue = this._preZoomVal;
this._eventzoomvalue = this._zoomVal;
this._preZoomVal = this._zoomVal;
this._previousZoom = this._zoomVal;
zoomineventvalue.previousZoomPercentage = Math.round(this._eventpreviouszoomvalue * 100);
zoomineventvalue.currentZoomPercentage = Math.round(this._eventzoomvalue * 100);
this._raiseClientEvent("zoomChange", zoomineventvalue);
this.zoomPercentage = Math.round(this._zoomVal * 100);