Permalink
Browse files

Restoring a couple of defers that seem to be essential for iOS.

  • Loading branch information...
1 parent 7a77d2d commit 539e68d515e51790243bb74a1517ae6af5810522 @joseph joseph committed Oct 14, 2011
Showing with 54 additions and 55 deletions.
  1. +2 −2 src/compat/env.js
  2. +11 −13 src/core/component.js
  3. +3 −3 src/core/reader.js
  4. +38 −34 src/flippers/slider.js
  5. +0 −3 styles/monocore.css
View
@@ -395,14 +395,14 @@ Monocle.Env = function () {
});
}],
- // For some reason, WebKit on the iPad sometimes loses track of a page after
+ // For some reason, iOS MobileSafari sometimes loses track of a page after
// slideOut -- it thinks it has an x-translation of 0, rather than -768 or
// whatever. So the page gets "stuck" there, until it is given a non-zero
// x-translation. The workaround is to set a non-zero duration on the jumpIn,
// which seems to force WebKit to recalculate the x of the page. Weird, yeah.
//
["stickySlideOut", function () {
- result(Monocle.Browser.on.iPad);
+ result(Monocle.Browser.is.MobileSafari);
}]
];
View
@@ -38,24 +38,22 @@ Monocle.Component = function (book, id, index, chapters, source) {
// Makes this component the active component for the pageDiv. There are
// several strategies for this (see loadFrame).
//
- // Some strategies are time-consuming (and usually asynchronous), some are
- // not. When the component has been loaded into the pageDiv's frame, the
- // callback will be invoked with the pageDiv and this component as arguments.
+ // When the component has been loaded into the pageDiv's frame, the callback
+ // will be invoked with the pageDiv and this component as arguments.
//
function applyTo(pageDiv, callback) {
var evtData = { 'page': pageDiv, 'source': p.source };
pageDiv.m.reader.dispatchEvent('monocle:componentchanging', evtData);
- return loadFrame(
- pageDiv,
- function () {
- setupFrame(
- pageDiv,
- pageDiv.m.activeFrame,
- function () { callback(pageDiv, API) }
- );
- }
- );
+ var onLoaded = function () {
+ setupFrame(
+ pageDiv,
+ pageDiv.m.activeFrame,
+ function () { callback(pageDiv, API) }
+ );
+ }
+
+ Monocle.defer(function () { loadFrame(pageDiv, onLoaded); });
}
View
@@ -757,9 +757,9 @@ Monocle.Reader.DEFAULT_STYLE_RULES = [
"overflow: visible !important;" +
"}",
"html#RS\\:monocle body {" +
- "margin: 0;"+
- "border: none;"+
- "padding: 0;"+
+ "margin: 0 !important;"+
+ "border: none !important;"+
+ "padding: 0 !important;"+
"-webkit-text-size-adjust: none;" +
"}",
"html#RS\\:monocle body * {" +
View
@@ -14,6 +14,7 @@ Monocle.Flippers.Slider = function (reader) {
function initialize() {
p.reader = reader;
+ p.reader.listen("monocle:componentchanging", showWaitControl);
}
@@ -105,13 +106,12 @@ Monocle.Flippers.Slider = function (reader) {
function setPage(pageDiv, locus, callback) {
- ensureWaitControl();
p.reader.getBook().setOrLoadPageAt(
pageDiv,
locus,
function (locus) {
pageDiv.m.dimensions.translateToLocus(locus);
- if (callback) { callback(); }
+ Monocle.defer(callback);
}
);
}
@@ -144,8 +144,10 @@ Monocle.Flippers.Slider = function (reader) {
}
p.turnData.lifting = true;
+ var place = getPlace();
+
if (dir == k.FORWARDS) {
- if (getPlace().onLastPageOfBook()) {
+ if (place.onLastPageOfBook()) {
p.reader.dispatchEvent(
'monocle:boundaryend',
{
@@ -158,7 +160,7 @@ Monocle.Flippers.Slider = function (reader) {
}
onGoingForward(boxPointX);
} else if (dir == k.BACKWARDS) {
- if (getPlace().onFirstPageOfBook()) {
+ if (place.onFirstPageOfBook()) {
p.reader.dispatchEvent(
'monocle:boundarystart',
{
@@ -199,7 +201,6 @@ Monocle.Flippers.Slider = function (reader) {
checkPoint(boxPointX);
p.turnData.releasing = true;
- //showWaitControl(lowerPage());
if (dir == k.FORWARDS) {
if (
@@ -245,19 +246,17 @@ Monocle.Flippers.Slider = function (reader) {
function onGoingBackward(x) {
var lp = lowerPage(), up = upperPage();
- showWaitControl(up);
// set lower to "the page before upper"
setPage(
lp,
getPlace(up).getLocus({ direction: k.BACKWARDS }),
function () {
+ // flip lower to upper, ready to slide in from left
flipPages();
// move lower off the screen to the left
jumpOut(lp, function () {
- // flip lower to upper, ready to slide in from left
lifted(x);
- hideWaitControl(up);
});
}
);
@@ -267,31 +266,35 @@ Monocle.Flippers.Slider = function (reader) {
function afterGoingForward() {
var up = upperPage(), lp = lowerPage();
if (p.interactive) {
- showWaitControl(up);
- showWaitControl(lp);
// set upper (off screen) to current
- setPage(up, getPlace().getLocus({ direction: k.FORWARDS }));
- // move upper back onto screen
- jumpIn(up);
- // then set lower to next and reset turn
- prepareNextPage(announceTurn);
+ setPage(
+ up,
+ getPlace().getLocus({ direction: k.FORWARDS }),
+ function () {
+ // move upper back onto screen, then set lower to next and reset turn
+ jumpIn(up, function () { prepareNextPage(announceTurn); });
+ }
+ );
} else {
- showWaitControl(lp);
flipPages();
- jumpIn(up);
- prepareNextPage(announceTurn);
+ jumpIn(up, function () { prepareNextPage(announceTurn); });
}
}
function afterGoingBackward() {
if (p.interactive) {
// set lower page to current
- setPage(lowerPage(), getPlace().getLocus());
- // flip lower to upper
- flipPages();
- // set lower to next and reset turn
- prepareNextPage(announceTurn);
+ setPage(
+ lowerPage(),
+ getPlace().getLocus(),
+ function () {
+ // flip lower to upper
+ flipPages();
+ // set lower to next and reset turn
+ prepareNextPage(announceTurn);
+ }
+ );
} else {
announceTurn();
}
@@ -305,8 +308,7 @@ Monocle.Flippers.Slider = function (reader) {
function afterCancellingBackward() {
flipPages(); // flip upper to lower
- jumpIn(lowerPage());
- prepareNextPage(resetTurnData);
+ jumpIn(lowerPage(), function () { prepareNextPage(resetTurnData); });
}
@@ -338,8 +340,7 @@ Monocle.Flippers.Slider = function (reader) {
function resetTurnData() {
- hideWaitControl(upperPage());
- hideWaitControl(lowerPage());
+ hideWaitControl();
p.turnData = {};
}
@@ -442,7 +443,7 @@ Monocle.Flippers.Slider = function (reader) {
function slideOpts() {
- var opts = { timing: 'ease-in', duration: 360 }
+ var opts = { timing: 'ease-in', duration: 320 }
var now = (new Date()).getTime();
if (p.lastSlide && now - p.lastSlide < 1500) { opts.duration *= 0.5; }
p.lastSlide = now;
@@ -461,17 +462,20 @@ Monocle.Flippers.Slider = function (reader) {
}
- function showWaitControl(page) {
- var ctrl = p.reader.dom.find('flippers_slider_wait', page.m.pageIndex);
- ctrl.style.opacity = 1;
+ function showWaitControl() {
+ ensureWaitControl();
+ p.reader.dom.find('flippers_slider_wait', 0).style.opacity = 1;
+ p.reader.dom.find('flippers_slider_wait', 1).style.opacity = 1;
}
- function hideWaitControl(page) {
- var ctrl = p.reader.dom.find('flippers_slider_wait', page.m.pageIndex);
- ctrl.style.opacity = 0;
+ function hideWaitControl() {
+ ensureWaitControl();
+ p.reader.dom.find('flippers_slider_wait', 0).style.opacity = 0;
+ p.reader.dom.find('flippers_slider_wait', 1).style.opacity = 0;
}
+
// THIS IS THE CORE API THAT ALL FLIPPERS MUST PROVIDE.
API.pageCount = p.pageCount;
API.addPage = addPage;
View
@@ -99,9 +99,6 @@ div.monelem_flippers_slider_wait {
-webkit-background-size: 100%;
-moz-background-size: 100%;
background-size: 100%;
- -webkit-transition: opacity 160ms ease-out 0ms;
- -moz-transition: opacity 160ms ease-out 0ms;
- transition: opacity 160ms ease-out 0ms;
}
@media screen and (max-width: 640px) {

0 comments on commit 539e68d

Please sign in to comment.