File tree Expand file tree Collapse file tree 2 files changed +15
-8
lines changed Expand file tree Collapse file tree 2 files changed +15
-8
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " responsive" ,
3- "version" : " 1.1.0 " ,
3+ "version" : " 1.1.1 " ,
44 "description" : " " ,
55 "main" : " responsive.js" ,
66 "repository" : {
Original file line number Diff line number Diff line change 8181 this . eventEmitter = new EventEmitter ( ) ;
8282 }
8383
84- setTimeout ( function defer ( ) {
85- this . listen ( ) ;
86- this . update ( ) ;
87- } . bind ( this ) ) ;
84+ this . listen ( ) ;
85+ this . update ( true ) ;
8886 }
8987
90- Responsive . prototype . update = function ( ) {
88+ Responsive . prototype . update = function ( deferEvents ) {
9189 var _previousBreakpoints = this . _currentBreakpoints ;
9290 this . _currentBreakpoints = _ . filter ( _ . keys ( this . breakpoints ) , function ( breakpoint ) {
9391 return ! ! matchMedia ( this . breakpoints [ breakpoint ] ) . matches ;
9492 } , this ) ;
9593
9694 if ( ! _ . isEqual ( _previousBreakpoints , this . _currentBreakpoints ) ) {
97- this . dispatchEvents ( this . _currentBreakpoints , _previousBreakpoints ) ;
95+ if ( deferEvents ) {
96+ setTimeout ( function defer ( ) {
97+ this . dispatchEvents ( this . _currentBreakpoints , _previousBreakpoints ) ;
98+ } . bind ( this ) ) ;
99+ }
100+ else {
101+ this . dispatchEvents ( this . _currentBreakpoints , _previousBreakpoints ) ;
102+ }
98103 }
99104 } ;
100105
101106 Responsive . prototype . listen = function ( ) {
102107 if ( ! this . listening ) {
103- window . addEventListener ( 'resize' , _ . throttle ( this . update . bind ( this ) , 1000 ) ) ;
108+ window . addEventListener ( 'resize' , _ . throttle ( function handleResize ( ) {
109+ this . update ( ) ;
110+ } . bind ( this ) , 1000 ) ) ;
104111 this . listening = true ;
105112 }
106113 } ;
You can’t perform that action at this time.
0 commit comments