Browse Source

New attempt to fix the webkit image size bug (Thanks orourkedd)

Jay Salvat 13 years ago
parent
commit
33d2add7e7
2 changed files with 16 additions and 46 deletions
  1. 5 1
      CHANGELOG.md
  2. 11 45
      jquery.vegas.js

+ 5 - 1
CHANGELOG.md

@@ -1,7 +1,11 @@
-# Vegas Background jQuery Plugin v1.3
+# Vegas Background jQuery Plugin v1.3.1
 
 ## CHANGE LOG
 
+### Vegas 1.3.1 2012-09-05
+* New attempt to fix the webkit image size bug (Thanks orourkedd)
+* Get rid of imagesLoadedForVegas function
+
 ### Vegas 1.3.0 2012-05-04
 
 * Fixed the destroy() error

+ 11 - 45
jquery.vegas.js

@@ -1,11 +1,11 @@
 // ----------------------------------------------------------------------------
 // Vegas - jQuery plugin 
 // Add awesome fullscreen backgrounds to your webpages.
-// v 1.3
+// v 1.3.1
 // Dual licensed under the MIT and GPL licenses.
 // http://vegas.jaysalvat.com/
 // ----------------------------------------------------------------------------
-// Copyright (C) 2011 Jay Salvat
+// Copyright (C) 2012 Jay Salvat
 // http://jaysalvat.com/
 // ----------------------------------------------------------------------------
 // Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -62,7 +62,7 @@
                 'left': '0px',
                 'top': '0px'
             })
-            .imagesLoadedForVegas( function() {
+            .bind('load', function() {
                 if ( $new == $current ) {
                     return;
                 }
@@ -340,6 +340,14 @@
         }
         $.extend( options, settings );
 
+        if( $img.height() == 0 ) {
+            console.log('pecouille');
+            $img.load( function(){
+                resize( $(this), settings );
+            } );
+            return;
+        }
+
         var ww = $( window ).width(),
             wh = $( window ).height(),
             iw = $img.width(),
@@ -444,46 +452,4 @@
             // opacity:     float
         }
     }
-
-    /*!
-     * jQuery imagesLoaded plugin v1.0.3
-     * http://github.com/desandro/imagesloaded
-     *
-     * MIT License. by Paul Irish et al.
-     */
-    $.fn.imagesLoadedForVegas = function( callback ) {
-        var $this = this,
-            $images = $this.find('img').add( $this.filter('img') ),
-            len = $images.length,
-            blank = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==';
-
-        function triggerCallback() {
-            callback.call( $this, $images );
-        }
-
-        function imgLoaded() {
-            if ( --len <= 0 && this.src !== blank ){
-                setTimeout( triggerCallback );
-                $images.unbind( 'load error', imgLoaded );
-            }
-        }
-
-        if ( !len ) {
-            setTimeout( triggerCallback, 200 );
-            // triggerCallback();
-        }
-
-        $images.bind( 'load error',  imgLoaded ).each( function() {
-            // cached images don't fire load sometimes, so we reset src.
-            if (this.complete || this.complete === undefined){
-                var src = this.src;
-                // webkit hack from http://groups.google.com/group/jquery-dev/browse_thread/thread/eee6ab7b2da50e1f
-                // data uri bypasses webkit log warning (thx doug jones)
-                this.src = blank;
-                this.src = src;
-            }
-        });
-
-        return $this;
-      };
 })( jQuery );