SORU
23 Aralık 2010, PERŞEMBE


Nasıl fare pozisyon almak için fare olayları olmadan bir WordPress kullanmak?

Geçerli fare konumunu almak istiyorum ama kullanmak istemiyorum:

$(document).bind('mousemove',function(e){ 
        $("#log").text("e.pageX: "   e.pageX   ", e.pageY: "   e.pageY); 
}); 

sadece pozisyon almak ve bu bilgileri işlemek zorunda olduğundan

CEVAP
23 Aralık 2010, PERŞEMBE


Bir yolu olduğunu sanmıyorumsorgufare konumu, ama saklı bilgileri sorgulayabilirsiniz yüzden sadece bilgi uzakta saklayan mousemove işleyicisi kullanabilirsiniz.

jQuery(function($) {
    var currentMousePos = { x: -1, y: -1 };
    $(document).mousemove(function(event) {
        currentMousePos.x = event.pageX;
        currentMousePos.y = event.pageY;
    });

    // ELSEWHERE, your code that needs to know the mouse position without an event
    if (currentMousePos.x < 10) {
        // ....
    }
});

Amaneredeyse tüm kodu setTimeout kodu dışında böyle bir olaya tepki olarak çalışır ve çoğu olaylar fare konumu sağlar. Fare nerede olduğunu bilmesi gereken kod zaten bu bilgilere erişimi vardır

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Google Developers

    Google Devel

    23 AĞUSTOS 2007
  • Joe DiFeo

    Joe DiFeo

    7 AĞUSTOS 2012
  • Rayone GB

    Rayone GB

    14 Temmuz 2007