Bonjour à tous, j'utilise un code JavaScript pour afficher une image plus grande. Jusque-là, pas de problème.

Ce que je souhaite à présent, c'est afficher la preview à un endroit spécifique de ma fenêtre. Pour le moment, le JavaScript calcule toujours la position de la souris.

Si quelqu'un peut m'aider, merci.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
 
$(document).ready(function () {
 
    // Get all the thumbnail
    $('div.thumbnail-item').mouseenter(function (e) {
 
        // Calculate the position of the image tooltip
        x = e.pageX - $(this).offset().left;
        y = e.pageY - $(this).offset().top;
 
        // Set the z-index of the current item, 
        // make sure it's greater than the rest of thumbnail items
        // Set the position and display the image tooltip
        $(this).css('z-index', '15')
			.children("div.preview")
			.css({ 'top': y - 120, 'left': x + 50, 'display': 'block' });
 
    }).mousemove(function (e) {
 
        // Calculate the position of the image tooltip			
        x = e.pageX - $(this).offset().left;
        y = e.pageY - $(this).offset().top;
 
 
        // This line causes the tooltip will follow the mouse pointer
        $(this).children("div.preview").css({ 'top': y - 120, 'left': x + 50 });
 
    }).mouseleave(function () {
 
        // Reset the z-index and hide the image tooltip 
        $(this).css('z-index', '1')
			.children("div.preview")
			.animate({ "opacity": "hide" }, "fast");
    });
 
});