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

feat: How do you trigger a collection-repeat resize() in v1.0.0-rc0? #3292

Closed
mixersoft opened this issue Mar 11, 2015 · 7 comments
Closed

Comments

@mixersoft
Copy link

Type: feat

Platform: all

I'm not sure if this is a bug or not, but in beta14 I was able to force the collection-repeat directive to recalculate dimensions and re-render with a call like this, $ionicScrollDelegate.$getByHandle('collection-repeat-wrap').resize(). This no longer seems to work with the new, refactored collection-repeat from 1.0.0-rc0

    $ionicScrollDelegate.$getByHandle('collection-repeat-wrap').resize()
   // trying to get collection-repeat directive to run this code:
    var onWindowResize = ionic.animationFrameThrottle(validateResize);
    angular.element($window).on('resize', onWindowResize);
     <ion-content delegate-handle="collection-repeat-wrap">
      <div collection-repeat="item in items">
        ...
      </div>
    </ion-content>

Is there a better way to do this?

@mixersoft mixersoft changed the title How do you trigger a collection-repeat resize() in v1.0.0-rc0? feat: How do you trigger a collection-repeat resize() in v1.0.0-rc0? Mar 11, 2015
@ajoslin
Copy link
Contributor

ajoslin commented Mar 11, 2015

Try triggering a resize on the window.

angular.element($window).triggerHandler('resize');

@mixersoft
Copy link
Author

i tried it. it doesn't work because of this method - it there an easy way to add a --force option?

function validateResize() {
  var h = scrollView.__clientHeight, w = scrollView.__clientWidth;
  if (w && h && (validateResize.height !== h || validateResize.width !== w)) {
    validateResize.height = h;
    validateResize.width = w;
    refreshDimensions();
  }
}

@mixersoft
Copy link
Author

I added this these lines to the directive for now, but there has to be a better way

var onWindowResize = ionic.animationFrameThrottle(validateResize);
angular.element($window).on('resize', onWindowResize);
// force collection-repeat refresh with a call to:
//    angular.element($window).triggerHandler('resize.collection-repeat');
var onWindowResizeFORCE = ionic.animationFrameThrottle(refreshDimensions);
angular.element($window).on('resize.collection-repeat', onWindowResizeFORCE);

@zarko-tg
Copy link

Made a small test case: http://codepen.io/zarko/pen/VYEQZM

@ajoslin
Copy link
Contributor

ajoslin commented Mar 12, 2015

Ah you're right that won't work. I'll add a better way.
On Thu, Mar 12, 2015 at 07:04 Zarko Hristovski notifications@github.com
wrote:

Made a small test case: http://codepen.io/zarko/pen/VYEQZM


Reply to this email directly or view it on GitHub
#3292 (comment).

@ajoslin
Copy link
Contributor

ajoslin commented Mar 12, 2015

It now refreshes dimensions when $ionicScrollDelegate.resize() is called. Thanks!

@zarko-tg
Copy link

Thanks. I also updated the codepen and seems just fine now.

@Fayozjon
Copy link

Zarko

http://sustainabletechknow.com/youtube_range

13.03.2015, 01:54, "Zarko Hristovski" notifications@github.com:Thanks. I also updated the codepen and seems just fine now.

—Reply to this email directly or .

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants