This repository was archived by the owner on Dec 30, 2018. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 131131 columnWidth : parseInt ( attrs . columnWidth , 10 ) || attrs . columnWidth
132132 } , attrOptions || { } ) ;
133133 element . masonry ( options ) ;
134+ scope . masonryContainer = element [ 0 ] ;
134135 var loadImages = scope . $eval ( attrs . loadImages ) ;
135136 ctrl . loadImages = loadImages !== false ;
136137 var preserveOrder = scope . $eval ( attrs . preserveOrder ) ;
137- ctrl . preserveOrder = ( preserveOrder !== false && attrs . preserveOrder !== undefined ) ;
138+ ctrl . preserveOrder = ( preserveOrder !== false && attrs . preserveOrder !== undefined ) ;
138139 var reloadOnShow = scope . $eval ( attrs . reloadOnShow ) ;
139140 if ( reloadOnShow !== false && attrs . reloadOnShow !== undefined ) {
140141 scope . $watch ( function ( ) {
147148 }
148149 var reloadOnResize = scope . $eval ( attrs . reloadOnResize ) ;
149150 if ( reloadOnResize !== false && attrs . reloadOnResize !== undefined ) {
150- scope . $watch ( function ( ) {
151- return element . prop ( 'offsetWidth' ) ;
152- } , function ( newWidth , oldWidth ) {
151+ scope . $watch ( 'masonryContainer.offsetWidth' , function ( newWidth , oldWidth ) {
153152 if ( newWidth != oldWidth ) {
154153 ctrl . reload ( ) ;
155154 }
Original file line number Diff line number Diff line change @@ -82,15 +82,15 @@ describe 'angular-masonry', ->
8282 element = angular .element ' <masonry reload-on-resize></masonry>'
8383 element = $compile (element)(@scope )
8484
85- expect (@scope .$watch ).toHaveBeenCalled ()
85+ expect (@scope .$watch ).toHaveBeenCalledWith ( ' masonryContainer.offsetWidth ' , sinon . match . func );
8686 )
8787
8888 it ' should not setup a $watch when the reload-on-resize is missing' , inject (($compile ) =>
8989 sinon .spy (@scope , ' $watch' )
9090 element = angular .element ' <masonry></masonry>'
9191 element = $compile (element)(@scope )
9292
93- expect (@scope .$watch ).not .toHaveBeenCalled ()
93+ expect (@scope .$watch ).not .toHaveBeenCalledWith ( ' masonryContainer.offsetWidth ' , sinon . match . func );
9494 )
9595
9696 describe ' MasonryCtrl' , =>
You can’t perform that action at this time.
0 commit comments