My first thought is, elements aren't just randomly changing their own styles on their own.
I'd use some sort of custom event that your fire every time you change the styles / className of an element, and then send along the new styles or className when you do it. Couple ways to do it. http://jsfiddle.net/rpflorence/MnpzQ/ On Feb 25, 2011, at 8:42 AM, John Chavarria wrote: > Hello eveyone, > > I am currently trying to implement some sort of CSS Property watcher > on a piece of code I'm working on. First of all, I might notice you > it's Chrome (7x+, soon 9x+) only, and using mootools 1.2.4. (will also > update to 1.3 soon) > > Here is what I want to implement: Having a watcher, such as an event, > that indicates me whenever a certain CSS property is modified on a > Element and returning me this new value. > > I went through the Object.watch function, implemented - unfortunately > - in Gecko-based browsers and not Google Chrome. With the help of > keeto and some Googeling, I managed to implement the Object.watch in > Chrome, see: http://pastie.org/1606445 > > However, while this is working like a charm for plain Objects, it does > completely strange things on Elements. If I try to watch the 'height' > property on a Element for instance, console logging the property > el.style.height now returns undefined, and the watcher does not call > the set method. > > Do you guys have any idea how I could fix that? Or maybe, do you think > I'm going through the wrong idea to implement some sort of CSS > Property Watcher? > > As for now, since the Object.watch does not work properly I am using > an "Observer" while polling getStyle with the use of a periodical, but > that's heavy as hell. If I could get rid of that, that would be > perfect. > > Thanks for help! > > Moo! > > - John
