mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 09:05:53 +00:00
Calculate where to scroll to based off the position in the div
Also, only scroll if not currently visible.
This commit is contained in:
parent
c3e25e9e07
commit
0c2514d13e
@ -142,16 +142,26 @@
|
||||
}
|
||||
});
|
||||
|
||||
// Scroll tree down to context of the current page
|
||||
// Scroll tree down to context of the current page, if it isn't
|
||||
// already visible
|
||||
$('.cms-tree a.jstree-clicked').entwine({
|
||||
onmatch: function(){
|
||||
var self = this,
|
||||
panel = self.parents('.cms-panel-content');
|
||||
panel = self.parents('.cms-panel-content'),
|
||||
scrollTo;
|
||||
|
||||
if(self.offset().top < 0 ||
|
||||
self.offset().top > panel.height() - self.height()) {
|
||||
// Current scroll top + our current offset top is our
|
||||
// position in the panel
|
||||
scrollTo = panel.scrollTop() + self.offset().top
|
||||
+ (panel.height() / 2);
|
||||
|
||||
panel.animate({
|
||||
scrollTop: self.offset().top - (panel.height() / 2)
|
||||
scrollTop: scrollTo
|
||||
}, 'slow');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user