mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02: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,17 +142,27 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 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({
|
$('.cms-tree a.jstree-clicked').entwine({
|
||||||
onmatch: function(){
|
onmatch: function(){
|
||||||
var self = this,
|
var self = this,
|
||||||
panel = self.parents('.cms-panel-content');
|
panel = self.parents('.cms-panel-content'),
|
||||||
|
scrollTo;
|
||||||
|
|
||||||
panel.animate({
|
if(self.offset().top < 0 ||
|
||||||
scrollTop: self.offset().top - (panel.height() / 2)
|
self.offset().top > panel.height() - self.height()) {
|
||||||
}, 'slow');
|
// 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: scrollTo
|
||||||
|
}, 'slow');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}(jQuery));
|
}(jQuery));
|
||||||
|
Loading…
Reference in New Issue
Block a user