簡體   English   中英

jqzoom彈出式廣告與移動瀏覽器(ipad)對齊

[英]jqzoom flyout alignment with mobile safari (ipad)

我已經完成了jqzoom的所有設置,除了幾件事情以外,其他所有東西都運行良好,即使我告訴jqzoom將彈出圖像對齊到原始圖像的右側,在我們的ipad上,它也將圖像放在左側。

有誰足夠了解jqzoom的工作原理,以了解為什么會這樣做? 看起來jqzoom不管如何都設置為[left:],如果彈出框位於右側,則僅相應地調整[left:]值(沿-負方向)。 如果是這樣,難道不能只是做一個if / else,如果需要在右邊,設置[right:]而不是[left:]?

這就是我設置jqzoom的方式:

<div id="jqDiv" style="width:400px; height:400px;">
<a id="imageNameAId" href="http://path.to.image/bigImage.jpg" class="MYCLASS" rel="gal1">
    <img src='http://path.to.image/smallImage.jpg' alt='imageName' id='imageNameImgId' height="400" width="400" />
</a>
</div>

<script type="text/javascript">
var options = {
    zoomType: "standard",
    lens: true,
    preloadImages: true,
    alwaysOn: false,
    zoomWidth: 600,
    zoomHeight: 600,
    xOffset: 10,
    yOffset: 0,
    position: "right",
    title: false
};
// Delay jqzoom binding to allow (rel) thumbnail images time to load
setTimeout( function() {
    jQuery('#imageNameA').jqzoom(options);
}, 500);
</script>

正常和預期:

.--. .-----.
|  | |     |
`--' |     |
     `-----'

移動Safari:

.-----. .--.
|     | |  |
|     | `--'
`-----'

我自己找到了答案。 jqzoom確定右側是否有足夠的空間放置彈出圖像,而在iPad上(在我們的示例中)沒有空間,因此它將其顯示在左側。 盡管事實上右側的空間比左側的空間大,但它仍然可以做到這一點。

因此,我正在檢測iPad,並按預期將其強制到右側。

在535行附近的jquery.jqzoom-core.js中:

之前:

    this.node.leftpos = (smallimage.rightlimit + Math.abs(settings.xOffset) + settings.zoomWidth < screen.width) ? (smallimage.ow + Math.abs(settings.xOffset)) : (0 - settings.zoomWidth - Math.abs(settings.xOffset));

后:

if (navigator.userAgent.match(/iPad/i) != null) {
    this.node.leftpos = (smallimage.ow + Math.abs(settings.xOffset));
} else {
    this.node.leftpos = (smallimage.rightlimit + Math.abs(settings.xOffset) + settings.zoomWidth < screen.width) ? (smallimage.ow + Math.abs(settings.xOffset)) : (0 - settings.zoomWidth - Math.abs(settings.xOffset));
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM