File tree Expand file tree Collapse file tree 1 file changed +38
-4
lines changed Expand file tree Collapse file tree 1 file changed +38
-4
lines changed Original file line number Diff line number Diff line change 787
787
numberElement . innerHTML = formatSlideNumber ( slideNumberH , '.' , slideNumberV ) ;
788
788
page . appendChild ( numberElement ) ;
789
789
}
790
+
791
+ // Copy page and show fragments one after another
792
+ if ( isPrintingPDFFragments ( ) ) {
793
+
794
+ var numberOfFragments = toArray ( page . querySelectorAll ( '.fragment' ) ) . length ;
795
+
796
+ for ( var currentFragment = 0 ; currentFragment < numberOfFragments ; currentFragment ++ ) {
797
+ var clonedPage = page . cloneNode ( true ) ;
798
+ page . parentNode . insertBefore ( clonedPage , page . nextSibling ) ;
799
+
800
+ toArray ( sortFragments ( clonedPage . querySelectorAll ( '.fragment' ) ) ) . forEach ( function ( fragment , fragmentIndex ) {
801
+ if ( fragmentIndex <= currentFragment ) {
802
+ fragment . classList . add ( 'visible' ) ;
803
+ } else {
804
+ fragment . classList . remove ( 'visible' ) ;
805
+ }
806
+ } ) ;
807
+
808
+ page = clonedPage ;
809
+ }
810
+
811
+ }
812
+ // Show all fragments
813
+ else {
814
+ toArray ( page . querySelectorAll ( '.fragment' ) ) . forEach ( function ( fragment ) {
815
+ fragment . classList . add ( 'visible' ) ;
816
+ } ) ;
817
+ }
818
+
790
819
}
791
820
792
821
} ) ;
793
822
794
- // Show all fragments
795
- toArray ( dom . wrapper . querySelectorAll ( SLIDES_SELECTOR + ' .fragment' ) ) . forEach ( function ( fragment ) {
796
- fragment . classList . add ( 'visible' ) ;
797
- } ) ;
798
823
799
824
// Notify subscribers that the PDF layout is good to go
800
825
dispatchEvent ( 'pdf-ready' ) ;
1637
1662
1638
1663
}
1639
1664
1665
+ /**
1666
+ * Check if this instance is being used to print a PDF with fragments.
1667
+ */
1668
+ function isPrintingPDFFragments ( ) {
1669
+
1670
+ return ( / p r i n t - p d f - f r a g m e n t s / gi ) . test ( window . location . search ) ;
1671
+
1672
+ }
1673
+
1640
1674
/**
1641
1675
* Hides the address bar if we're on a mobile device.
1642
1676
*/
You can’t perform that action at this time.
0 commit comments