mirror of
https://github.com/pdf2htmlEX/pdf2htmlEX.git
synced 2024-12-22 04:50:09 +00:00
working on offset_to
This commit is contained in:
parent
1c41b1ae04
commit
15510af60a
@ -195,15 +195,18 @@
|
|||||||
position : function () {
|
position : function () {
|
||||||
return this.offset_to(this.$container.get(0));
|
return this.offset_to(this.$container.get(0));
|
||||||
|
|
||||||
|
/*
|
||||||
var off = this.$p.offset();
|
var off = this.$p.offset();
|
||||||
var off_c = this.$container.offset();
|
var off_c = this.$container.offset();
|
||||||
return [off_c.left-off.left, off_c.top-off.top];
|
return [off_c.left-off.left, off_c.top-off.top];
|
||||||
|
*/
|
||||||
},
|
},
|
||||||
/*
|
/*
|
||||||
* Similar to position, but specify container as ele
|
* Similar to position, but specify container as ele
|
||||||
* ele must be an ancestor node of current page
|
* ele must be an ancestor node of current page
|
||||||
* TODO: remove position
|
* TODO: remove position
|
||||||
* TODO: consider border
|
* TODO: consider border
|
||||||
|
* TODO: consider scroll
|
||||||
*/
|
*/
|
||||||
offset_to : function (ele) {
|
offset_to : function (ele) {
|
||||||
var elep = ele.offsetParent;
|
var elep = ele.offsetParent;
|
||||||
@ -212,18 +215,19 @@
|
|||||||
var cur_left = 0;
|
var cur_left = 0;
|
||||||
while(true) {
|
while(true) {
|
||||||
switch(cur_e) {
|
switch(cur_e) {
|
||||||
case null;
|
case null:
|
||||||
return;
|
return;
|
||||||
case elep:
|
case elep:
|
||||||
cur_top -= ele.offsetTop;
|
cur_top -= ele.offsetTop;
|
||||||
cur_left -= ele.offsetLeft;
|
cur_left -= ele.offsetLeft;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case ele:
|
case ele:
|
||||||
|
window['console']['log'](cur_top+' '+cur_left);
|
||||||
return [cur_top, cur_left];
|
return [cur_top, cur_left];
|
||||||
default:
|
default:
|
||||||
cur_top += cur_e.offsetTop;
|
cur_top += cur_e.offsetTop;
|
||||||
cur_left += cur_e.offsetLeft;
|
cur_left += cur_e.offsetLeft;
|
||||||
cur_e = cur_e.offstParent;
|
cur_e = cur_e.offsetParent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user