Custom jQuery event -


I want to make my own event - OnPositionChange. Organizing the course implementation is not a problem. The point is, when the style of the top or the left changes, how can it be triggered? Should I overwrite the prototype of the $ .css () function, or is there a better solution?

Not sure about an ideal method, but you can always set an interval which Does that CSS value have changed, and then this event has been triggered:

  // Bind $ ('#'. Element ') PositionChange (function () {. ..}); $ .fn.PositionChange = function (Data, FN) {// Function to Border and trigger the algies later on event = $ (this); Self.bind ('PositionChange', data, fn); Var top = self.offset (). Top; Var left = self.offset (). Left; SetInterval (function () {if (self.offset (). Top! = Top || self.offset (). Left! = Left) {self.trigger ('PositionChange');} top = self.offset () Top ; Left = self.offset () .left;}, 1000); // you can use a different interval from 1000 ms}  

Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -