Skip to content

Commit

Permalink
Added timeout to resizeThrottle
Browse files Browse the repository at this point in the history
  • Loading branch information
IanLunn committed Apr 22, 2015
1 parent b696c3f commit 06d96f5
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 28 deletions.
30 changes: 17 additions & 13 deletions scripts/sequence.js
Original file line number Diff line number Diff line change
Expand Up @@ -3297,20 +3297,24 @@ function defineSequence(imagesLoaded, Hammer) {
// Events to be executed when the throttled window resize occurs
function throttledEvents() {

self.canvas.getTransformProperties();
// Use a delay to give the browser a chance to repaint before
// getting transform properties
setTimeout(function() {
self.canvas.getTransformProperties();

/**
* Snap to the currently active step
*
* Assume the canvas is laid out in a 2 x 2 grid, the Sequence
* element has a height of 100%, and the user is viewing the second
* row of steps -- when the user resizes the window, the second row
* of steps will no longer be positioned perfectly in the window.
* This event will immediately snap the canvas back into place.
*/
if (self.propertySupport.transitions === true) {
self.canvas.move(self.currentStepId, false);
}
/**
* Snap to the currently active step
*
* Assume the canvas is laid out in a 2 x 2 grid, the Sequence
* element has a height of 100%, and the user is viewing the second
* row of steps -- when the user resizes the window, the second row
* of steps will no longer be positioned perfectly in the window.
* This event will immediately snap the canvas back into place.
*/
if (self.propertySupport.transitions === true) {
self.canvas.move(self.currentStepId, false);
}
}, 500);

// Callback
self.throttledResize(self);
Expand Down
2 changes: 1 addition & 1 deletion scripts/sequence.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion scripts/sequence.min.map

Large diffs are not rendered by default.

30 changes: 17 additions & 13 deletions src/sequence.js
Original file line number Diff line number Diff line change
Expand Up @@ -3297,20 +3297,24 @@ function defineSequence(imagesLoaded, Hammer) {
// Events to be executed when the throttled window resize occurs
function throttledEvents() {

self.canvas.getTransformProperties();
// Use a delay to give the browser a chance to repaint before
// getting transform properties
setTimeout(function() {
self.canvas.getTransformProperties();

/**
* Snap to the currently active step
*
* Assume the canvas is laid out in a 2 x 2 grid, the Sequence
* element has a height of 100%, and the user is viewing the second
* row of steps -- when the user resizes the window, the second row
* of steps will no longer be positioned perfectly in the window.
* This event will immediately snap the canvas back into place.
*/
if (self.propertySupport.transitions === true) {
self.canvas.move(self.currentStepId, false);
}
/**
* Snap to the currently active step
*
* Assume the canvas is laid out in a 2 x 2 grid, the Sequence
* element has a height of 100%, and the user is viewing the second
* row of steps -- when the user resizes the window, the second row
* of steps will no longer be positioned perfectly in the window.
* This event will immediately snap the canvas back into place.
*/
if (self.propertySupport.transitions === true) {
self.canvas.move(self.currentStepId, false);
}
}, 500);

// Callback
self.throttledResize(self);
Expand Down

0 comments on commit 06d96f5

Please sign in to comment.