开发者

Dynamically created Canvas in HTML5 created rectangle to it now wanted to add hand cursor only to rectangle

$(newCanvas).mouseover( function(e) { 
    ux= x1;// where user click 
    uy = y1; 
    if( ux >=arrObjectDetail[i].pox && ux <= (arrObjectDetail[i].pox + arrObjectDetail[i].width)&& uy >= arrObjectDetail[i].poy && uy <= (arrObjectDetail[i].poy +arrObjectDetail[i].height) ) {
        $(newCanvas).css('cursor',开发者_如何学编程 'pointer'); } 
    else {
        $(newCanvas).css('cursor', 'default'); 
    }  
 ); 

On mouseover event I wanted to display hand cursor to only rectangle not entire canvas using JQUERY and HTML5.


Try this:

$(newCanvas).mouseover( function(event) { 
    uX = event.layerX; // or event.offsetX for Opera
    uY = event.layerY; // or event.offsetY for Opera
    if(uX > rectX && uX < (rectX + rectWidth) &&
       uY > rectY && uY < (rectY + rectHeight)){
        $(newCanvas).css('cursor', 'pointer'); 
    } else {
        $(newCanvas).css('cursor', 'default'); 
    }  
 });

I'm not sure what your ux=x1 and uy=y1 stuff was. You never actually get the x and y positions from the event itself which is why it never works.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜