Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save thehappycoder/72cde85fbfec9643fa7d to your computer and use it in GitHub Desktop.
Save thehappycoder/72cde85fbfec9643fa7d to your computer and use it in GitHub Desktop.
Index: app/assets/javascripts/blueimp-gallery.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- app/assets/javascripts/blueimp-gallery.js (revision 328:c900ca71ecec0ce23ead18ab66d10b1404191483)
+++ app/assets/javascripts/blueimp-gallery.js (revision )
@@ -154,6 +154,7 @@
// The event object for which the default action will be canceled
// on Gallery initialization (e.g. the click event to open the Gallery):
event: undefined,
+ memoryOptimizations: true,
// Callback function executed when the Gallery is initialized.
// Is called with the gallery instance as "this" object:
onopen: undefined,
@@ -285,6 +286,13 @@
return false;
}
this.initEventListeners();
+
+ for (var i = 0; i < this.num; i += 1) {
+ this.setSlideVisible(i, false);
+ }
+
+ this.setSlideVisible(0, true);
+
// Load the slide at the given index:
this.onslide(this.index);
// Manually trigger the slideend event for the initial slide:
@@ -295,6 +303,13 @@
}
},
+ setSlideVisible: function(slideIndex, visible) {
+ if (this.options.memoryOptimizations) {
+ console.log("Making slide " + slideIndex.toString() + ' ' + (visible ? 'visible' : 'hidden'));
+ this.slides[slideIndex].style.visibility = visible ? 'visible' : 'hidden';
+ }
+ },
+
slide: function (to, speed) {
window.clearTimeout(this.timeout);
var index = this.index,
@@ -334,8 +349,12 @@
);
}
to = this.circle(to);
+ var oldIndex = index;
+ this.setSlideVisible(to, true);
this.move(index, this.slideWidth * direction, speed);
this.move(to, 0, speed);
+ this.setSlideVisible(oldIndex, false);
+
if (this.options.continuous) {
this.move(
this.circle(to - direction),
@@ -606,6 +625,14 @@
this.isScrolling = undefined;
// Reset delta values:
this.touchDelta = {};
+
+ if (this.index != 0) {
+ this.setSlideVisible(this.index - 1, true);
+ }
+
+ if (this.index < this.num) {
+ this.setSlideVisible(this.index + 1, true);
+ }
},
ontouchmove: function (event) {
@@ -720,6 +747,17 @@
speed
);
index = this.circle(indexBackward);
+
+ //alert(index);
+
+ if (index != 0) {
+ this.setSlideVisible(index - 1, false);
+ }
+
+ if (index + 1 < this.num) {
+ this.setSlideVisible(index + 1, false);
+ }
+
this.onslide(index);
} else {
// Move back into position
@@ -756,6 +794,11 @@
ontransitionend: function (event) {
var slide = this.slides[this.index];
+
+ if (this.index != 0) {
+ this.setSlideVisible(this.index - 1, false);
+ }
+
if (!event || slide === event.target) {
if (this.interval) {
this.play();
@@ -793,6 +836,8 @@
this.options.onslidecomplete,
[index, parent]
);
+
+ console.log("Image " + index + " completed loading with code " + this.elements[index]);
},
onload: function (event) {
@@ -1012,6 +1057,7 @@
loadElement: function (index) {
if (!this.elements[index]) {
+ console.log("Loading element " + index);
if (this.slides[index].firstChild) {
this.elements[index] = $(this.slides[index])
.hasClass(this.options.slideErrorClass) ? 3 : 2;
@@ -1039,7 +1085,11 @@
// Connect the ends of the list to load slide elements for
// continuous navigation:
j = this.circle(j);
+
+ // When not continuous do not load images from the other end
+ if (this.options.continuous || (j - index) <= this.options.preloadRange) {
- this.loadElement(j);
+ this.loadElement(j);
+ }
}
},
\ No newline at end of file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment