first commit
This commit is contained in:
48
bootstrap/node_modules/has-transitions/index.js
generated
vendored
Normal file
48
bootstrap/node_modules/has-transitions/index.js
generated
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
/**
|
||||
* This will store the property that the current
|
||||
* browser uses for transitionDuration
|
||||
*/
|
||||
var property;
|
||||
|
||||
/**
|
||||
* The properties we'll check on an element
|
||||
* to determine if it actually has transitions
|
||||
* We use duration as this is the only property
|
||||
* needed to technically have transitions
|
||||
* @type {Array}
|
||||
*/
|
||||
var types = [
|
||||
"transitionDuration",
|
||||
"MozTransitionDuration",
|
||||
"webkitTransitionDuration"
|
||||
];
|
||||
|
||||
/**
|
||||
* Determine the correct property for this browser
|
||||
* just once so we done need to check every time
|
||||
*/
|
||||
while(types.length) {
|
||||
var type = types.shift();
|
||||
if(type in document.body.style) {
|
||||
property = type;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the browser supports transitions or
|
||||
* if an element has transitions at all.
|
||||
* @param {Element} el Optional. Returns browser support if not included
|
||||
* @return {Boolean}
|
||||
*/
|
||||
function hasTransitions(el){
|
||||
if(!property) {
|
||||
return false; // No browser support for transitions
|
||||
}
|
||||
if(!el) {
|
||||
return property != null; // We just want to know if browsers support it
|
||||
}
|
||||
var duration = getComputedStyle(el)[property];
|
||||
return duration !== "" && parseFloat(duration) !== 0; // Does this element have transitions?
|
||||
}
|
||||
|
||||
module.exports = hasTransitions;
|
Reference in New Issue
Block a user