@automattic/newspack-blocks 1.66.0 → 1.66.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,7 +7,7 @@
7
7
  * Author URI: https://newspack.blog/
8
8
  * Text Domain: newspack-blocks
9
9
  * Domain Path: /languages
10
- * Version: 1.66.0
10
+ * Version: 1.66.1
11
11
  *
12
12
  * @package Newspack_Blocks
13
13
  */
@@ -15,7 +15,7 @@
15
15
  define( 'NEWSPACK_BLOCKS__PLUGIN_FILE', __FILE__ );
16
16
  define( 'NEWSPACK_BLOCKS__BLOCKS_DIRECTORY', 'dist/' );
17
17
  define( 'NEWSPACK_BLOCKS__PLUGIN_DIR', plugin_dir_path( NEWSPACK_BLOCKS__PLUGIN_FILE ) );
18
- define( 'NEWSPACK_BLOCKS__VERSION', '1.66.0' );
18
+ define( 'NEWSPACK_BLOCKS__VERSION', '1.66.1' );
19
19
 
20
20
  require_once NEWSPACK_BLOCKS__PLUGIN_DIR . 'includes/class-newspack-blocks.php';
21
21
  require_once NEWSPACK_BLOCKS__PLUGIN_DIR . 'includes/class-newspack-blocks-api.php';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/newspack-blocks",
3
- "version": "1.66.0",
3
+ "version": "1.66.1",
4
4
  "author": "Automattic",
5
5
  "devDependencies": {
6
6
  "@rushstack/eslint-patch": "^1.2.0",
@@ -99,6 +99,7 @@ class Edit extends Component {
99
99
  if ( latestPosts && this.swiperInstance.realIndex < latestPosts.length ) {
100
100
  initialSlide = this.swiperInstance.realIndex;
101
101
  }
102
+ this.setState( { swiperInitialized: false } );
102
103
  this.swiperInstance.destroy( true, true );
103
104
  }
104
105
 
@@ -115,7 +116,6 @@ class Edit extends Component {
115
116
 
116
117
  if ( latestPosts && latestPosts.length ) {
117
118
  const { aspectRatio, autoplay, delay, slidesPerView } = this.props.attributes;
118
-
119
119
  const swiperInstance = createSwiper(
120
120
  {
121
121
  block: this.carouselRef.current, // Editor uses the same wrapper for block and swiper container.
@@ -240,7 +240,7 @@ class Edit extends Component {
240
240
  <div style={ { margin: 'auto' } }>{ __( 'Sorry, no posts were found.' ) }</div>
241
241
  </Placeholder>
242
242
  ) }
243
- { ! latestPosts && (
243
+ { ( ! this.state.swiperInitialized || ! latestPosts ) && (
244
244
  <Placeholder icon={ <Spinner /> } className="component-placeholder__align-center" />
245
245
  ) }
246
246
  { latestPosts && (
@@ -15,26 +15,37 @@ if ( typeof window !== 'undefined' ) {
15
15
  document.querySelectorAll( '.wp-block-newspack-blocks-carousel' )
16
16
  );
17
17
  blocksArray.forEach( block => {
18
- const slidesPerView = parseInt( block.dataset.slidesPerView );
19
- const slideCount = parseInt( block.dataset.slideCount );
20
- createSwiper(
21
- {
22
- block,
23
- container: block.querySelector( '.swiper' ),
24
- prev: block.querySelector( '.swiper-button-prev' ),
25
- next: block.querySelector( '.swiper-button-next' ),
26
- pagination: block.querySelector( '.swiper-pagination-bullets' ),
27
- pause: block.querySelector( '.swiper-button-pause' ),
28
- play: block.querySelector( '.swiper-button-play' ),
18
+ // Initialize Swiper only when the carousel becomes visible.
19
+ const observer = new IntersectionObserver(
20
+ entries => {
21
+ entries.forEach( entry => {
22
+ if ( entry.isIntersecting ) {
23
+ const slidesPerView = parseInt( block.dataset.slidesPerView );
24
+ const slideCount = parseInt( block.dataset.slideCount );
25
+ createSwiper(
26
+ {
27
+ block,
28
+ container: block.querySelector( '.swiper' ),
29
+ prev: block.querySelector( '.swiper-button-prev' ),
30
+ next: block.querySelector( '.swiper-button-next' ),
31
+ pagination: block.querySelector( '.swiper-pagination-bullets' ),
32
+ pause: block.querySelector( '.swiper-button-pause' ),
33
+ play: block.querySelector( '.swiper-button-play' ),
34
+ },
35
+ {
36
+ aspectRatio: parseFloat( block.dataset.aspectRatio ),
37
+ autoplay: !! parseInt( block.dataset.autoplay ),
38
+ delay: parseInt( block.dataset.autoplay_delay ) * 1000,
39
+ slidesPerView: slidesPerView <= slideCount ? slidesPerView : slideCount,
40
+ spaceBetween: 16,
41
+ }
42
+ );
43
+ }
44
+ } );
29
45
  },
30
- {
31
- aspectRatio: parseFloat( block.dataset.aspectRatio ),
32
- autoplay: !! parseInt( block.dataset.autoplay ),
33
- delay: parseInt( block.dataset.autoplay_delay ) * 1000,
34
- slidesPerView: slidesPerView <= slideCount ? slidesPerView : slideCount,
35
- spaceBetween: 16,
36
- }
46
+ { threshold: 0.25 }
37
47
  );
48
+ observer.observe( block );
38
49
  } );
39
50
  } );
40
51
  }
@@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
22
22
 
23
23
  require_once __DIR__ . '/composer/autoload_real.php';
24
24
 
25
- return ComposerAutoloaderInitba98d80c961f6c191c5abfe2b7fcd260::getLoader();
25
+ return ComposerAutoloaderInita284b8440ce7cae45448aa4583a3feee::getLoader();
@@ -2,7 +2,7 @@
2
2
 
3
3
  // autoload_real.php @generated by Composer
4
4
 
5
- class ComposerAutoloaderInitba98d80c961f6c191c5abfe2b7fcd260
5
+ class ComposerAutoloaderInita284b8440ce7cae45448aa4583a3feee
6
6
  {
7
7
  private static $loader;
8
8
 
@@ -22,12 +22,12 @@ class ComposerAutoloaderInitba98d80c961f6c191c5abfe2b7fcd260
22
22
  return self::$loader;
23
23
  }
24
24
 
25
- spl_autoload_register(array('ComposerAutoloaderInitba98d80c961f6c191c5abfe2b7fcd260', 'loadClassLoader'), true, true);
25
+ spl_autoload_register(array('ComposerAutoloaderInita284b8440ce7cae45448aa4583a3feee', 'loadClassLoader'), true, true);
26
26
  self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
27
- spl_autoload_unregister(array('ComposerAutoloaderInitba98d80c961f6c191c5abfe2b7fcd260', 'loadClassLoader'));
27
+ spl_autoload_unregister(array('ComposerAutoloaderInita284b8440ce7cae45448aa4583a3feee', 'loadClassLoader'));
28
28
 
29
29
  require __DIR__ . '/autoload_static.php';
30
- call_user_func(\Composer\Autoload\ComposerStaticInitba98d80c961f6c191c5abfe2b7fcd260::getInitializer($loader));
30
+ call_user_func(\Composer\Autoload\ComposerStaticInita284b8440ce7cae45448aa4583a3feee::getInitializer($loader));
31
31
 
32
32
  $loader->register(true);
33
33
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  namespace Composer\Autoload;
6
6
 
7
- class ComposerStaticInitba98d80c961f6c191c5abfe2b7fcd260
7
+ class ComposerStaticInita284b8440ce7cae45448aa4583a3feee
8
8
  {
9
9
  public static $classMap = array (
10
10
  'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
@@ -13,7 +13,7 @@ class ComposerStaticInitba98d80c961f6c191c5abfe2b7fcd260
13
13
  public static function getInitializer(ClassLoader $loader)
14
14
  {
15
15
  return \Closure::bind(function () use ($loader) {
16
- $loader->classMap = ComposerStaticInitba98d80c961f6c191c5abfe2b7fcd260::$classMap;
16
+ $loader->classMap = ComposerStaticInita284b8440ce7cae45448aa4583a3feee::$classMap;
17
17
 
18
18
  }, null, ClassLoader::class);
19
19
  }
@@ -3,7 +3,7 @@
3
3
  'name' => 'automattic/newspack-blocks',
4
4
  'pretty_version' => 'dev-master',
5
5
  'version' => 'dev-master',
6
- 'reference' => 'b8c0c488a2dd448a8207e8a34147fcab9cdf848d',
6
+ 'reference' => '24f3c8000d251f2272fc09d8ba7837108751506d',
7
7
  'type' => 'wordpress-plugin',
8
8
  'install_path' => __DIR__ . '/../../',
9
9
  'aliases' => array(),
@@ -13,7 +13,7 @@
13
13
  'automattic/newspack-blocks' => array(
14
14
  'pretty_version' => 'dev-master',
15
15
  'version' => 'dev-master',
16
- 'reference' => 'b8c0c488a2dd448a8207e8a34147fcab9cdf848d',
16
+ 'reference' => '24f3c8000d251f2272fc09d8ba7837108751506d',
17
17
  'type' => 'wordpress-plugin',
18
18
  'install_path' => __DIR__ . '/../../',
19
19
  'aliases' => array(),