mirror of
https://github.com/sourcey/spectacle.git
synced 2024-09-11 05:25:36 +03:00
53 lines
1.4 KiB
JavaScript
53 lines
1.4 KiB
JavaScript
"use strict";
|
|
|
|
import $ from 'jquery';
|
|
|
|
// Core Foundation Utilities, utilized in a number of places.
|
|
|
|
/**
|
|
* Returns a boolean for RTL support
|
|
*/
|
|
function rtl() {
|
|
return $('html').attr('dir') === 'rtl';
|
|
}
|
|
|
|
/**
|
|
* returns a random base-36 uid with namespacing
|
|
* @function
|
|
* @param {Number} length - number of random base-36 digits desired. Increase for more random strings.
|
|
* @param {String} namespace - name of plugin to be incorporated in uid, optional.
|
|
* @default {String} '' - if no plugin name is provided, nothing is appended to the uid.
|
|
* @returns {String} - unique id
|
|
*/
|
|
function GetYoDigits(length, namespace){
|
|
length = length || 6;
|
|
return Math.round((Math.pow(36, length + 1) - Math.random() * Math.pow(36, length))).toString(36).slice(1) + (namespace ? `-${namespace}` : '');
|
|
}
|
|
|
|
function transitionend($elem){
|
|
var transitions = {
|
|
'transition': 'transitionend',
|
|
'WebkitTransition': 'webkitTransitionEnd',
|
|
'MozTransition': 'transitionend',
|
|
'OTransition': 'otransitionend'
|
|
};
|
|
var elem = document.createElement('div'),
|
|
end;
|
|
|
|
for (var t in transitions){
|
|
if (typeof elem.style[t] !== 'undefined'){
|
|
end = transitions[t];
|
|
}
|
|
}
|
|
if(end){
|
|
return end;
|
|
}else{
|
|
end = setTimeout(function(){
|
|
$elem.triggerHandler('transitionend', [$elem]);
|
|
}, 1);
|
|
return 'transitionend';
|
|
}
|
|
}
|
|
|
|
export {rtl, GetYoDigits, transitionend};
|