mirror of
https://github.com/Jermolene/TiddlyWiki5.git
synced 2025-12-06 02:30:46 -08:00
accomodate also for scroll-margin-left
This commit is contained in:
parent
49cccd7b2a
commit
9aec77b814
1 changed files with 8 additions and 4 deletions
|
|
@ -98,14 +98,18 @@ PageScroller.prototype.scrollIntoView = function(element,callback,options) {
|
|||
if(toolbar) {
|
||||
offset = toolbar.offsetHeight;
|
||||
}
|
||||
// Get the scroll-margin-top value from the element
|
||||
var scrollMarginTop = 0;
|
||||
// Get the scroll-margin-top and scroll-margin-left values from the element
|
||||
var scrollMarginTop = 0, scrollMarginLeft = 0;
|
||||
if(element) {
|
||||
var computedStyle = srcWindow.getComputedStyle(element);
|
||||
var marginTop = computedStyle.getPropertyValue("scroll-margin-top");
|
||||
if(marginTop) {
|
||||
scrollMarginTop = parseFloat(marginTop) || 0;
|
||||
}
|
||||
var marginLeft = computedStyle.getPropertyValue("scroll-margin-left");
|
||||
if(marginLeft) {
|
||||
scrollMarginLeft = parseFloat(marginLeft) || 0;
|
||||
}
|
||||
}
|
||||
// Get the client bounds of the element and adjust by the scroll position
|
||||
var getBounds = function() {
|
||||
|
|
@ -115,7 +119,7 @@ PageScroller.prototype.scrollIntoView = function(element,callback,options) {
|
|||
if(isWindowScroll) {
|
||||
scrollPosition = $tw.utils.getScrollPosition(srcWindow);
|
||||
return {
|
||||
left: clientBounds.left + scrollPosition.x,
|
||||
left: clientBounds.left + scrollPosition.x - scrollMarginLeft,
|
||||
top: clientBounds.top + scrollPosition.y - offset - scrollMarginTop,
|
||||
width: clientBounds.width,
|
||||
height: clientBounds.height
|
||||
|
|
@ -128,7 +132,7 @@ PageScroller.prototype.scrollIntoView = function(element,callback,options) {
|
|||
y: scrollContainer.scrollTop
|
||||
};
|
||||
return {
|
||||
left: clientBounds.left - containerBounds.left + scrollPosition.x,
|
||||
left: clientBounds.left - containerBounds.left + scrollPosition.x - scrollMarginLeft,
|
||||
top: clientBounds.top - containerBounds.top + scrollPosition.y - offset - scrollMarginTop,
|
||||
width: clientBounds.width,
|
||||
height: clientBounds.height
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue