From 15510af60a0d6e76af1b84d0e7a56be0f59793f7 Mon Sep 17 00:00:00 2001 From: Lu Wang Date: Mon, 4 Nov 2013 22:32:00 +0800 Subject: [PATCH] working on offset_to --- share/pdf2htmlEX.js.in | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/share/pdf2htmlEX.js.in b/share/pdf2htmlEX.js.in index 25fefb7..6c7a274 100644 --- a/share/pdf2htmlEX.js.in +++ b/share/pdf2htmlEX.js.in @@ -195,15 +195,18 @@ position : function () { return this.offset_to(this.$container.get(0)); + /* var off = this.$p.offset(); var off_c = this.$container.offset(); return [off_c.left-off.left, off_c.top-off.top]; + */ }, /* * Similar to position, but specify container as ele * ele must be an ancestor node of current page * TODO: remove position * TODO: consider border + * TODO: consider scroll */ offset_to : function (ele) { var elep = ele.offsetParent; @@ -212,18 +215,19 @@ var cur_left = 0; while(true) { switch(cur_e) { - case null; + case null: return; case elep: cur_top -= ele.offsetTop; cur_left -= ele.offsetLeft; /* fall through */ case ele: + window['console']['log'](cur_top+' '+cur_left); return [cur_top, cur_left]; default: cur_top += cur_e.offsetTop; cur_left += cur_e.offsetLeft; - cur_e = cur_e.offstParent; + cur_e = cur_e.offsetParent; } } }