jQuery UI Widget + RxJS Example (mouseover firehose)


/ Published in: jQuery
Save to your folder(s)



Copy this code and paste it in your HTML
  1. $.widget("example.firehose", {
  2. _create: function () {
  3. // Closure
  4. var self = this;
  5. var o = self.options;
  6. var el = self.element;
  7.  
  8. // Create a Reactive JavaScript (RxJS) observable, which creates a sequence of
  9. // mouse move events
  10. o.firehose = $(document).toObservable("mousemove").Select(function (eventData) {
  11. return eventData;
  12. });
  13.  
  14. // Subscribe the DOM element to which we are attached to the mousemove events
  15. o.firehose.Subscribe(function (eventData) {
  16. // Write the X and Y coordinates into the DOM element we have attached to
  17. $(el[0]).text(eventData.offsetX + "," + eventData.offsetY);
  18. });
  19. }
  20. });

URL: http://www.sage.co.uk/devblog

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.