Fire event if custom CSS style changes?

I am writing a lightweight htc program for IE 9 (= javascript). CSS3 has a new property called transition, but it does not work in IE 9. I am trying to implement this, but I need to know when the property changes. I am familiar with DOMAttrModified and onpropertychange, but they do not start if CSS changes the property:

a { color:#FFF; } a:hover { color:#000; } 

If you anchor, DOMAttrModified does nothing. I could use mouseover, mouseout, blur, focus, activate and deactivate and check every time they occur, if the property has changed, but what if:

 div:hover a { color:#FFF; } 

The user did not set anchor marks, but CSS still changed color. I think pie.htc has the same problem. I only need a solution compatible with IE 9 ... Thanks!

+6
source share
3 answers

I do not think there is an event for "onCSSChange"

How to skip a subroutine every 50 ms and check the current style. If the CSS changes, you can fire your own event.

+1
source
0
source

A simpler and more cross-browser user will be Modernizr or a similar javascript application for testing the browser’s ability to transform transition , if it cannot, it will add the class name to the root element with which you can easily configure jQuery or a similar structure:

 $('.notransition div').hover(function() { $a = $(this).find('a'); //Then animate $a. }, function() { ... }); 

This way you can use your own property if possible, and if not, go back to jQuery.

0
source

Source: https://habr.com/ru/post/893076/


All Articles