Search code examples
jqueryhtml5-canvasparticles

Need help finding what is blocking text selection in script


I am using the following mobile-me script that can be seen here:

http://lokeshdhakar.com/projects/mobileme-particles/

I have noticed that it is blocking my ability to select text on the site. For example if you use your mouse to select “Created by: lokesh dhakar” at the footer of the page, it cannot be done.

Here is the github repository:

https://github.com/lokesh/mobileme-particles

I need help finding what is blocking the text from being selected in this project. Any assistance is greatly appreciated.


Solution

  • I'll start with words of wisdom :

    Disabling text selection is bad. Don't use this.

    From http://api.jqueryui.com/disableselection/

    .disableSelection()
    

    Otherwise you can change the background of your text selection to match the other background

    ::selection {
      background: #ffb7b7; 
    }
    

    or from : How to disable text selection using jQuery?

    (function($){
      $.fn.disableSelection = function() {
        return this
                 .attr('unselectable', 'on')
                 .css('user-select', 'none')
                 .on('selectstart', false);
      };
    })(jQuery);
    

    EDIT : (From me and Presto) add Modernizr.addTest("userselect",function(){ return Modernizr.testAllProps("user-select"); }); to the js file and I can now select the text :)