Skip to content

Instantly share code, notes, and snippets.

@FirstVertex
Forked from lorenzopolidori/has3d.js
Last active December 15, 2015 19:29
Show Gist options
  • Save FirstVertex/5312032 to your computer and use it in GitHub Desktop.
Save FirstVertex/5312032 to your computer and use it in GitHub Desktop.

Revisions

  1. FirstVertex revised this gist Apr 4, 2013. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion has3d.js
    Original file line number Diff line number Diff line change
    @@ -16,10 +16,12 @@ function has3d(){
    if( el.style[t] !== undefined ){
    el.style[t] = 'translate3d(1px,1px,1px)';
    has3d = window.getComputedStyle(el).getPropertyValue(transforms[t]);
    has3d = (has3d !== undefined && has3d.length > 0 && has3d !== "none");
    if (has3d) break;
    }
    }

    document.body.removeChild(el);

    return (has3d !== undefined && has3d.length > 0 && has3d !== "none");
    return has3d;
    }
  2. @lorenzopolidori lorenzopolidori revised this gist Dec 19, 2012. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions has3d.js
    Original file line number Diff line number Diff line change
    @@ -2,11 +2,11 @@ function has3d(){
    var el = document.createElement('p'),
    has3d,
    transforms = {
    'WebkitTransform':'-webkit-transform',
    'webkitTransform':'-webkit-transform',
    'OTransform':'-o-transform',
    'MSTransform':'-ms-transform',
    'msTransform':'-ms-transform',
    'MozTransform':'-moz-transform',
    'Transform':'transform'
    'transform':'transform'
    };

    // Add it to the body to get the computed style
  3. @lorenzopolidori lorenzopolidori revised this gist Sep 28, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion has3d.js
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@ function has3d(){
    };

    // Add it to the body to get the computed style
    document.body.insertBefore(el, document.body.lastChild);
    document.body.insertBefore(el, null);

    for(var t in transforms){
    if( el.style[t] !== undefined ){
  4. @lorenzopolidori lorenzopolidori revised this gist Sep 28, 2012. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions has3d.js
    Original file line number Diff line number Diff line change
    @@ -20,5 +20,6 @@ function has3d(){
    }

    document.body.removeChild(el);

    return (has3d !== undefined && has3d.length > 0 && has3d !== "none");
    }
  5. @lorenzopolidori lorenzopolidori revised this gist Sep 28, 2012. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions has3d.js
    Original file line number Diff line number Diff line change
    @@ -19,5 +19,6 @@ function has3d(){
    }
    }

    document.body.removeChild(el);
    return (has3d !== undefined && has3d.length > 0 && has3d !== "none");
    }
  6. @lorenzopolidori lorenzopolidori revised this gist Sep 27, 2012. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions has3d.js
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,6 @@
    function has3d(){
    var el = document.createElement('p'), t, has3d,
    var el = document.createElement('p'),
    has3d,
    transforms = {
    'WebkitTransform':'-webkit-transform',
    'OTransform':'-o-transform',
    @@ -11,7 +12,7 @@ function has3d(){
    // Add it to the body to get the computed style
    document.body.insertBefore(el, document.body.lastChild);

    for(t in transforms){
    for(var t in transforms){
    if( el.style[t] !== undefined ){
    el.style[t] = 'translate3d(1px,1px,1px)';
    has3d = window.getComputedStyle(el).getPropertyValue(transforms[t]);
  7. @lorenzopolidori lorenzopolidori revised this gist Sep 27, 2012. 1 changed file with 2 additions and 5 deletions.
    7 changes: 2 additions & 5 deletions has3d.js
    Original file line number Diff line number Diff line change
    @@ -17,9 +17,6 @@ function has3d(){
    has3d = window.getComputedStyle(el).getPropertyValue(transforms[t]);
    }
    }
    if (has3d !== undefined && has3d.length > 0) {
    return has3d !== "none";
    } else {
    return false;
    }

    return (has3d !== undefined && has3d.length > 0 && has3d !== "none");
    }
  8. @lorenzopolidori lorenzopolidori revised this gist Sep 27, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion has3d.js
    Original file line number Diff line number Diff line change
    @@ -13,7 +13,7 @@ function has3d(){

    for(t in transforms){
    if( el.style[t] !== undefined ){
    el.style[t] = 'translate3d(0,0,0)';
    el.style[t] = 'translate3d(1px,1px,1px)';
    has3d = window.getComputedStyle(el).getPropertyValue(transforms[t]);
    }
    }
  9. @lorenzopolidori lorenzopolidori revised this gist Sep 27, 2012. 1 changed file with 3 additions and 4 deletions.
    7 changes: 3 additions & 4 deletions has3d.js
    Original file line number Diff line number Diff line change
    @@ -8,19 +8,18 @@ function has3d(){
    'Transform':'transform'
    };

    /* Add it to the body to get the computed style.*/
    // Add it to the body to get the computed style
    document.body.insertBefore(el, document.body.lastChild);

    for(t in transforms){
    if( el.style[t] !== undefined ){
    el.style[t] = 'translate3d(0,0,0)';
    has3d = window.getComputedStyle(el).getPropertyValue( transforms[t] );
    has3d = window.getComputedStyle(el).getPropertyValue(transforms[t]);
    }
    }

    if (has3d !== undefined && has3d.length > 0) {
    return has3d !== "none";
    } else {
    } else {
    return false;
    }
    }
  10. @lorenzopolidori lorenzopolidori revised this gist Sep 27, 2012. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions has3d.js
    Original file line number Diff line number Diff line change
    @@ -18,9 +18,9 @@ function has3d(){
    }
    }

    if( has3d !== undefined ){
    return has3d !== 'none';
    } else {
    return false;
    if (has3d !== undefined && has3d.length > 0) {
    return has3d !== "none";
    } else {
    return false;
    }
    }
  11. @lorenzopolidori lorenzopolidori revised this gist Sep 27, 2012. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions has3d.js
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@ function has3d(){
    'WebkitTransform':'-webkit-transform',
    'OTransform':'-o-transform',
    'MSTransform':'-ms-transform',
    'MozTransform':'transform',
    'MozTransform':'-moz-transform',
    'Transform':'transform'
    };

    @@ -13,7 +13,7 @@ function has3d(){

    for(t in transforms){
    if( el.style[t] !== undefined ){
    el.style[ transforms[t] ] = 'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)';
    el.style[t] = 'translate3d(0,0,0)';
    has3d = window.getComputedStyle(el).getPropertyValue( transforms[t] );
    }
    }
  12. @webinista webinista revised this gist Sep 4, 2012. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion has3d.js
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    function has3d(){
    var el = document.createElement('el'), t, has3d,
    var el = document.createElement('p'), t, has3d,
    transforms = {
    'WebkitTransform':'-webkit-transform',
    'OTransform':'-o-transform',
    @@ -8,12 +8,16 @@ function has3d(){
    'Transform':'transform'
    };

    /* Add it to the body to get the computed style.*/
    document.body.insertBefore(el, document.body.lastChild);

    for(t in transforms){
    if( el.style[t] !== undefined ){
    el.style[ transforms[t] ] = 'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)';
    has3d = window.getComputedStyle(el).getPropertyValue( transforms[t] );
    }
    }

    if( has3d !== undefined ){
    return has3d !== 'none';
    } else {
  13. @webinista webinista revised this gist Sep 4, 2012. 1 changed file with 0 additions and 7 deletions.
    7 changes: 0 additions & 7 deletions has3d.js
    Original file line number Diff line number Diff line change
    @@ -8,13 +8,6 @@ function has3d(){
    'Transform':'transform'
    };

    /*
    Need to add it to the body and set a position
    to get the computed style.
    */
    document.body.insertBefore(el, document.body.lastChild);
    el.style.position = 'absolute';

    for(t in transforms){
    if( el.style[t] !== undefined ){
    el.style[ transforms[t] ] = 'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)';
  14. @webinista webinista created this gist Sep 4, 2012.
    29 changes: 29 additions & 0 deletions has3d.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    function has3d(){
    var el = document.createElement('el'), t, has3d,
    transforms = {
    'WebkitTransform':'-webkit-transform',
    'OTransform':'-o-transform',
    'MSTransform':'-ms-transform',
    'MozTransform':'transform',
    'Transform':'transform'
    };

    /*
    Need to add it to the body and set a position
    to get the computed style.
    */
    document.body.insertBefore(el, document.body.lastChild);
    el.style.position = 'absolute';

    for(t in transforms){
    if( el.style[t] !== undefined ){
    el.style[ transforms[t] ] = 'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)';
    has3d = window.getComputedStyle(el).getPropertyValue( transforms[t] );
    }
    }
    if( has3d !== undefined ){
    return has3d !== 'none';
    } else {
    return false;
    }
    }