epub.js icon indicating copy to clipboard operation
epub.js copied to clipboard

range.getBoundingClientRect() return 0 for all values

Open anatoly314 opened this issue 9 years ago • 3 comments

Hi, I'm looking for a way to get a callback on selection with selected text and coordinates of selected text. Trying to do it with latest version of v0.3 and the following code:

book.rendition.on("selected", function(cfiRange) {

                book.range(cfiRange).then(function (range) {
                    if (range) {
                        var text = range.toString();
                        console.log(text);
                        var boundedRect = range.getBoundingClientRect();
                        console.log(boundedRect);
                    }
                })
});

Selected text it prints correctly, but boundedRect returns with all values: 0

I've established a Plunker demo here: https://plnkr.co/edit/XlzLP3J2Pp3q53qIkHjq?p=preview Maybe somebody has a clue what gone wrong?

anatoly314 avatar Apr 05 '17 23:04 anatoly314

Having the same issue too , couldn't know why this happened , update please ? this is really limiting a use case where I wanna render something like a tooltip at the end of the selection etc... . any ideas how I could manage that if I'm running to the same issue ?

skhamoud avatar Mar 02 '18 00:03 skhamoud

any luck on this?

ncammarata avatar Aug 16 '18 22:08 ncammarata

#809

ncammarata avatar Aug 16 '18 22:08 ncammarata