javascript - Why positioning element next to mouse cursor is so "laggy"? -


https://jsfiddle.net/m0zwwav4/

html:

<div id="container"></div> <div id="tooltip">tooltip!</div> 

css:

#container {     width: 500px;     height: 500px;     border: solid 1px red; }  #tooltip {   position: absolute; } 

js:

var container = document.getelementbyid('container') var tooltip = document.getelementbyid('tooltip')  container.onmousemove = function(event) {   tooltip.style.left = (event.pagex + 20) + 'px'   tooltip.style.top = event.pagey + 'px' } 

when move cursor inside red box, tooltip seems little bit laggy (there little delay) - testing in chrome on max os. there trick make faster make moving fast mouse cursor?

you can without javascript.

change container's cursor url, image containing tooltip text:

enter image description here

you can using data uri:

#container {   cursor: url(data:image/png;base64,ivborw0kggoaaaansuheugaaaeoaaaazcaiaaaazqc9/aaaaaxnsr0iars4c6qaaaarnqu1baacxjwv8yquaaaajcehzcwaadsmaaa7dacdvqgqaaaipsurbvfhh5zg7csiweizxzgkp0kch6kccg0bbaqv0kdofwptq5qapcaudlqfhugb3cx5ji2t5irnjbsb5zjlj1yqvpz1st5wgccrl5qv/jdhhcfb7vwwqe1wp7ha7ywrspkpsa+v1ejgclsxq6whf90u2hoyewbqwytcqbx5l6a3wghocgudxestoayuhvickwvmz9bkfnavxd5wsb/6+hm+vvboqhotvpb8pdhulqxog0xcb7wdbqi/i/oriynevdfekotqkobajk2fspgfynmpzvcwmxrldr/bsbb5yvaw4xpzchc0vlbwqchu1k6bqdtod2x+z2tqadwrngo9tg/sucfxxte0vezyvqbeqiihumkohk7vw+jqrw4ejw7lwpuu4lx17chkplx9isu1zgy7oglh77durusfeix4rkmjowq1rrueovg+xn5g7pwnyhb2lef2fu1b2bpj7jew7uzlhuqdwg9tsnsmcymn2w9vp/ggt+gfrhfrwuubwr9dlebuho9pscu9ye7zosfznzjn8zec73zyt6ijo7mwgdpnupd4ytmfjbsmmcyux+6ik5tntjqkufyennh7aqn3gvvldmnzdfijqmyrukvkpzbrg7oaijbnjw7ijbbwgty+5k13vhc+/3hog9gj946tqayjhx8/qbrl1ur9aan4n6fhq4/qx/ip/ljwyuutvkr8o6juk23d1qgaaaabjru5erkjggg==), auto; } 

fiddle


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -