joseph / Monocle

A silky, tactile browser-based ebook JavaScript library.
http://monocle.inventivelabs.com.au
MIT License
743 stars 200 forks source link

Creating bookmarks #244

Open CoreyEWalsh opened 10 years ago

CoreyEWalsh commented 10 years ago

I'm trying to replicate booki.sh's use of bookmarks in their book.

Does anybody have any insight on how I can do this?

AbhilashThomas commented 10 years ago

Don't know about booki.sh, but you could use something like

var locus = {
      componentId: reader.getPlace().componentId(),
      percent: reader.getPlace().percentageThrough()
    }

/// or better

var locus = reader.getPlace().getLocus();

You can then use the 'locus' to move to that location in the book.

reader.moveTo(locus);

//which will go as

reader.moveTo({componentId:"components/3.html",percent:0.8});

If you want to persist the book mark, see the placesaver control to understand how to store in cookie or localStorage.