Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var onCssLoad = function (options, callback) {
- var body = $("body");
- var div = document.createElement(constants.TAG_DIV);
- for (var key in options) {
- if (options.hasOwnProperty(key)) {
- if (key.toLowerCase() === "css") {
- continue;
- }
- div[key] = options[key];
- }
- }
- var css = options.css;
- if (css) {
- body.appendChild(div);
- var handle = -1;
- handle = window.setInterval(function () {
- var match = true;
- for (var key in css) {
- if (css.hasOwnProperty(key)) {
- match = match && utils.getStyle(div, key) === css[key];
- }
- }
- if (match === true) {
- window.clearTimeout(handle);
- body.removeChild(div);
- callback();
- }
- }, 100);
- }
- }
- onCssLoad({
- "id": <insert element CSS applies to>,
- css: <insert sample CSS styles>
- }, function () {
- console.log("CSS loaded, you can show the slideshow now :)");
- });
- function getStyle(elem, prop) {
- return window.getComputedStyle(elem, null).getPropertyValue(prop);
- }
- function checkStyle(elem, prop, callback) {
- while ( getStyle(elem, prop) !== 'computed' ) {
- // see explanation below
- }
- callback()
- }
- function checkStyle(elem, prop, callback) {
- if ( getStyle(elem, prop) !== 'computed' ) {
- // see explanation below
- window.setTimeout( function() {checkStyle(elem, prop, callback);}, 100 )
- } else {
- callback()
- }
- }
- $(function(){
- // this fn not waiting for images
- $('.selector-class')[0].style ;// this is your computed style OR...
- $('.selector-class').css(); // json representation of style;
- });
- document.addEventListener( "DOMContentLoaded", function(){
- var computedStyle = document.querySelector('#yourElementId').style ;
- })
- function getStyle(elem, prop) {
- return window.getComputedStyle(elem, null).getPropertyValue(prop);
- }
- function checkStyle(elem, prop, callback) {
- while ( getStyle(elem, prop) !== 'computed' ) {
- // see explanation below
- }
- callback()
- }
Add Comment
Please, Sign In to add comment