Skip to content

Instantly share code, notes, and snippets.

@ppcano
Created June 29, 2012 13:53
Show Gist options
  • Select an option

  • Save ppcano/3018075 to your computer and use it in GitHub Desktop.

Select an option

Save ppcano/3018075 to your computer and use it in GitHub Desktop.
Mixin to mark a view being visible via the scroller ( also using iscroll4 )
Yn.IsScrollVisible = Em.Mixin.create({
scrollVisibleId: null,
isScrollVisible: false,
didInsertElement: function() {
this._super();
var scroll = $(this.scrollVisibleId);
var self = this,
height = self.$().height();
var wrapper = scroll.parent();
var limit = wrapper.offset().top + wrapper.height();
var destroyCheck = function() {
scroll.unbind('touchmove',check);
};
var check = function() {
var elemTop = self.$().offset().top;
//console.log( Em.String.fmt('checking: top (%@) docViewBottom (%@)', [elemTop, limit]) );
if ( (elemTop <= limit) ) {
destroyCheck();
self.set('isScrollVisible', true);
self.appear();
}
};
scroll.bind('touchmove',check);
// check before first touch move
check();
},
appear: function() {
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment