scroll to current reference
This commit is contained in:
parent
f092db3780
commit
ce09b3bcde
1 changed files with 12 additions and 0 deletions
|
@ -71,6 +71,9 @@ pandora.ui.textPanel = function() {
|
||||||
float: 'right',
|
float: 'right',
|
||||||
margin: '4px 2px 4px 2px'
|
margin: '4px 2px 4px 2px'
|
||||||
})
|
})
|
||||||
|
.bindEvent({
|
||||||
|
click: scrollToSelectedEmbed
|
||||||
|
})
|
||||||
.appendTo($toolbar),
|
.appendTo($toolbar),
|
||||||
|
|
||||||
$previousButton = Ox.Button({
|
$previousButton = Ox.Button({
|
||||||
|
@ -183,6 +186,12 @@ pandora.ui.textPanel = function() {
|
||||||
return urls;
|
return urls;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function scrollToSelectedEmbed() {
|
||||||
|
var scrollTop = Math.max(pandora.$ui.text[0].scrollTop + $('#embed' + selected).offset().top - 50, 0),
|
||||||
|
position = 100 * scrollTop / pandora.$ui.text[0].scrollHeight;
|
||||||
|
pandora.$ui.text.scrollTo(position);
|
||||||
|
}
|
||||||
|
|
||||||
that.selectEmbed = function(index) {
|
that.selectEmbed = function(index) {
|
||||||
if (index != selected) {
|
if (index != selected) {
|
||||||
selected = index;
|
selected = index;
|
||||||
|
@ -190,6 +199,7 @@ pandora.ui.textPanel = function() {
|
||||||
$('.OxSpecialLink').removeClass('OxActive');
|
$('.OxSpecialLink').removeClass('OxActive');
|
||||||
selected > -1 && $('#embed' + selected).addClass('OxActive');
|
selected > -1 && $('#embed' + selected).addClass('OxActive');
|
||||||
pandora.$ui.textEmbed.update(selectedURL);
|
pandora.$ui.textEmbed.update(selectedURL);
|
||||||
|
scrollToSelectedEmbed();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -332,6 +342,8 @@ pandora.ui.textHTML = function(text) {
|
||||||
that[0].scrollTop = that[0].scrollHeight/100 * position;
|
that[0].scrollTop = that[0].scrollHeight/100 * position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
that.scrollTo = scrollTo;
|
||||||
|
|
||||||
that.update = function() {
|
that.update = function() {
|
||||||
$text.options({
|
$text.options({
|
||||||
width: getWidth()
|
width: getWidth()
|
||||||
|
|
Loading…
Reference in a new issue