John
I don't believe you will be able to do that across frameworks. Thats just like saying if you added an event to an element that you would expect any js framework you have included on the page, all those frameworks would trigger the event without having to set up the event watcher in each framework. From: John Chavarria [mailto:[email protected]] Sent: Saturday, 26 February 2011 3:48 AM To: [email protected] Subject: Re: [Moo] Implementing CSS Property watcher. Ryan, This is indeed an idea, however this is part of a generic class that I want other users to be able to use. So, I need the watcher to work on every kind of modification on the CSS Property. It needs to work if the user use setStyle, set, in plain js, even with JQuery, dojo or whatever. So I can't use a custom event on css property modification :-) Thanks! J. On Fri, Feb 25, 2011 at 5:05 PM, Ryan Florence <[email protected]> wrote: 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
