Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace font loader with a resize event in reflow and scroll view #308

Merged
Prev Previous commit
Next Next commit
Debounce ResizeSensor events in continuous ScrollView
  • Loading branch information
olivierkorner committed Sep 9, 2016
commit ab53a60cb7c19814a93b42fd7a569535b632c89a
26 changes: 13 additions & 13 deletions js/views/scroll_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,17 +368,11 @@ var ScrollView = function (options, isContinuousScroll, reader) {
newView.loadSpineItem(prevSpineItem, function (success, $iframe, spineItem, isNewlyLoaded, context) {
if (success) {

var continueCallback = function (successFlag)
{
onPageViewLoaded(newView, success, $iframe, spineItem, isNewlyLoaded, context);

callback(successFlag);
};

updatePageViewSizeAndAdjustScroll(newView);
onPageViewLoaded(newView, success, $iframe, spineItem, isNewlyLoaded, context);
callback(success);
// No need for complicated reachStableContentHeight any more
// Remove this
//reachStableContentHeight(0, newView, $iframe[0], spineItem.href, spineItem.isFixedLayout(), spineItem.isFixedLayout() ? newView.meta_width() : 0, "addToTopOf", continueCallback); // //onIFrameLoad called before this callback, so okay.
}
else {
Expand Down Expand Up @@ -509,16 +503,22 @@ var ScrollView = function (options, isContinuousScroll, reader) {
self.emit(Globals.Events.CONTENT_DOCUMENT_LOAD_START, $iframe, spineItem);
});

pageView.on(OnePageView.Events.CONTENT_SIZE_CHANGED, function($iframe, spineItem) {

Globals.logEvent("OnePageView.Events.CONTENT_SIZE_CHANGED", "ON", "scroll_view.js [ " + spineItem.href + " ]");

function updatePageViewSizeAndPagination_() {
// Resize the PageView to fit its content and update the pagination
// and the adjacent views
updatePageViewSize(pageView);

onPaginationChanged(self);

updateTransientViews();
}
var updatePageViewSizeAndPagination = _.debounce(updatePageViewSizeAndPagination_, 100);

// Observe the CONTENT_SIZE_CHANGED from the page view so the ScrollView
// is notified when the size of the content of the view changes, because
// the font or the viewport size has changed
pageView.on(OnePageView.Events.CONTENT_SIZE_CHANGED, function($iframe, spineItem) {

Globals.logEvent("OnePageView.Events.CONTENT_SIZE_CHANGED", "ON", "scroll_view.js [ " + spineItem.href + " ]");
updatePageViewSizeAndPagination();
});

pageView.render();
Expand Down