@@ -40,6 +40,10 @@ let options = {
4040 useClassNames : false
4141} ;
4242
43+ // Detect not supported browsers (<=IE9)
44+ // http://browserhacks.com/#hack-e71d8692f65334173fee715c222cb805
45+ const isBrowserNotSupported = ( ) => document . all && ! window . atob ;
46+
4347const initializeScroll = function initializeScroll ( ) {
4448 // Extend elements objects in $aosElements with their positions
4549 $aosElements = prepare ( $aosElements , options ) ;
@@ -74,6 +78,11 @@ const refresh = function refresh(initialize = false) {
7478 */
7579const refreshHard = function refreshHard ( ) {
7680 $aosElements = elements ( ) ;
81+
82+ if ( isDisabled ( options . disable ) || isBrowserNotSupported ( ) ) {
83+ return disable ( ) ;
84+ }
85+
7786 refresh ( ) ;
7887} ;
7988
@@ -126,15 +135,18 @@ const init = function init(settings) {
126135 // Create initial array with elements -> to be fullfilled later with prepare()
127136 $aosElements = elements ( ) ;
128137
129- // Detect not supported browsers (<=IE9)
130- // http://browserhacks.com/#hack-e71d8692f65334173fee715c222cb805
131- const browserNotSupported = document . all && ! window . atob ;
138+ /**
139+ * Observe [aos] elements
140+ * If something is loaded by AJAX
141+ * it'll refresh plugin automatically
142+ */
143+ observe ( '[data-aos]' , refreshHard ) ;
132144
133145 /**
134146 * Don't init plugin if option `disable` is set
135147 * or when browser is not supported
136148 */
137- if ( isDisabled ( options . disable ) || browserNotSupported ) {
149+ if ( isDisabled ( options . disable ) || isBrowserNotSupported ( ) ) {
138150 return disable ( ) ;
139151 }
140152
@@ -180,13 +192,6 @@ const init = function init(settings) {
180192 window . addEventListener ( 'resize' , debounce ( refresh , 50 , true ) ) ;
181193 window . addEventListener ( 'orientationchange' , debounce ( refresh , 50 , true ) ) ;
182194
183- /**
184- * Observe [aos] elements
185- * If something is loaded by AJAX
186- * it'll refresh plugin automatically
187- */
188- observe ( '[data-aos]' , refreshHard ) ;
189-
190195 return $aosElements ;
191196} ;
192197
0 commit comments