3

I want to create custom cursor image, but it is limited to 32x32, while I need about 300x300 image. So it seems that I need to hide cursor cursor: none and create custom large div or image, that will be moving with invisible mouse.

The simplest implementation could be:

$(document).on('mousemove', function(e){
     $('#custom-cursor').css({
          left:  e.pageX,
          top:   e.pageY
     });
});

but I have some problems:

  1. Performance (how should I implement moving div not with left-top properties)
  2. Text selection jsfiddle cannot select text properly

Can anyone help me with this?

2
  • I'm curious about your #1 -- have you had some performance issue with it? That would surprise me. Commented May 21, 2014 at 13:44
  • @T.J.Crowder probably i want using css transforms instead of changing left-top... or some javascript implementations such as VelocityJS or GSAP Commented May 21, 2014 at 14:58

2 Answers 2

2

On modern browsers, you need to use pointer-event CSS property set to none:

--DEMO--

$(document).on('mousemove', function (e) {
    $('#custom-cursor').css({
        left: e.pageX,
        top: e.pageY,
        pointerEvents: 'none'
    });
});
Sign up to request clarification or add additional context in comments.

3 Comments

We're talking really modern, not even IE9 or IE10 support this, you need IE11 (in the IE line) to get pointer-events.
@T.J.Crowder Thx for the feedback, i wasn't sure which IE version support it, was thinking about IE9< to not support it, damn IE... Anyway, i'm not sure we can call IE11 a modern browser though
thank you! this is what i was looking for. did my problem with selection happen because cursor was selecting image/div?
0

If Cursor and Text are in the same Color, add z-index: -1 to the cursor. So the cursor is behind the text and lets you select it.

But if the color is not equal the user will see, that the cursor is behind the text.

1 Comment

interesting trick, but text-selection color laying over image.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.