Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chapter14-1
- Loading branch information
Showing
3 changed files
with
50 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
Template.postsList.onRendered(function () { | ||
this.find('.wrapper')._uihooks = { | ||
moveElement: function (node, next) { | ||
var $node = $(node), $next = $(next); | ||
var oldTop = $node.offset().top; | ||
var height = $(node).outerHeight(true); | ||
|
||
// find all the elements between next and node | ||
var $inBetween = $(next).nextUntil(node); | ||
if ($inBetween.length === 0) | ||
$inBetween = $(node).nextUntil(next); | ||
|
||
// now put node in place | ||
$(node).insertBefore(next); | ||
|
||
// measure new top | ||
var newTop = $(node).offset().top; | ||
|
||
// move node *back* to where it was before | ||
$(node) | ||
.removeClass('animate') | ||
.css('top', oldTop - newTop); | ||
|
||
// push every other element down (or up) to put them back | ||
$inBetween | ||
.removeClass('animate') | ||
.css('top', oldTop < newTop ? height : -1 * height) | ||
|
||
|
||
// force a redraw | ||
$(node).offset(); | ||
|
||
// reset everything to 0, animated | ||
$(node).addClass('animate').css('top', 0); | ||
$inBetween.addClass('animate').css('top', 0); | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f101ae4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pathFor couldn't find a route named "postsList"