@@ -36,8 +36,8 @@ class ParallaxInstance {
36
36
this . wrapElement ( this . element ) ;
37
37
}
38
38
39
- // apply the default style on the image
40
- this . setStyle ( ) ;
39
+ // apply the transform style on the image
40
+ this . setTransformCSS ( ) ;
41
41
42
42
// get the current element offset
43
43
this . getElementOffset ( ) ;
@@ -51,6 +51,15 @@ class ParallaxInstance {
51
51
// apply its translation even if not visible for the first init
52
52
this . animate ( ) ;
53
53
54
+ // if a delay has been set
55
+ if ( this . settings . delay > 0 ) {
56
+ // apply a timeout to avoid buggy effect
57
+ setTimeout ( ( ) => {
58
+ // apply the transition style on the image
59
+ this . setTransitionCSS ( ) ;
60
+ } , 10 ) ;
61
+ }
62
+
54
63
// for some reason, <picture> are init an infinite time on windows OS
55
64
this . isInit = true ;
56
65
}
@@ -80,23 +89,23 @@ class ParallaxInstance {
80
89
}
81
90
82
91
// apply default style on element
83
- setStyle ( ) {
92
+ setTransformCSS ( ) {
84
93
if ( this . settings . overflow === false ) {
85
94
// if overflow option is set to false
86
95
// add scale style so the image can be translated without getting out of its container
87
96
this . element . style [ cssTransform ] = `scale(${ this . settings . scale } )` ;
88
97
}
89
98
90
- if ( this . settings . delay > 0 ) {
91
- // if delay option is set to true
92
- // add transition option
93
- this . element . style . transition = `transform ${ this . settings . delay } s ${ this . settings . transition } ` ;
94
- }
95
-
96
99
// add will-change CSS property to improve perfomance
97
100
this . element . style . willChange = 'transform' ;
98
101
}
99
102
103
+ // apply the transition effet
104
+ setTransitionCSS ( ) {
105
+ // add transition option
106
+ this . element . style . transition = `transform ${ this . settings . delay } s ${ this . settings . transition } ` ;
107
+ }
108
+
100
109
// remove style of the element
101
110
unSetStyle ( ) {
102
111
// remove will change inline style
0 commit comments