Skip to content

Commit

Permalink
craftpip#214 add option for Animate scroll to previous focused element.
Browse files Browse the repository at this point in the history
  • Loading branch information
craftpip committed Feb 19, 2017
1 parent cf3b064 commit c1ccce4
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions js/jquery-confirm.js
Original file line number Diff line number Diff line change
Expand Up @@ -943,11 +943,19 @@ var jconfirm, Jconfirm;
var ot = that._lastFocused.offset().top;
var wh = $(window).height();
if (!(ot > st && ot < (st + wh))) {
$('html, body').animate({
scrollTop: (ot - Math.round((wh / 3))),
}, that.animationSpeed, 'swing', function () {
that._lastFocused.focus();
});
var scrollTo = (ot - Math.round((wh / 3)));

if(that.scrollToPreviousElement && that.scrollToPreviousElementAnimate){
$('html, body').animate({
scrollTop: scrollTo,
}, that.animationSpeed, 'swing', function () {
that._lastFocused.focus();
});
}else if(that.scrollToPreviousElement){
$('html, body').scrollTop(scrollTo);
}else{
// do nothing.
}
} else {
that._lastFocused.focus();
}
Expand Down Expand Up @@ -1057,6 +1065,8 @@ var jconfirm, Jconfirm;
columnClass: 'col-md-4 col-md-offset-4 col-sm-6 col-sm-offset-3 col-xs-10 col-xs-offset-1',
boxWidth: '50%',
useBootstrap: true,
scrollToPreviousElement: true,
scrollToPreviousElementAnimate: true,
bootstrapClasses: {
container: 'container',
containerFluid: 'container-fluid',
Expand Down

0 comments on commit c1ccce4

Please sign in to comment.