Sha256: ee9344db353bfe7880b1407a79eba5b1604c8c8fad5aa532434d37852556a02a

Contents?: true

Size: 1.62 KB

Versions: 44

Compression:

Stored size: 1.62 KB

Contents

module.exports = {

  isDescendant: function(parent, child) {
    var node = child.parentNode;

    while (node != null) {
      if (node == parent) return true;
      node = node.parentNode;
    }

    return false;
  },

  offset: function(el) {
    var rect = el.getBoundingClientRect();
    return {
      top: rect.top + document.body.scrollTop,
      left: rect.left + document.body.scrollLeft
    };
  },

  addClass: function(el, className) {
    if (el.classList)
      el.classList.add(className);
    else
      el.className += ' ' + className;
  },

  removeClass: function(el, className) {
    if (el.classList)
      el.classList.remove(className);
    else
      el.className = el.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), ' ');
  },

  hasClass: function(el, className) {
    if (el.classList)
      return el.classList.contains(className);
    else
      return new RegExp('(^| )' + className + '( |$)', 'gi').test(el.className);
  },

  toggleClass: function(el, className) {
    if (this.hasClass(el, className))
      this.removeClass(el, className);
    else
      this.addClass(el, className);
  },

  forceRedraw: function(el) {
    var originalDisplay = el.style.display;

    el.style.display = 'none';
    el.offsetHeight;
    el.style.display = originalDisplay;
  },

  withoutTransition: function(el, callback) {
    //turn off transition
    el.style.transition = 'none';
    
    callback();

    //force a redraw
    this.forceRedraw(el);

    //put the transition back
    el.style.transition = '';
  }
  
}

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
nutella_framework-0.7.3 framework_components/roomcast-package-creator/src/app/components/material-ui/utils/dom.js
nutella_framework-0.7.2 framework_components/roomcast-package-creator/src/app/components/material-ui/utils/dom.js
nutella_framework-0.7.1 framework_components/roomcast-package-creator/src/app/components/material-ui/utils/dom.js
nutella_framework-0.7.0 framework_components/roomcast-package-creator/src/app/components/material-ui/utils/dom.js
nutella_framework-0.6.21 framework_components/roomcast-package-creator/src/app/components/material-ui/utils/dom.js
nutella_framework-0.6.20 framework_components/roomcast-package-creator/src/app/components/material-ui/utils/dom.js
nutella_framework-0.6.19 framework_components/roomcast-package-creator/src/app/components/material-ui/utils/dom.js
nutella_framework-0.6.18 framework_components/roomcast-package-creator/src/app/components/material-ui/utils/dom.js
nutella_framework-0.6.17 framework_components/roomcast-package-creator/src/app/components/material-ui/utils/dom.js
nutella_framework-0.6.16 framework_components/roomcast-package-creator/src/app/components/material-ui/utils/dom.js
nutella_framework-0.6.15 framework_components/roomcast-package-creator/src/app/components/material-ui/utils/dom.js
nutella_framework-0.6.13 framework_components/roomcast-package-creator/src/app/components/material-ui/utils/dom.js
nutella_framework-0.6.12 framework_components/roomcast-package-creator/src/app/components/material-ui/utils/dom.js
nutella_framework-0.6.11 framework_components/roomcast-package-creator/src/app/components/material-ui/utils/dom.js
nutella_framework-0.6.10 framework_components/roomcast-package-creator/src/app/components/material-ui/utils/dom.js
nutella_framework-0.6.9 framework_components/roomcast-package-creator/src/app/components/material-ui/utils/dom.js
nutella_framework-0.6.8 framework_components/roomcast-package-creator/src/app/components/material-ui/utils/dom.js
nutella_framework-0.6.7 framework_components/roomcast-package-creator/src/app/components/material-ui/utils/dom.js
nutella_framework-0.6.6 framework_components/roomcast-package-creator/src/app/components/material-ui/utils/dom.js
nutella_framework-0.6.5 framework_components/roomcast-package-creator/src/app/components/material-ui/utils/dom.js