Skip to content

Instantly share code, notes, and snippets.

@junaidpv
Created May 19, 2020 12:21
Show Gist options
  • Select an option

  • Save junaidpv/ea18d7e61eca50ea1b24b39560b48b8c to your computer and use it in GitHub Desktop.

Select an option

Save junaidpv/ea18d7e61eca50ea1b24b39560b48b8c to your computer and use it in GitHub Desktop.
Patch for views_slideshow moule to make Responsive Layout Builder module to integrate with views slideshows
diff --git a/modules/views_slideshow_cycle/js/rpp-slideshows.js b/modules/views_slideshow_cycle/js/rpp-slideshows.js
new file mode 100644
index 0000000..875bc48
--- /dev/null
+++ b/modules/views_slideshow_cycle/js/rpp-slideshows.js
@@ -0,0 +1,21 @@
+(function ($) {
+ // Update the window dimensions on each resize.
+ $(window).on("resize", function () {
+ Drupal.behaviors.views_slideshow_test.onResize();
+ });
+
+ Drupal.behaviors.views_slideshow_test = {
+
+ attach: function (context) {
+ this.onResize();
+ },
+
+ onResize: function () {
+ $('.rlb-load-hidden').filter(':visible').once('rlb-views-slideshow').each(function(){
+ Drupal.behaviors.viewsSlideshowCycle.attach(this);
+ });
+ }
+
+ };
+
+})(jQuery);
\ No newline at end of file
diff --git a/modules/views_slideshow_cycle/js/views_slideshow_cycle.js b/modules/views_slideshow_cycle/js/views_slideshow_cycle.js
index 57d13be..fc00d67 100644
--- a/modules/views_slideshow_cycle/js/views_slideshow_cycle.js
+++ b/modules/views_slideshow_cycle/js/views_slideshow_cycle.js
@@ -10,6 +10,10 @@
Drupal.behaviors.viewsSlideshowCycle = {
attach: function (context) {
$('.views_slideshow_cycle_main:not(.viewsSlideshowCycle-processed)', context).addClass('viewsSlideshowCycle-processed').each(function () {
+ if ($(this).is(":hidden") && $(this).parents('.rlb-load-hidden').length) {
+ $(this).removeClass('viewsSlideshowCycle-processed');
+ return;
+ }
var fullId = '#' + $(this).attr('id');
var settings = drupalSettings.viewsSlideshowCycle[fullId];
settings.targetId = '#' + $(fullId + " :first").attr('id');
diff --git a/modules/views_slideshow_cycle/views_slideshow_cycle.libraries.yml b/modules/views_slideshow_cycle/views_slideshow_cycle.libraries.yml
index b475acb..c883a8f 100644
--- a/modules/views_slideshow_cycle/views_slideshow_cycle.libraries.yml
+++ b/modules/views_slideshow_cycle/views_slideshow_cycle.libraries.yml
@@ -11,6 +11,7 @@ views_slideshow_cycle:
css/views_slideshow_cycle.css: {}
js:
js/views_slideshow_cycle.js: {}
+ js/rpp-slideshows.js: {}
dependencies:
- core/jquery
- core/drupal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment