Permalink
Browse files

Merge remote-tracking branch 'remotes/beedesk/master' into pull-request

Conflicts:
	jquery.quicksand.js
  • Loading branch information...
2 parents cb82355 + 569f51b commit 3d83ecdaed3cc3436fabdcc191e21169a11aa88c @arlm arlm committed Oct 29, 2012
Showing with 62 additions and 21 deletions.
  1. +1 −0 README
  2. +61 −21 jquery.quicksand.js
View
1 README
@@ -0,0 +1 @@
+Added support of translate3d for animation.
View
@@ -27,6 +27,7 @@ Github site: http://github.com/razorjack/quicksand
useScaling: true, // disable it if you're not using scaling effect or want to improve performance
enhancement: function(c) {}, // Visual enhacement (eg. font replacement) function for cloned elements
selector: '> *',
+ atomic: false,
dx: 0,
dy: 0,
maxWidth: 0,
@@ -77,6 +78,7 @@ Github site: http://github.com/razorjack/quicksand
if (!postCallbackPerformed) {
postCallbackPerformed = 1;
+ if (!options.atomic) {
// hack:
// used to be: $sourceParent.html($dest.html()); // put target HTML into visible source container
// but new webkit builds cause flickering when replacing the collections
@@ -126,6 +128,7 @@ Github site: http://github.com/razorjack/quicksand
if (adjustWidthOnCallback) {
$sourceParent.css('width', sourceWidth);
}
+ }
options.enhancement($sourceParent); // Perform custom visual enhancements on a newly replaced collection
if (typeof callbackFunction == 'function') {
callbackFunction.call(this);
@@ -273,19 +276,28 @@ Github site: http://github.com/razorjack/quicksand
if (!options.useScaling) {
animationQueue.push(
{
- element: $(this),
- animation:
- {top: destElement.offset().top - correctionOffset.top,
- left: destElement.offset().left - correctionOffset.left,
- opacity: 1.0
- }
+ element: $(this),
+ dest: destElement,
+ style: {top: $(this).offset().top,
+ left: $(this).offset().left,
+ opacity: ""
+ },
+ animation: {top: destElement.offset().top - correctionOffset.top,
+ left: destElement.offset().left - correctionOffset.left,
+ opacity: 1.0
+ }
});
} else {
animationQueue.push({
- element: $(this),
- animation: {top: destElement.offset().top - correctionOffset.top,
- left: destElement.offset().left - correctionOffset.left,
- opacity: 1.0,
+ element: $(this),
+ dest: destElement,
+ style: {top: $(this).offset().top,
+ left: $(this).offset().left,
+ opacity: ""
+ },
+ animation: {top: destElement.offset().top - correctionOffset.top,
+ left: destElement.offset().left - correctionOffset.left,
+ opacity: 1.0,
scale: '1.0'
}
});
@@ -294,10 +306,19 @@ Github site: http://github.com/razorjack/quicksand
// The item from source collection is not present in destination collections
// Let's remove it
if (!options.useScaling) {
- animationQueue.push({element: $(this),
+ animationQueue.push({element: $(this),
+ style: {top: $(this).offset().top,
+ left: $(this).offset().left,
+ opacity: ""
+ },
animation: {opacity: '0.0'}});
} else {
- animationQueue.push({element: $(this), animation: {opacity: '0.0',
+ animationQueue.push({element: $(this),
+ animation: {opacity: '0.0',
+ style: {top: $(this).offset().top,
+ left: $(this).offset().left,
+ opacity: ""
+ },
scale: '0.0'}});
}
}
@@ -362,20 +383,39 @@ Github site: http://github.com/razorjack/quicksand
d.appendTo($sourceParent);
if (options.maxWidth == 0 || destElement.offset().left < options.maxWidth) {
- animationQueue.push({element: $(d),
- animation: animationOptions});
+ animationQueue.push({element: $(d),
+ dest: destElement,
+ animation: animationOptions});
}
}
});
$dest.remove();
- options.enhancement($sourceParent); // Perform custom visual enhancements during the animation
- for (i = 0; i < animationQueue.length; i++) {
- if (i == animationQueue.length - 1) {
- animationQueue[i].element.animate(animationQueue[i].animation, options.duration, options.easing, postCallback);
- } else {
- animationQueue[i].element.animate(animationQueue[i].animation, options.duration, options.easing);
- }
+ if (!options.atomic) {
+ options.enhancement($sourceParent); // Perform custom visual enhancements during the animation
+ for (i = 0; i < animationQueue.length; i++) {
+ if (i == animationQueue.length - 1) {
+ animationQueue[i].element.animate(animationQueue[i].animation, options.duration, options.easing, postCallback);
+ }
+ }
+ } else {
+ $toDelete = $sourceParent.find('> *');
+ $sourceParent.prepend($dest.find('> *'));
+ for (i = 0; i < animationQueue.length; i++) {
+ if (animationQueue[i].dest && animationQueue[i].style) {
+ var destElement = animationQueue[i].dest;
+ var offset = destElement.offset();
+
+ destElement.css({
+ position: 'relative', top: (animationQueue[i].style.top - offset.top),
+ left: (animationQueue[i].style.left - offset.left)});
+
+ destElement.animate({top: "0", left: "0"}, options.duration, options.easing, postCallback);
+ } else {
+ animationQueue[i].element.animate(animationQueue[i].animation, options.duration, options.easing, postCallback);
+ }
+ }
+ $toDelete.remove();
}
});
};

0 comments on commit 3d83ecd

Please sign in to comment.