/ Published in: jQuery
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
$.widget("example.firehose", { _create: function () { // Closure var self = this; var o = self.options; var el = self.element; // Create a Reactive JavaScript (RxJS) observable, which creates a sequence of // mouse move events o.firehose = $(document).toObservable("mousemove").Select(function (eventData) { return eventData; }); // Subscribe the DOM element to which we are attached to the mousemove events o.firehose.Subscribe(function (eventData) { // Write the X and Y coordinates into the DOM element we have attached to $(el[0]).text(eventData.offsetX + "," + eventData.offsetY); }); } });
URL: http://www.sage.co.uk/devblog