1
- /*! @license ScrollReveal v4.0.7
1
+ /*! @license ScrollReveal v4.0.8
2
2
3
- Copyright 2020 Fisssion LLC.
3
+ Copyright 2021 Fisssion LLC.
4
4
5
5
Licensed under the GNU General Public License 3.0 for
6
6
compatible open source projects and non-commercial use.
@@ -181,69 +181,6 @@ function rinse() {
181
181
each ( sequenceIds . stale , function ( staleId ) { return delete this$1 . store . sequences [ staleId ] ; } ) ;
182
182
}
183
183
184
- function clean ( target ) {
185
- var this$1 = this ;
186
-
187
- var dirty ;
188
- try {
189
- each ( $ ( target ) , function ( node ) {
190
- var id = node . getAttribute ( 'data-sr-id' ) ;
191
- if ( id !== null ) {
192
- dirty = true ;
193
- var element = this$1 . store . elements [ id ] ;
194
- if ( element . callbackTimer ) {
195
- window . clearTimeout ( element . callbackTimer . clock ) ;
196
- }
197
- node . setAttribute ( 'style' , element . styles . inline . generated ) ;
198
- node . removeAttribute ( 'data-sr-id' ) ;
199
- delete this$1 . store . elements [ id ] ;
200
- }
201
- } ) ;
202
- } catch ( e ) {
203
- return logger . call ( this , 'Clean failed.' , e . message )
204
- }
205
-
206
- if ( dirty ) {
207
- try {
208
- rinse . call ( this ) ;
209
- } catch ( e ) {
210
- return logger . call ( this , 'Clean failed.' , e . message )
211
- }
212
- }
213
- }
214
-
215
- function destroy ( ) {
216
- var this$1 = this ;
217
-
218
- /**
219
- * Remove all generated styles and element ids
220
- */
221
- each ( this . store . elements , function ( element ) {
222
- element . node . setAttribute ( 'style' , element . styles . inline . generated ) ;
223
- element . node . removeAttribute ( 'data-sr-id' ) ;
224
- } ) ;
225
-
226
- /**
227
- * Remove all event listeners.
228
- */
229
- each ( this . store . containers , function ( container ) {
230
- var target =
231
- container . node === document . documentElement ? window : container . node ;
232
- target . removeEventListener ( 'scroll' , this$1 . delegate ) ;
233
- target . removeEventListener ( 'resize' , this$1 . delegate ) ;
234
- } ) ;
235
-
236
- /**
237
- * Clear all data from the store
238
- */
239
- this . store = {
240
- containers : { } ,
241
- elements : { } ,
242
- history : [ ] ,
243
- sequences : { }
244
- } ;
245
- }
246
-
247
184
var getPrefixedCssProp = ( function ( ) {
248
185
var properties = { } ;
249
186
var style = document . documentElement . style ;
@@ -481,6 +418,163 @@ function style(element) {
481
418
}
482
419
}
483
420
421
+ /**
422
+ * apply a CSS string to an element using the CSSOM (element.style) rather
423
+ * than setAttribute, which may violate the content security policy.
424
+ *
425
+ * @param {Node } [el] Element to receive styles.
426
+ * @param {string } [declaration] Styles to apply.
427
+ */
428
+ function applyStyle ( el , declaration ) {
429
+ declaration . split ( ';' ) . forEach ( function ( pair ) {
430
+ var ref = pair . split ( ':' ) . map ( function ( s ) { return s . trim ( ) ; } ) ;
431
+ var property = ref [ 0 ] ;
432
+ var value = ref [ 1 ] ;
433
+ if ( property && value ) {
434
+ el . style [ property ] = value ;
435
+ }
436
+ } ) ;
437
+ }
438
+
439
+ function clean ( target ) {
440
+ var this$1 = this ;
441
+
442
+ var dirty ;
443
+ try {
444
+ each ( $ ( target ) , function ( node ) {
445
+ var id = node . getAttribute ( 'data-sr-id' ) ;
446
+ if ( id !== null ) {
447
+ dirty = true ;
448
+ var element = this$1 . store . elements [ id ] ;
449
+ if ( element . callbackTimer ) {
450
+ window . clearTimeout ( element . callbackTimer . clock ) ;
451
+ }
452
+ applyStyle ( element . node , element . styles . inline . generated ) ;
453
+ node . removeAttribute ( 'data-sr-id' ) ;
454
+ delete this$1 . store . elements [ id ] ;
455
+ }
456
+ } ) ;
457
+ } catch ( e ) {
458
+ return logger . call ( this , 'Clean failed.' , e . message )
459
+ }
460
+
461
+ if ( dirty ) {
462
+ try {
463
+ rinse . call ( this ) ;
464
+ } catch ( e ) {
465
+ return logger . call ( this , 'Clean failed.' , e . message )
466
+ }
467
+ }
468
+ }
469
+
470
+ function destroy ( ) {
471
+ var this$1 = this ;
472
+
473
+ /**
474
+ * Remove all generated styles and element ids
475
+ */
476
+ each ( this . store . elements , function ( element ) {
477
+ applyStyle ( element . node , element . styles . inline . generated ) ;
478
+ element . node . removeAttribute ( 'data-sr-id' ) ;
479
+ } ) ;
480
+
481
+ /**
482
+ * Remove all event listeners.
483
+ */
484
+ each ( this . store . containers , function ( container ) {
485
+ var target =
486
+ container . node === document . documentElement ? window : container . node ;
487
+ target . removeEventListener ( 'scroll' , this$1 . delegate ) ;
488
+ target . removeEventListener ( 'resize' , this$1 . delegate ) ;
489
+ } ) ;
490
+
491
+ /**
492
+ * Clear all data from the store
493
+ */
494
+ this . store = {
495
+ containers : { } ,
496
+ elements : { } ,
497
+ history : [ ] ,
498
+ sequences : { }
499
+ } ;
500
+ }
501
+
502
+ function deepAssign ( target ) {
503
+ var sources = [ ] , len = arguments . length - 1 ;
504
+ while ( len -- > 0 ) sources [ len ] = arguments [ len + 1 ] ;
505
+
506
+ if ( isObject ( target ) ) {
507
+ each ( sources , function ( source ) {
508
+ each ( source , function ( data , key ) {
509
+ if ( isObject ( data ) ) {
510
+ if ( ! target [ key ] || ! isObject ( target [ key ] ) ) {
511
+ target [ key ] = { } ;
512
+ }
513
+ deepAssign ( target [ key ] , data ) ;
514
+ } else {
515
+ target [ key ] = data ;
516
+ }
517
+ } ) ;
518
+ } ) ;
519
+ return target
520
+ } else {
521
+ throw new TypeError ( 'Target must be an object literal.' )
522
+ }
523
+ }
524
+
525
+ function isMobile ( agent ) {
526
+ if ( agent === void 0 ) agent = navigator . userAgent ;
527
+
528
+ return / A n d r o i d | i P h o n e | i P a d | i P o d / i. test ( agent )
529
+ }
530
+
531
+ var nextUniqueId = ( function ( ) {
532
+ var uid = 0 ;
533
+ return function ( ) { return uid ++ ; }
534
+ } ) ( ) ;
535
+
536
+ function initialize ( ) {
537
+ var this$1 = this ;
538
+
539
+ rinse . call ( this ) ;
540
+
541
+ each ( this . store . elements , function ( element ) {
542
+ var styles = [ element . styles . inline . generated ] ;
543
+
544
+ if ( element . visible ) {
545
+ styles . push ( element . styles . opacity . computed ) ;
546
+ styles . push ( element . styles . transform . generated . final ) ;
547
+ element . revealed = true ;
548
+ } else {
549
+ styles . push ( element . styles . opacity . generated ) ;
550
+ styles . push ( element . styles . transform . generated . initial ) ;
551
+ element . revealed = false ;
552
+ }
553
+
554
+ applyStyle ( element . node , styles . filter ( function ( s ) { return s !== '' ; } ) . join ( ' ' ) ) ;
555
+ } ) ;
556
+
557
+ each ( this . store . containers , function ( container ) {
558
+ var target =
559
+ container . node === document . documentElement ? window : container . node ;
560
+ target . addEventListener ( 'scroll' , this$1 . delegate ) ;
561
+ target . addEventListener ( 'resize' , this$1 . delegate ) ;
562
+ } ) ;
563
+
564
+ /**
565
+ * Manually invoke delegate once to capture
566
+ * element and container dimensions, container
567
+ * scroll position, and trigger any valid reveals
568
+ */
569
+ this . delegate ( ) ;
570
+
571
+ /**
572
+ * Wipe any existing `setTimeout` now
573
+ * that initialization has completed.
574
+ */
575
+ this . initTimeout = null ;
576
+ }
577
+
484
578
function animate ( element , force ) {
485
579
if ( force === void 0 ) force = { } ;
486
580
@@ -514,7 +608,7 @@ function triggerReveal(element, delayed) {
514
608
styles . push ( element . styles . transition . generated . instant ) ;
515
609
}
516
610
element . revealed = element . seen = true ;
517
- element . node . setAttribute ( 'style' , styles . filter ( function ( s ) { return s !== '' ; } ) . join ( ' ' ) ) ;
611
+ applyStyle ( element . node , styles . filter ( function ( s ) { return s !== '' ; } ) . join ( ' ' ) ) ;
518
612
registerCallbacks . call ( this , element , delayed ) ;
519
613
}
520
614
@@ -526,7 +620,7 @@ function triggerReset(element) {
526
620
element . styles . transition . generated . instant
527
621
] ;
528
622
element . revealed = false ;
529
- element . node . setAttribute ( 'style' , styles . filter ( function ( s ) { return s !== '' ; } ) . join ( ' ' ) ) ;
623
+ applyStyle ( element . node , styles . filter ( function ( s ) { return s !== '' ; } ) . join ( ' ' ) ) ;
530
624
registerCallbacks . call ( this , element ) ;
531
625
}
532
626
@@ -565,11 +659,6 @@ function registerCallbacks(element, isDelayed) {
565
659
} ;
566
660
}
567
661
568
- var nextUniqueId = ( function ( ) {
569
- var uid = 0 ;
570
- return function ( ) { return uid ++ ; }
571
- } ) ( ) ;
572
-
573
662
function sequence ( element , pristine ) {
574
663
if ( pristine === void 0 ) pristine = this . pristine ;
575
664
@@ -694,77 +783,6 @@ function cue(seq, i, direction, pristine) {
694
783
} , seq . interval ) ;
695
784
}
696
785
697
- function initialize ( ) {
698
- var this$1 = this ;
699
-
700
- rinse . call ( this ) ;
701
-
702
- each ( this . store . elements , function ( element ) {
703
- var styles = [ element . styles . inline . generated ] ;
704
-
705
- if ( element . visible ) {
706
- styles . push ( element . styles . opacity . computed ) ;
707
- styles . push ( element . styles . transform . generated . final ) ;
708
- element . revealed = true ;
709
- } else {
710
- styles . push ( element . styles . opacity . generated ) ;
711
- styles . push ( element . styles . transform . generated . initial ) ;
712
- element . revealed = false ;
713
- }
714
-
715
- element . node . setAttribute ( 'style' , styles . filter ( function ( s ) { return s !== '' ; } ) . join ( ' ' ) ) ;
716
- } ) ;
717
-
718
- each ( this . store . containers , function ( container ) {
719
- var target =
720
- container . node === document . documentElement ? window : container . node ;
721
- target . addEventListener ( 'scroll' , this$1 . delegate ) ;
722
- target . addEventListener ( 'resize' , this$1 . delegate ) ;
723
- } ) ;
724
-
725
- /**
726
- * Manually invoke delegate once to capture
727
- * element and container dimensions, container
728
- * scroll position, and trigger any valid reveals
729
- */
730
- this . delegate ( ) ;
731
-
732
- /**
733
- * Wipe any existing `setTimeout` now
734
- * that initialization has completed.
735
- */
736
- this . initTimeout = null ;
737
- }
738
-
739
- function isMobile ( agent ) {
740
- if ( agent === void 0 ) agent = navigator . userAgent ;
741
-
742
- return / A n d r o i d | i P h o n e | i P a d | i P o d / i. test ( agent )
743
- }
744
-
745
- function deepAssign ( target ) {
746
- var sources = [ ] , len = arguments . length - 1 ;
747
- while ( len -- > 0 ) sources [ len ] = arguments [ len + 1 ] ;
748
-
749
- if ( isObject ( target ) ) {
750
- each ( sources , function ( source ) {
751
- each ( source , function ( data , key ) {
752
- if ( isObject ( data ) ) {
753
- if ( ! target [ key ] || ! isObject ( target [ key ] ) ) {
754
- target [ key ] = { } ;
755
- }
756
- deepAssign ( target [ key ] , data ) ;
757
- } else {
758
- target [ key ] = data ;
759
- }
760
- } ) ;
761
- } ) ;
762
- return target
763
- } else {
764
- throw new TypeError ( 'Target must be an object literal.' )
765
- }
766
- }
767
-
768
786
function reveal ( target , options , syncing ) {
769
787
var this$1 = this ;
770
788
if ( options === void 0 ) options = { } ;
@@ -796,7 +814,7 @@ function reveal(target, options, syncing) {
796
814
* from throwing off the new styles, the style tag
797
815
* has to be reverted to its pre-reveal state.
798
816
*/
799
- element . node . setAttribute ( 'style' , element . styles . inline . computed ) ;
817
+ applyStyle ( element . node , element . styles . inline . computed ) ;
800
818
} else {
801
819
element . id = nextUniqueId ( ) ;
802
820
element . node = elementNode ;
@@ -1067,7 +1085,7 @@ function isTransitionSupported() {
1067
1085
return 'transition' in style || 'WebkitTransition' in style
1068
1086
}
1069
1087
1070
- var version = "4.0.7 " ;
1088
+ var version = "4.0.8 " ;
1071
1089
1072
1090
var boundDelegate ;
1073
1091
var boundDestroy ;
0 commit comments