這是我的相關代碼,我將根據點擊的位置切換圖像。有沒有辦法讓我逐漸切換圖像?也許在切換時動畫他們?一種淡入淡出。使用jQuery動畫製作帶200ms交叉淡入淡出的img開關源?
<script type="text/javascript">
jQuery(document).ready(function ($) { //fire on DOM ready
$('#mainproductpicture').addpowerzoom({
defaultpower: 2,
powerrange: [2, 5],
largeimage: null,
magnifiersize: [200, 200] //<--no comma following last option!
})
$('#smallpictureone').click(function() {
$("#mainproductpicture").attr("src", $(this).attr("src"));
$('#mainproductpicture').addpowerzoom({
defaultpower: 2,
powerrange: [2, 5],
largeimage: null,
magnifiersize: [200, 200] //<--no comma following last option!
})
});
$('#smallpicturetwo').click(function() {
$("#mainproductpicture").attr("src", $(this).attr("src"));
$('#mainproductpicture').addpowerzoom({
defaultpower: 2,
powerrange: [2, 5],
largeimage: null,
magnifiersize: [200, 200] //<--no comma following last option!
})
});
$('#smallpicturethree').click(function() {
$("#mainproductpicture").attr("src", $(this).attr("src"));
$('#mainproductpicture').addpowerzoom({
defaultpower: 2,
powerrange: [2, 5],
largeimage: null,
magnifiersize: [200, 200] //<--no comma following last option!
})
});
$('#smallpicturefour').click(function() {
$("#mainproductpicture").attr("src", $(this).attr("src"));
$('#mainproductpicture').addpowerzoom({
defaultpower: 2,
powerrange: [2, 5],
largeimage: null,
magnifiersize: [200, 200] //<--no comma following last option!
})
});
$('#smallpicturefive').click(function() {
$("#mainproductpicture").attr("src", $(this).attr("src"));
$('#mainproductpicture').addpowerzoom({
defaultpower: 2,
powerrange: [2, 5],
largeimage: null,
magnifiersize: [200, 200] //<--no comma following last option!
})
});
});
</script>
我有我的javascript代碼另一個相關問題。我正在使用一個我在網上找到的Javascript庫,它使我能夠很好地放大圖像。但是,當我將src切換到另一個圖像時,縮放仍保留在第一個圖像上。因此,我每次點擊圖像時都會將庫重新連接到圖像上。 這是否有我不知道的負面表現打擊?當前的gen會在我之後正確清理嗎?
非常感謝花時間寫這篇文章。 :)我原來使用的ID,因爲我不知道$(this)選擇器,這應該真的清理我的代碼。謝謝。 –
@Sergio我剛剛在我的回答中添加了一個實際的答案。我希望它有幫助。 – sholsinger