Created
June 29, 2012 13:53
-
-
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 )
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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