code: function observeStyleChanges (element, stylesToObserve, onChange) {
      var oldStyles = {};
  
      var getStyle = function getStyle(style) {
        switch (style) {
        case 'width':
          return $(element).width();
  
        case 'height':
          return $(element).height();
  
        default:
          return $(element).css(style);
        }
      };
  
      // get the inital values
      $.forEach(stylesToObserve, function(style) {
        oldStyles[style] = getStyle(style);
      });
  
      var observer = new MutationObserver(function(mutations) {
        var changeSet = {};
  
        $.forEach(mutations, function(mutation) {
          if (mutation.attributeName !== 'style') return;
  
          var isHidden = $.isDisplayNone(element);
  
          $.forEach(stylesToObserve, function(style) {
            if(isHidden && (style === 'width' || style === 'height')) return;
  
            var newValue = getStyle(style);
  
            if (newValue !== oldStyles[style]) {
              changeSet[style] = [oldStyles[style], newValue];
              oldStyles[style] = newValue;
            }
          });
        });
  
        if (!$.isEmpty(changeSet)) {
          // Do this after so as to help avoid infinite loops of mutations.
          $.callAsync(function() {
            onChange.call(null, changeSet);
          });
        }
      });
  
      observer.observe(element, {
        attributes:true,
        attributeFilter: ['style'],
        childList:false,
        characterData:false,
        subtree:false
      });
  
      return observer;
    }
docs: tb_require('../helpers.js') tb_require('./callbacks.js') tb_require('./dom.js')