joseph / Monocle

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

MoveTo(locus) #191

Open nirmaala opened 11 years ago

nirmaala commented 11 years ago

I have following two values : reader.getPlace().percentAtTopOfPage() and reader.getPlace().percentAtBottomOfPage(). Now i want to move to any particular page depending up on these two values . how can i do this. or , I will have to find locus of page for using MoveTo(locus) function. I am not able to find locus of current page. how can i find locus.

Please help me.

lmvco commented 11 years ago

Locus of current page can be obtained using getPlace function of reader object.

reader.getPlace().getLocus();

As example, open the Dickens test case - http://test.monoclejs.com/test/showcase/02-dickens/index.html - and execute the line above in the Javascript console of your browser.

nirmaala commented 11 years ago

Thanks Imvco ,

Yes i am aware of this, I am able to find locus percent bu using var locus = reader.getPlace().getLocus(); var per = locus.percent.

I am working to bookmark a page by saving locus.percent in localstorage .But my problem is that, once i changed the orientation of ipad locus get changed , and when i compare saved locus and changed locus values never matches.

lmvco commented 11 years ago

But locus values are similar or very different?

On other hand, are you call resized function on window resize ?

   /* Because the 'reader' element changes size on window resize,
       * we should notify it of this event. */
      Monocle.Events.listen(
        window,
        'resize',
        function () { window.reader.resized() }
      );
nirmaala commented 11 years ago

When i change orientation locus value changes and following method called:

Monocle.defer(function () {
  if (locus) {
              alert( locus.percent);
              p.flipper.moveTo(locus); }
  dispatchEvent("monocle:recalculated");
});

}

But i am not able to get this locus.percent inside my function.

Sorry , but i am not getting , how to call resized function?