11/*!
22 * simpleParallax - simpleParallax is a simple JavaScript library that gives your website parallax animations on any images or videos,
3- * @date : 08-04 -2020 8:7:34 ,
4- * @version : 5.4.0 ,
3+ * @date : 25-05 -2020 17:53:21 ,
4+ * @version : 5.4.1 ,
55 * @link : https://simpleparallax.com/
66 */
77( function webpackUniversalModuleDefinition ( root , factory ) {
@@ -233,6 +233,8 @@ var parallax_ParallaxInstance =
233233/*#__PURE__*/
234234function ( ) {
235235 function ParallaxInstance ( element , options ) {
236+ var _this = this ;
237+
236238 parallax_classCallCheck ( this , ParallaxInstance ) ;
237239
238240 // set the element & settings
@@ -247,17 +249,29 @@ function () {
247249 if ( helpers_isImageLoaded ( element ) ) {
248250 this . init ( ) ;
249251 } else {
250- this . element . addEventListener ( 'load' , this . init ) ;
252+ this . element . addEventListener ( 'load' , function ( ) {
253+ //timeout to ensure the image is fully loaded into the DOM
254+ setTimeout ( function ( ) {
255+ _this . init ( true ) ;
256+ } , 50 ) ;
257+ } ) ;
251258 }
252259 }
253260
254261 parallax_createClass ( ParallaxInstance , [ {
255262 key : "init" ,
256- value : function init ( ) {
257- var _this = this ;
263+ value : function init ( asyncInit ) {
264+ var _this2 = this ;
258265
259266 // for some reason, <picture> are init an infinite time on windows OS
260- if ( this . isInit ) return ; // check if element has not been already initialized with simpleParallax
267+ if ( this . isInit ) return ;
268+
269+ if ( asyncInit ) {
270+ //in case the image is lazy loaded, the rangemax should be cleared
271+ //so it will be updated in the next getTranslateValue()
272+ this . rangeMax = null ;
273+ } // check if element has not been already initialized with simpleParallax
274+
261275
262276 if ( this . element . closest ( '.simpleParallax' ) ) return ;
263277
@@ -282,7 +296,7 @@ function () {
282296 // apply a timeout to avoid buggy effect
283297 setTimeout ( function ( ) {
284298 // apply the transition style on the image
285- _this . setTransitionCSS ( ) ;
299+ _this2 . setTransitionCSS ( ) ;
286300 } , 10 ) ;
287301 } // for some reason, <picture> are init an infinite time on windows OS
288302
@@ -558,7 +572,6 @@ function () {
558572 if ( ! ( 'IntersectionObserver' in window ) ) intersectionObserverAvailable = false ;
559573
560574 if ( this . settings . customContainer ) {
561- console . log ( helpers_convertToArray ( this . settings . customContainer ) [ 0 ] ) ;
562575 this . customContainer = helpers_convertToArray ( this . settings . customContainer ) [ 0 ] ;
563576 }
564577
0 commit comments